Plan: Audit rows name who acted, and every detection rule can fire
Status
Done (2026-11-17) — audit rows name the worker or the calling service where a publisher holds one, and the detection rules count closed action tokens.
Closes: #3116, #3114. Depends on: #2314 (merged through !2405: the audit header is where an actor is stated).
Tree: written against feat/audit-header-parser-removal (main plus !2404 and !2405).
Rulings (maintainer, 2026-11-16/17): one plan for both issues, built right after #2314; an SSN release names the
requesting caseworker; the real initiator is named wherever the staging site knows it; the privilege-escalation rule
counts denials; the failed-authentication and account-lockout rules are removed until an identity-provider event
feed exists.
Erratum (2026-11-17): the removed rule types are refused with the existing 400 invalid-enum-value, which is what an unknown rule_type already answers; the Tests table’s "existing 422" was wrong.
Erratum (2026-11-17): two of step 1’s three devstack "fires on a real publisher’s rows" tests build an envelope with the header that publisher states, because craig-security cannot call another service’s publisher; the denial test uses craig-authz’s real builder.
Erratum (2026-11-17): step 3 lowers no ceiling. Each of its six sites keeps a SYSTEM_OR_RECORDLESS row, reworded: five can still state System on a path that remains, and the placement AFCARS release names no record. The ceiling stays 55.
Erratum (2026-11-17): the engine never evaluates for itself, so rules.evaluated states System only for a caller whose claims name neither a worker nor a service and whose raw sub is empty or the word system.
Erratum (2026-11-17): a manual scan’s alert names the acting principal by D1, which is service:<name> for a service caller the scan’s authorization admits; D2’s row said Sub(worker) only.
Erratum (2026-11-17): five of step 3’s publishers build their envelope in a named function their unit tests call, so their allowlist rows are keyed by that function (afcars_released_envelope, payment_created_envelope, payments_voided_envelope, alert_created_envelope, evaluated_envelope). The sweep’s admin reaches the header through a field of the event struct that is never serialized, not a publisher parameter.
Context
-
#3116.
SYSTEM_OR_RECORDLESS(services/craig-security/src/audit_header_census_tests.rs, 58 rows, ceiling 58) lists every site whose header statesSystemor no record. Most are right (a scheduler, a reconciler, an inbox consumer, a cache signal). Some are not: the act has a worker or a calling service behind it and the row sayssystemonly because the payload never carried an actor key the old parser lifted. The clearest ispublish_person_pii_released_for_screening(services/craig-cases/src/events.rs): an SSN release that names nobody, though its payload carriesrequested_by. -
#3114. The five pattern rules of
services/craig-security/src/detection_sql.rscountaudit_logrows byILIKEonaction. With the closed action set (crates/craig-mq/src/audit_meta.rs),%auth%fail%,%privilege%,%escalat%,%unauthorized%,%lockout%,%get%,%list%and%download%match no token (the_detection_substrings_match_the_same_actions_as_before,services/craig-security/src/audit_columns.rs), so three of the rule types can never fire.
Design
D1. The actor rule
A header states, in this order of preference:
-
Sub(worker)when a worker’s act or a worker-started run causes the event and the staging site holds that worker. -
AuditActor::named("service:<name>")when a service principal called and no worker is known. The text is the ADR-085 encoding craig-authz already writes (acting_encoding,crates/craig-authz/src/engine.rs). -
Systemonly for a scheduler tick, a reconciler, an inbox consumer acting on another service’s event, or a cache signal.
A worker asserted by a calling service as data (not the authenticated caller) may be stated as Sub only when the
endpoint is service-only and allowlisted to that one caller. The authenticated service stays in the payload.
D2. Sites that change
| Site (publisher) | Today | After |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
the run’s |
|
|
|
|
|
|
|
|
|
|
|
the evaluator the evaluation row already records, by D1; |
Each publisher gains the actor as a typed parameter (AuditActor or the existing initiator type); no payload key is
added or removed, so consumers are untouched. Sites not in the table keep their header and their allowlist row.
publish_subsidy_anchor_replaced, publish_payment_generation_skipped and the auto-link pass stay System: they are
inbox consumers, and the causing worker is on the causing event.
A site that can state System on some path keeps its SYSTEM_OR_RECORDLESS row, reworded to name the paths that
remain. The two SSN sites and the two person-PII release sites lose System entirely; the ceiling drops by the rows
that lose both System and a None id (the refusal, at least), and SYSTEM_OR_RECORDLESS_CEILING is lowered to the
new length.
D3. Detection rules count closed tokens
detection_sql.rs stops matching substrings. Each rule’s predicate names action tokens exactly:
| Rule type | Predicate on audit_log |
|---|---|
|
|
|
|
|
|
|
unchanged |
The token lists are built in Rust from AuditAction variants (as_token()), so a renamed token cannot drift from
the SQL. failed_auth and account_lockout are removed: the rule_type CHECK and VALID_RULE_TYPES
(services/craig-security/src/api/mod.rs) lose them, count_for_rule (detection.rs) loses their arms, and the
CLI help (services/craig-cli/src/cmd/detection.rs) and store/models.rs docs follow. The same step changes every
place that creates a rule of a removed type, or it is not green alone: the seeder
(tools/craig-seed/src/datagen/security.rs, the failed_auth_burst and account_lockout_pattern rules, replaced by
a privilege_escalation rule) and the fixtures in services/craig-security/tests/api/detection.rs,
config_act_events.rs, refusal_echo.rs, replay_guards.rs and the unit test in src/detection.rs, which move to
bulk_access (a test that needs a removed type to prove the refusal keeps it as the refused input).
One migration in craig-security (ADR-063 contract migration, floor bump): detach alerts from rules of the two
removed types (security_alerts.rule_id = NULL; such alerts cannot exist unless hand-inserted, since the rules
never fired), delete those rules, tighten the CHECK, drop the five partial indexes of
20260726060000_detection_partial_indexes.sql and create three that mirror the new predicates.
privilege_escalation counts every denial system-wide (ruled 2026-11-17): a rule’s threshold and
window_minutes are its tuning. Per-actor counting is not built here.
A headerless degraded row stores the halves of its event type, so one whose type ends in a counted token
(placement.portal_read, reporting.afcars_export_generated) still counts. That is the intended direction: it is
the same act, filed without its header, and detection should not go blind to it.
bulk_access counts what publishers state today: portal_read (caregiver portal reads) and read (the placement
AFCARS release). A worker’s ordinary record read stages no event and is not counted by any rule; that is unchanged
and out of scope.
Scope and order
One merge request per step, each green alone.
-
Detection (
Closes #3114): D3, its migration, tests, docs, fragmentchangelog.d/3114.changed.adoc. -
craig-cases actors (
Relates to #3116): the SSN release and refusal, the SOLQ flip, the two releases, the intake-edge report. Fragmentchangelog.d/3116.cases.changed.adoc. -
The rest (
Closes #3116): craig-placement, craig-financial, craig-security, craig-exchange, craig-rules; the ceiling lowered. Fragmentchangelog.d/3116.changed.adoc.
Risks
| Risk | Mode | Mitigation |
|---|---|---|
A service asserts a worker who did not act, and the SSN release row names them. |
silent |
Only the service-only, single-caller |
A worker path of a changed publisher is passed |
silent |
The allowlist row for each mixed site names its remaining |
|
fail-closed |
One standing alert per rule ( |
A deployment has rules of the removed types; the migration deletes them. |
fail-closed |
They could never fire; the release note says they are deleted and why; |
A token is renamed or added and a predicate silently stops matching. |
silent |
Predicates are built from |
The new partial indexes do not match the predicates and scans go back to the heap. |
silent |
The existing plan-pin integration test reads the shared constants; it is extended to the three new indexes. |
A headerless degraded row is missed by a rule its act belongs to, or an unrelated type is counted by a substring accident. |
silent |
Exact token equality replaces substring match, and a degraded row whose event type ends in a counted token still counts (D3); |
Tests
| Category | Tests |
|---|---|
Regression (#3114) |
|
Regression (#3116) |
Per changed site, a non-devstack test of the stated header on each path (worker, service, system); the census |
Integration (devstack-gated, run by the car) |
Each rule fires on rows a real publisher staged: a denial through craig-authz for |
Migration |
|
Hostile input |
The rule-create handler refuses |
Every new test gets a red proof. Devstack-gated tests are written and compiled locally and run by the train car.
Delivery
-
Canonical page:
docs/modules/ROOT/pages/data-model-security.adoc(§audit_log: who the actor is, by D1; § detection rules: the predicates and the four rule types). -
Also updated: every live page that lists the rule types (
security-operations.adoc,nist-architecture-mapping.adoc;security.adoclists none); the CLI help text. Archived plan pages are not edited. -
CHANGELOG entry: the three fragments named under Scope, each a declared audit-row or behaviour change with its Ops clause (review
privilege_escalationthresholds; rules of the removed types are deleted; saved filters onuser_id = 'system'for the listed events must change). -
Close:
Closes #3114on step 1,Closes #3116on step 3; one line with each merge SHA; thencargo xtask plan-lint --doneand the archive move.
Review log
| Round | Vendor | Resolved model | Verdict |
|---|---|---|---|
1 |
Anthropic |
claude-fable-5-2 |
FLAGS (1): the removed rule types' seeder and fixtures were missing from step 1; folded. |
2 |
gemini-4-carbon |
FLAGS (1): the backpay caller, the seeder, the headerless-row risk and the doc pages; folded. Approved by the maintainer in plan mode, 2026-11-17. |