Plan: Events carry their audit header; the event-type string table goes

Status

Done (2026-11-17) — every event states its audit header, staging refuses one without it, craig-security files each row from the header and a headerless message as a degraded system row, and the event-type string table and its two censuses are deleted.

Closes: #2314 (epic &105). Branch: one refactor/audit-header-<step> per step of § Scope and order.
Tree: written against main of 2026-11-15; line references are to that tree.

Erratum (2026-11-16): D1 names the UUID spelling as its one declared row change, but the header’s bounds change rows too once a publisher with a text actor or roles migrates: an actor over 256 bytes is cut with no truncation marker (the parser capped at 1024 and wrote one), a denial keeps at most 32 roles of 128 bytes, an empty actor is stored as system, and a forged header with an unreadable resource token stores unknown where the parser stored authz_decision. The headerless path keeps the old values until the last step.

Erratum (2026-11-16): a denial whose only role is empty text states no roles, so its row keeps the role unknown the parser gave it.

Erratum (2026-11-17): D8’s "carries forward" means the allowlist test takes over the property of the two actor-key censuses; they, CHAIN_PINS and CONTEXT are deleted with their file, since both are defined against the parser’s actor chain.

Context

craig-security binds its audit queue to every routing key (#, services/craig-security/src/lib.rs:603 and :617). For each event, handle_inbound_event (lib.rs:777-864) writes one audit_log row. The envelope (crates/craig-mq/src/envelope.rs:20-37) carries id, timestamp, source_service, event_type, an untyped payload and trace_context. It carries nothing that says who acted on what. The subscriber guesses, in services/craig-security/src/event_parsing.rs (5,484 lines, about 1,440 of them production code):

  • Action and resource type come from a string table keyed by event_type (parse_event_type, :717-810, and its sub-catalogs, :828-1440). Three payload lifts sit on top (parse_envelope_type :548, parse_authz_access_denied :496).

  • Resource id comes from a payload key guess: a prefix-family table and a generic key list (:59-66, :82, extract_resource_id :447).

  • Actor is the first payload key present among created_by, approved_by, user_id, archived_by, sub (ACTOR_KEYS :31), else system.

  • Role and outcome are unknown and success, except for authz.access_denied.

Two census tests hold this together by lexing every publisher in the workspace: event_parsing/audit_census_tests.rs (1,293 lines) and event_parsing/resource_census_tests.rs (2,034 lines). The second lists all 190 routing keys the fleet stages (CENSUS, :75-816). Every publisher must stay in step with a table in another service, and each actor or id fix (#1913, #2231, #2245) was a miss of that kind.

The publisher knows the action, the record and the actor as typed values at the staging site, so it should say them. One property constrains the change. The detection rules count rows by substring of the action column (services/craig-security/src/detection_sql.rs:14-36): %auth%fail%, %read%, %get%, %list%, %privilege%, %escalat%, %unauthorized%, %export%, %download%, %lockout%. The action text is therefore part of the detection contract, and it must not change.

Design

D1. AuditMeta and its home

New file crates/craig-mq/src/audit_meta.rs, re-exported from the crate root.

pub struct AuditMeta { action, resource_type, resource_id, actor, outcome, actor_roles, degraded }  // all private
pub enum AuditAction   { Create, Update, /* … D2 */ Unknown }
pub enum AuditResource { Case, Payment,  /* … D2 */ Unknown }
pub enum AuditActor    { Sub(Uuid), System, Named(ActorName) }
pub struct ActorName(String);                                     // private field
pub enum AuditOutcome  { Done, Refused }
  • AuditMeta::new(action, resource_type, resource_id: Option<Uuid>, actor) sets outcome = Done and no roles. A nil UUID is stored as None. .refused() sets Refused; .with_roles(Vec<String>) sets actor_roles. Read accessors return each field. The constructor is infallible; D4 says where an Unknown token is refused.

  • The actor. Sub is a worker’s UUID. System is no actor. Named carries, verbatim, every non-UUID actor the audit log holds today: service:<name>, config:<layer>@<sha>, system:<pass> (system:retention), a raw sub that does not parse, and a legacy text such as legacy-operator.

  • ActorName’s field is private and it has no public constructor, so code outside craig-mq cannot write `AuditActor::Named(..) itself. AuditActor::named(text: &str) → AuditActor is the only way to build Named (a_named_actor_cannot_be_built_outside_craig_mq, a compile_fail doctest on ActorName), and it normalises: text that Uuid::parse_str accepts is Sub; empty text or system is System; anything else is Named. So Named is never empty and never UUID-shaped. a_uuid_shaped_actor_is_always_sub (property) pins it.

  • The header is bounded at construction, so no publisher can stage one of unbounded size: named keeps at most 256 bytes of the text (cut on a character boundary), and with_roles keeps at most 32 roles of at most 128 bytes each. from_wire applies the same bounds. an_audit_header_serialises_within_its_bound (property, in crates/craig-mq/src/audit_meta.rs) asserts the serialised header never exceeds MAX_AUDIT_HEADER_BYTES, a constant computed from those limits.

  • AuditActor::user_id() returns the text for audit_log.user_id: the hyphenated lowercase UUID, system, or the Named text. One declared change: a UUID actor written in another spelling (upper case, no hyphens) is stored verbatim today and in the canonical spelling on the header path.

  • Wire. The header is an object with the keys action, resource_type, resource_id (omitted when none), actor (the user_id() text), outcome (done or refused) and actor_roles (omitted when empty). degraded is not on the wire.

  • Decode is per field (AuditMeta::from_wire(&serde_json::Value) → Option<AuditMeta>). A bad field never discards its siblings (a_bad_header_field_keeps_its_siblings):

    • action, resource_type: a missing, non-string or unknown token is Unknown.

    • resource_id: anything but a non-nil UUID string is None.

    • actor: a string goes through AuditActor::named; a missing or non-string value is System.

    • outcome: done or refused; any other value is Refused when the action is deny, else Done. A refusal is never recorded as a success because its outcome was garbled (a_garbled_outcome_on_a_deny_stays_refused).

    • actor_roles: an array keeps its string members; anything else is empty.

    • Each substitution above, except an absent resource_id or actor_roles, sets degraded (AuditMeta::is_degraded()).

    • Only a value that is not a JSON object returns None: the envelope is then headerless (D5).

  • The types live in craig-mq because the envelope does, and because craig-authz depends on craig-mq (crates/craig-authz/Cargo.toml:22), so craig-mq cannot name craig-authz’s ResourceType.

D2. The closed enums and their tokens

Both enums serialise with #[serde(rename_all = "snake_case")]. A variant is the token in UpperCamelCase, one capital per underscore-separated word, an acronym treated as a word: afcars_export_failed is AfcarsExportFailed, ive_determination is IveDetermination, icpc_request is IcpcRequest, nist_control is NistControl. The token set is fixed by what the audit log holds today.

AuditAction, 43 tokens. The 35 the table’s arms emit: abort, afcars_export_failed, afcars_export_generated, archive, assign_admin_unit, authz_fallback_admit, catch_up, create, delete, deny, dismiss, evaluate, export, field_proposal_decided, field_proposed, field_written, import, link_persons, ncands_export_failed, ncands_export_generated, portal_read, promote, purge, read, refuse_release, release, replay, restage, reveal, revoke_admin_unit, rollback, send_requested, system, update, upload_failed. And the 8 of the routing keys that have no arm and take the raw split today (generic_event_split, event_parsing.rs:812-819): assignment_changed, child_facts_changed, permanency_plan_established, cache_miss, cache_refreshed, cache_invalidated, invalidated, changed.

AuditResource, 85 tokens. The 75 of CENSUS: admin_unit, afcars_submission, authz, authz_decision, caregiver_identity, case, case_plan, case_plan_task, claim, composition, composition_override, contact, contact_attachment, court_order, custody_episode, data_quality_issue, dead_letter, detection_rule, education_record, event_outbox, exchange_agreement, exchange_partner, exchange_send_job, exchange_transaction, field_proposal, foster_home, foster_home_caregiver, foster_portal, governed_record, health_record, home_document, household_member, icpc_attachment, icpc_request, investigation, ive_determination, major_change, medicaid_application, ncands_submission, nist_control, partner, partner_api_key, partner_signer_key, payment, payment_adjustment, person, placement, portal_invitation, rate_table, referral, removal_episode, report, report_attachment, report_person, rule_evaluation, rule_evaluations, rule_set, rules, ruleset, screening_cohort, screening_review, screening_run, security_alert, security_archive, security_review, ssa_screening_job, subsidy_agreement, subsidy_backpay_batch, subsidy_generation, subsidy_import, subsidy_review, subsidy_sweep, trigger_admission, worker_admin_unit, worker_identity. Plus security (the unknown security.* catch-all, event_parsing.rs:801-803). Plus the 9 craig-authz ResourceType tokens (crates/craig-authz/src/types.rs:51-219, 60 variants) that CENSUS lacks, because the deny row and the fallback admit lift any of the 60 today (payload_resource_type, event_parsing.rs:533-539): audit_event, background_job, benefit_fact, disposition_follow_up, icpc_home_study, kinship_option, quality_review, screening_decision, subsidy_backpay.

  • craig-authz gains impl From<ResourceType> for AuditResource. It maps each of the 60 variants to the variant of the same token; no token differs. authz_decision has no ResourceType: today it is the deny row’s fallback for a payload token craig-authz does not know, which a typed ResourceType cannot produce. It stays a token because the headerless deny row uses it (D5).

  • Each enum has an Unknown variant, stored as unknown. Only decode produces it (D1, D4).

Tokens are byte-identical to today’s action and resource_type text, with one declared exception. The two keys with a runtime suffix (composition.invalidated.<jurisdiction>, ruleset.changed.<name>) store invalidated.<jurisdiction> and changed.<name> as the action today. They become invalidated and changed. The suffix stays in details. A rule-set name can no longer match a detection substring by accident. The release note says so.

D3. The wire field, and the outbox copy

  • EventEnvelope gains pub audit: Option<AuditMeta>, with #[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = …)]. The field is pub because every other field is and the workspace denies partial_pub_fields; AuditMeta’s own fields are private, so a header is only built through D1. The field stays an `Option for good: decode must keep accepting a headerless message (D5).

  • The deserialiser reads the audit value as JSON and calls AuditMeta::from_wire. It never fails the envelope’s decode (arbitrary_audit_json_never_fails_envelope_decode), which would send the message to the dead-letter queue and lose the audit row.

  • StagedEnvelope (crates/craig-mq/src/outbox.rs:110-123) is the borrowed copy that prepare_staged_envelope (:205) writes to the outbox. It gains audit: Option<&'a AuditMeta> with the same skip rule. Without this the header never leaves the publishing service. At step 8 the field becomes audit: &'a AuditMeta (D4).

  • Envelopes that craig-mq derives from another carry its header unchanged: wrap_for_dlx (crates/craig-mq/src/publisher.rs:484) clones the envelope, and wrap_for_capture (crates/craig-mq/src/park.rs:188) copies input.envelope.audit onto the outer envelope that build_outer (:294-312) makes. The copy sits outside the ParkWrapper, which is all fit_capture (park.rs:260-291) measures. So fit_capture takes the header’s serialised length as a reserve and holds the wrapper to MAX_CAPTURE_BYTES minus that reserve, in its early-return test (:262) as well as in its truncation budget (:283-285). A capture’s published size then keeps the bound it has without a header, MAX_CAPTURE_BYTES plus OUTER_MARGIN_BYTES (a_capture_with_the_largest_header_keeps_the_capture_bound, in park.rs: one wrapper just under the reduced ceiling and one over it). wrap_malformed (:220) has no original and stays headerless. OutboxAuditSink::stage (crates/craig-bootstrap/src/audit_sink.rs:40-43) stages the envelope craig-authz built and needs no change.

D4. How a publisher supplies it

  • Step 0 adds EventEnvelope::audited(source, event_type, payload, audit: AuditMeta) and stage_audited_json_event(tx, source, event_type, payload, audit: AuditMeta) beside EventEnvelope::new and stage_json_event (outbox.rs:283), which keep their signatures until step 8. Step 8 gives new and stage_json_event the audit argument and deletes audited and stage_audited_json_event.

  • domain_event! (crates/craig-mq/src/domain_event.rs:79-108) gains a clause after the routing key, on both arms:

    craig_mq::domain_event! {
        publish_payment_created(payment_id: Uuid, user_id: Uuid),
        "financial.payment_created",
        audit = (Create, Payment, Some(payment_id), Sub(user_id)),
        { "payment_id": payment_id, "user_id": user_id }
    }

    The four parts are: an AuditAction variant name, an AuditResource variant name, an Option<Uuid> expression, and an AuditActor expression. The expansion brings AuditActor and its Sub and System into scope. The first two are bare identifiers so the censuses of § Tests can read them as text. In steps 0 to 7 the clause is optional; step 8 makes it mandatory.

  • Actor forms at a site.

    • A worker’s Uuid: Sub(user_id).

    • An optional worker (publish_person_updated, publish_report_submitted, services/craig-cases/src/events.rs:283, :522): user_id.map_or(AuditActor::System, AuditActor::Sub).

    • Text in the ADR-085 encoding: AuditActor::named(text). That covers the sub of the three craig-authz inputs (crates/craig-authz/src/audit.rs:89, :156, :212, fed by acting_encoding, engine.rs:1748), the fallback admit (services/craig-rules/src/engine.rs:1431), the config reconcile actor (services/craig-rules/src/config_reconcile/apply.rs:62, used at :238 and :279), rules' archived_by (system:retention) and craig-security’s publish_alert_acknowledged text actor.

    • An upload attempt’s creator (services/craig-reporting/src/upload_finalizers.rs:125, services/craig-cases/src/events.rs:581, :692, :735): attempt.creator().map_or(AuditActor::System, |c| AuditActor::named(&c.encoding())).

    • rules.evaluated (services/craig-rules/src/engine.rs:919): System. Its payload (evaluated_event_payload, :1463) names no actor today; evaluated_by (:902) is written to the evaluation row only. The header keeps that, and the site is a row of D8’s allowlist.

  • A site that cannot use the clause builds AuditMeta::new(..) by hand: a resource type chosen at run time (placement.field_written, from its target_table by the mapping of governed_record_type, event_parsing.rs:567-575, else GovernedRecord; rules.authz_fallback_admit and authz.access_denied, through D2’s From), or a deny (.refused().with_roles(..); the suppression flush passes no roles), in crates/craig-authz/src/audit.rs.

  • Staging refuses what a publisher must not send. prepare_staged_envelope returns StageError::Unpublishable(Unpublishable::UnknownAuditToken) for a header whose action or resource is Unknown (step 0), and Unpublishable::MissingAuditHeader for an envelope with no header (step 8). Both variants are new in crates/craig-mq-error/src/lib.rs. This plan refuses at staging and not in the constructor: every publisher passes that one point, and craig-authz’s envelope builders have no error path.

  • Adding the field breaks the two struct-literal envelopes, both test code (services/craig-rules/src/main.rs:586, services/craig-security/src/event_parsing.rs:4544). Step 0 rewrites each to EventEnvelope::new followed by field assignments.

D5. The subscriber

New file services/craig-security/src/audit_columns.rs holds the column derivation and the two counters. handle_inbound_event (lib.rs:777) chooses per envelope.

Header present. The columns come from the header: action and resource_type are the enum tokens; resource_id the header’s; user_id is actor.user_id(); actor_user_sub is the UUID of Sub, else NULL; user_role is the roles joined by a comma, or unknown when empty; success is outcome == Done. service, actor_service and details are unchanged. Every text column still passes through the existing capping and escaping (lib.rs:832-844), so a Named actor is capped and escaped exactly as today’s user_id text. The payload is not consulted. A header with is_degraded() increments audit_degraded_headers_total and logs one WARN.

Header absent, steps 0 to 7. Today’s parser runs, unchanged.

Header absent, from step 8. The row still lands, degraded. Two cases are kept from today’s parser so that evidence is not inverted:

  • authz.access_denied lands action = deny, resource_type = authz_decision, success = false (the meaning of lib.rs:826).

  • any other security.* type lands (system, security) (event_parsing.rs:801-803).

  • everything else lands the raw split of event_type (the rule of generic_event_split), success = true.

In all three, user_id is system, resource_id and actor_user_sub are NULL and user_role is unknown. The payload is not read. The subscriber logs one WARN with the stable message audit event carries no header (capped fields only) and increments audit_headerless_events_total. This path is the legacy fallback the issue asks for. It is permanent: there is no later removal.

Counters. audit_headerless_events_total and audit_degraded_headers_total are OpenTelemetry u64 counters with no labels (the envelope’s text is not trusted), built on first use in a OnceLock on opentelemetry::global::meter("craig-security-audit"). That is the service’s existing mechanism (services/craig-security/src/identity/keys/ring.rs:44, :380-388); the Prometheus bridge serves them on /metrics.

In flight at the step 8 deploy. CRAIG has no production deployment before 1.0, so this is a devstack concern. The step 8 release note says: drain or discard each service’s outbox before upgrading; an admin replay of an outbox row written before its publisher’s step lands a degraded row.

The archive bookkeeping for rules.evaluations_archived (lib.rs:781, record_rules_archive_bookkeeping :876) and the dead-letter disposition map (disposition, lib.rs:1028) are untouched.

D6. The actor is data, as today

The header is written by the publishing service. A compromised publisher can name any actor, exactly as it can put any user_id in a payload today. The header changes where the claim is read, not who is trusted. Nothing in CRAIG authorises on it.

D7. Test call sites

There is no test-only feature and no test-only constructor. Test code that builds an envelope states explicit audit facts through the public API. The reason: the release-artifact gate classifies features per crate ([package.metadata.craig] test-only-features, read by xtask/src/cmd/release_artifact_gate.rs), and a craig-mq test feature enabled through craig-test-lib would enter xtask’s graph and need a third named exception beside craig-auth/test-fixtures and craig-common/test-zones (XTASK_GRAPH_EXCEPTIONS, :77-90, both waiting on #2671).

  • craig-test-lib gains craig_test_lib::audit::plain() → AuditMeta, which returns AuditMeta::new(AuditAction::Update, AuditResource::Case, None, AuditActor::System), for a test that does not care about the audit row. For it, craig-test-lib’s craig-mq dependency (crates/craig-test-lib/Cargo.toml:70) stops being optional and fault-injection becomes ["craig-mq/fault-injection"]. xtask already links craig-mq with no feature (xtask/Cargo.toml:36); cargo xtask release-artifact-gate must stay green at step 0.

  • craig-mq’s in-crate unit tests cannot use it (the crate under test is not the craig-mq that craig-test-lib links). They call AuditMeta::new directly.

  • A test of the headerless path decodes a JSON envelope with no audit key; it needs no constructor.

  • A test that builds another service’s envelope by hand states the header that service’s publisher states. A test that finds its audit row by resource id passes that id to AuditMeta::new.

D8. What guards the header once the string censuses go

The two censuses guard today that no staff act audits as system and that each key names its record. Deleting them must not make the audit trail easier to falsify. A source census replaces them: services/craig-security/src/audit_header_census_tests.rs, declared #[cfg(test)] in lib.rs. It exists from step 0 and reads the crates in MIGRATED (§ Tests); step 8 widens it to the workspace. It scans every .rs under a src directory of services/ and crates/, test files included, except crates/craig-mq. Its four tests:

  1. every_envelope_outside_craig_mq_is_built_with_a_header: no EventEnvelope { .. } struct literal, no write to .audit, and every domain_event!, staging call and envelope constructor carries the audit argument.

  2. no_publisher_names_an_unknown_audit_token: Unknown appears in no audit clause and AuditAction::Unknown / AuditResource::Unknown appear in no file outside craig-mq and craig-security. D4’s staging refusal is the run-time half.

  3. every_system_actor_and_recordless_site_is_allowlisted: each non-test site whose actor expression mentions System, or whose id is None, has a row (file, site, reason) in SYSTEM_OR_RECORDLESS. The table is exhaustive both ways (a site with no row fails; a row with no such site fails) and shrink-only: its length is pinned by SYSTEM_OR_RECORDLESS_CEILING, set at step 8, which a later change may lower and not raise without review of that constant. It carries forward every_payload_actor_key_is_lifted_or_context and every_multi_key_or_sub_payload_is_pinned_to_its_actor (audit_census_tests.rs:963, :1009, CHAIN_PINS).

  4. every_person_event_audits_against_the_person: each site whose routing key starts case.person_ states Person (today audit_census_tests.rs:1277).

In steps 0 to 7 it reuses the lexer of resource_census_tests.rs (mod read, :980) and the source walk of audit_census_tests.rs (scan::workspace_sources, :399), widened to pub(crate). Step 8 moves both into the new file before deleting the old ones.

A header can still name the wrong variable of the right type. No census proves intent; review does, and the allowlist makes each System a stated decision.

Scope and order

Each step is one merge request that is green on its own (Relates to #2314; the last Closes #2314). A step migrates every staging site of its crates, adds the crates to MIGRATED, converts the tests in those crates that build an envelope (D7), and rewrites the hand-built envelopes of its routing keys in craig-security’s suites so they carry a header and exercise the header path. Until its step, a suite’s headerless envelope still passes through the parser. Steps are numbered 0 to 8.

  1. craig-mq. D1, D2, D3 and D7; EventEnvelope::audited, stage_audited_json_event, the optional macro clause and UnknownAuditToken (D4); the header-present path of D5 with audit_degraded_headers_total; craig-authz’s From; D8’s census and the equivalence census with MIGRATED empty; the contract and property tests. The census readers learn the new forms: site_at (resource_census_tests.rs:1161) also reads stage_audited_json_event (key at argument 2, payload 3, header 4) and EventEnvelope::audited (key 1, payload 2, header 3); wrapper_site (:1127) takes a third part that opens audit = as the header and the parts after it as the payload; RawSite gains the header’s tokens. MARKERS and STAGING (audit_census_tests.rs:307, :315) gain stage_audited_json_event. domain_event_wrappers_stage_the_declared_key_source_and_payload gains a wrapper with the clause.

  2. craig-reporting and craig-composition (6 and 2 routing keys).

  3. craig-rules, craig-authz (audit.rs: the deny, suppression-flush, cache-miss and cache-refresh events) and craig-api (admin_replay/act.rs:108). Suites: services/craig-security/tests/authz_deny_audit.rs (:137, :174) builds its two envelopes with craig_authz::build_access_denied_event and build_access_denied_suppressed_event. In audit_emission_evil_tests.rs, Case::deny_storing (:236) and the rules.evaluations_archived case (:847) decode a wire envelope whose audit object carries the same hostile text in the matching header field.

  4. craig-exchange (exchange., icpc., ssa.*).

  5. craig-placement (placement., foster_home.).

  6. craig-financial (financial.*).

  7. craig-cases (case.*, eligibility.evaluated).

  8. craig-security’s own events (security.*). Suites: tests/worker_admin_unit_audit.rs (its assigned and revoked envelopes). The cases that stay headerless on purpose (its catch-all case, and Case::typed, audit_emission_evil_tests.rs:247) build their envelope by decoding JSON (D7). The example examples/inbox_latency_probe states existing tokens and gets no token of its own: probe_envelope (main.rs:188) states AuditMeta::new(AuditAction::System, AuditResource::Security, Some(id), AuditActor::System), with id the payload’s id, and VISIBLE_SQL (subscriber.rs:58) selects resource_type = 'security'. The ids are fresh, so the query stays exact.

  9. Mandatory. new and stage_json_event take the header, the macro clause is required, MissingAuditHeader is refused at staging and StagedEnvelope.audit loses its Option (D4). craig-mq keeps a pub(crate) EventEnvelope::unaudited for build_outer (park.rs:294); captures are published directly and are not staged. D5’s degraded path replaces the parser. The range event_parsing.rs:577-704 (EvaluationsArchivedPayload, RULES_ARCHIVE_PREFIX, validate_evaluations_archived and its helpers) moves, with its tests, to services/craig-security/src/archive_validation.rs. D8’s census widens to the workspace and takes over the lexer. In xtask/src/cmd/audit_write_census.rs, each_event_verdict_names_a_staged_key_with_an_audit_arm (:232) stops reading event_parsing.rs and drops its arm check; it keeps key_is_staged and is renamed each_event_verdict_names_a_staged_key. The arm check is redundant then: a staged key cannot lack a header. Headerless suites change with the path: Case::typed (audit_emission_evil_tests.rs:247) and a_security_catch_all_event_still_lands_system_security find their row by details→>'id', because the headerless row has no resource_id (rows_under, :698); a_revoke_attributed_only_by_revoked_by_falls_to_system pins a parser rule that no longer exists and is replaced by D8’s allowlist test.

services/craig-security/src/events/actor_audit_tests.rs is rewritten leg by leg: a leg that drives a real craig-security producer changes at step 7; a hand-built leg changes at the step of its routing-key prefix (reporting., composition. 1; rules. 2; exchange., icpc., ssa. 3; placement., foster_home. 4; financial. 5; case. 6; security. 7).

Only the last step deletes: event_parsing.rs, event_parsing/audit_census_tests.rs and event_parsing/resource_census_tests.rs, and with them the equivalence census. craig-intake stages no events and has no step.

Out of scope:

  • Typing the 190 payloads as contract structs. The header removes the need for the subscriber to read them; typing them is separate work.

  • details storing a copy of the whole payload. Noted on #2314.

  • Any audit_log schema change. The columns are TEXT with no vocabulary constraint, so there is no migration.

  • Naming the evaluator on rules.evaluated (D4). It would change today’s row; it is a separate issue.

Risks

Risk Class Mitigation, and the test that pins it

StagedEnvelope omits audit, so every header is dropped at the outbox and rows degrade.

silent

a_staged_header_survives_the_outbox_round_trip stages an event, reads the event_outbox row and asserts the audit JSON, field by field.

An action token drifts from today’s text and a detection rule stops counting.

silent

every_audit_action_token_is_pinned holds the full token list of D2 as literals. every_migrated_site_names_the_columns_the_parser_derives compares each site with the parser. the_detection_substrings_match_the_same_actions_as_before pins which tokens each ILIKE pattern of detection_sql.rs matches.

A site names the wrong id or actor variable, or is skipped in its step and keeps the parser’s guess.

silent

The equivalence census compares the clause’s id and actor with the payload key the parser reads for that routing key. every_site_of_a_migrated_crate_carries_a_header fails on a headerless site of a migrated crate. From step 8 omission is a compile error, and staging_refuses_an_envelope_with_no_header pins the run-time half.

With the string censuses gone, a new staff act is staged as System, or with no record, and nobody notices.

silent

D8: every_system_actor_and_recordless_site_is_allowlisted and every_person_event_audits_against_the_person.

A publisher builds a headerless envelope or names Unknown, and its rows degrade for good.

fail-closed

Staging refuses both (D4): staging_refuses_an_unknown_audit_token, staging_refuses_an_envelope_with_no_header. every_envelope_outside_craig_mq_is_built_with_a_header and no_publisher_names_an_unknown_audit_token fail the build first.

A compromised publisher forges a header (D6).

fail-open

Same exposure as today’s payload keys. hostile_header_fields_are_escaped_and_the_row_lands: hostile roles and actor text are capped and escaped; an unknown token stores unknown; the row lands.

One malformed header field discards the rest, so a deny with a hostile sub lands as a headerless success.

fail-open

D1’s per-field decode. a_hostile_actor_on_a_deny_header_keeps_the_refusal: the U+202E sub of audit_emission_evil_tests.rs:264 on an access-denied header still lands success = false, deny and its resource type and id. a_garbled_outcome_on_a_deny_stays_refused. a_bad_header_field_keeps_its_siblings (property).

A headerless message arrives after step 8: its actor and record are lost, and a read it reports is not counted by the bulk-access rule unless its raw split matches.

silent

The row still lands with system and no id, never a guessed actor; a headerless deny stays success = false. a_headerless_event_lands_a_degraded_row_and_counts asserts the columns, the WARN and audit_headerless_events_total; a_headerless_deny_stays_refused and a_headerless_security_event_lands_system_security pin the two kept cases. Ops watches the counter.

An unknown token or a malformed audit value fails the envelope’s decode; the message dead-letters and the row is lost.

fail-closed

D1’s Unknown and D3’s reader. arbitrary_audit_json_never_fails_envelope_decode (property).

A deny row loses success = false or its roles in the move to the header.

silent

deny_event_lands_column_evidence and suppression_flush_lands_resource_without_roles (tests/authz_deny_audit.rs), rebuilt on the real craig-authz builders at step 2 with their assertions unchanged.

A non-UUID actor (service:<name>, config:<layer>@<sha>, system:retention) is dropped to system, or a worker’s UUID lands as text without actor_user_sub.

silent

a_named_actor_lands_verbatim_with_no_sub and a_uuid_shaped_actor_is_always_sub; the equivalence census’s irregular rows state the expected actor text for each named site.

The suffix dropped from the two runtime-suffixed actions (D2) is one an operator filtered on.

silent

Accepted; the release note names both. suffixed_routing_keys_store_the_bare_action pins the new text.

A large header (a long actor text, many roles) is copied beside a parked message and pushes the capture over the publish limit, so the capture fails.

fail-closed

The header is bounded at construction and at decode, and fit_capture budgets for it. an_audit_header_serialises_within_its_bound, a_capture_with_the_largest_header_keeps_the_capture_bound.

Tests

Category Tests, with their file Devstack

Contract (wire)

crates/craig-mq/src/audit_meta.rs: every_audit_action_token_is_pinned, every_audit_resource_token_is_pinned, a_garbled_outcome_on_a_deny_stays_refused. crates/craig-mq/src/envelope.rs: the_envelope_wire_shape_carries_the_audit_header (the exact JSON with a header, and with none: no audit key). crates/craig-authz/src/types.rs: every_authz_resource_type_maps_to_the_same_token (over ResourceType::iter()). crates/craig-mq/src/outbox.rs: staging_refuses_an_unknown_audit_token, staging_refuses_an_envelope_with_no_header (step 8).

no

Contract (outbox)

crates/craig-mq/tests/outbox_concurrent.rs: a_staged_header_survives_the_outbox_round_trip; domain_event_wrappers_stage_the_declared_key_source_and_payload (:342) extended to assert the clause’s header.

yes

Property (proptest)

crates/craig-mq/src/audit_meta.rs: an_audit_header_round_trips (serialise then decode is the identity for any constructor-built AuditMeta); a_uuid_shaped_actor_is_always_sub (named of any UUID spelling is Sub, and decodes as Sub); a_bad_header_field_keeps_its_siblings (replace one field of a valid header with arbitrary JSON: every other field decodes unchanged). crates/craig-mq/src/envelope.rs: arbitrary_audit_json_never_fails_envelope_decode.

no

Regression (equivalence census, steps 0 to 7)

services/craig-security/src/event_parsing/resource_census_tests.rs: every_migrated_site_names_the_columns_the_parser_derives and every_site_of_a_migrated_crate_carries_a_header, over the crates in const MIGRATED. They reuse its reader (wrapper_site :1127, call_site :1149, filed :1668). For each site the reader takes the routing key and the header’s four parts as text. It asserts: action and resource equal parse_event_type(key) (the bare token for D2’s two suffixed keys); the id expression names the payload value under the CENSUS row’s key, or is None for a Nothing row; the actor is Sub(x) where x is the payload value under the key extract_actor picks, or System where it picks none. Any other site (a header built by hand, an optional actor’s map_or, a named actor, a run-time resource) needs a row in a new table HEADER_IRREGULAR beside IRREGULAR (:858): (file, site, expected action, resource, id and actor text, why), exhaustive both ways. Deleted in step 8.

no

Regression (header census, permanent)

services/craig-security/src/audit_header_census_tests.rs: the four tests of D8.

no

Regression (subscriber)

services/craig-security/tests/audit_header.rs (new): a_header_supplies_every_audit_column; a_named_actor_lands_verbatim_with_no_sub; a_degraded_header_lands_and_counts; suffixed_routing_keys_store_the_bare_action; a_headerless_event_keeps_the_parsers_row (steps 0 to 7), replaced in step 8 by a_headerless_event_lands_a_degraded_row_and_counts, a_headerless_deny_stays_refused and a_headerless_security_event_lands_system_security. The counter tests read the series through a Prometheus bridge, as tests/dead_letter_dedup.rs:819-834 does. services/craig-security/src/audit_columns.rs: the_detection_substrings_match_the_same_actions_as_before (no devstack).

yes, except the last

Evil

services/craig-security/src/audit_emission_evil_tests.rs: hostile_header_fields_are_escaped_and_the_row_lands and a_hostile_actor_on_a_deny_header_keeps_the_refusal. Its existing cases stay, moved onto the header at the steps § Scope names: they pin that a hostile envelope field never drops the row.

yes

Every new test gets a red proof. Devstack tests are #[ignore = "requires devstack"] and run in the car. failure_variants_carry_their_v12_dispositions (lib.rs:1359) already pins the dead-letter disposition map and stays.

Delivery

  • Canonical page: docs/modules/ROOT/pages/data-model-security.adoc, § audit_log: where each column comes from (the header), and the degraded row. Updated at step 0 and at step 8.

  • Also updated: shared-crates.adoc (the EventEnvelope and new signatures near line 429, and stage_json_event and domain_event! near lines 480-490), at step 0 and step 8; implementation-guide.adoc (the paragraph on event_parsing::ACTOR_KEYS, and how to stage an event with a header); the domain_event! doc comment.

  • ADR-003 amendment (a dated section in adrs/adr-003-rabbitmq-topology.adoc, at step 0): the envelope carries an audit header; it supersedes the #2211 amendment ("every payload names its actor under a lifted key") once step 8 lands.

  • CHANGELOG entry: the release-note fragment changelog.d/2314.changed.adoc, added at step 0, the step that changes the wire (a new optional envelope field; older consumers ignore it; a UUID actor is stored in canonical spelling). Step 8 adds changelog.d/2314.mandatory.changed.adoc: the header is required to stage, a headerless message audits as system, and the two suffixed actions lose their suffix. Its ops note: drain or discard each outbox before upgrading; an admin replay of a pre-header outbox row lands a degraded row; watch audit_headerless_events_total and audit_degraded_headers_total, which should stay at zero.

  • Close: Closes #2314 on step 8; after merge, one line with the merge SHA. Before Status flips:

    cargo xtask plan-lint --done docs/modules/ROOT/pages/plans/audit-header.adoc \
      --allow-missing services/craig-security/src/event_parsing.rs \
      --allow-missing services/craig-security/src/event_parsing/audit_census_tests.rs \
      --allow-missing services/craig-security/src/event_parsing/resource_census_tests.rs

Review log

Round Vendor Resolved model Verdict

1

Anthropic

vertex-anthropic/claude-fable-5-2 (cold read)

Conventions PASS, implementable FAIL, scaffolding PASS, readable PASS. Folded: non-UUID actors (Named), per-field decode, the consumers and suites the steps missed, the enum contents, the test files.

2

Google

gemini-4-carbon

Conventions FAIL, implementable FAIL, scaffolding PASS, readable PASS. Folded: the headerless path keeps the deny and security.* cases and is classed silent, the census that replaces the deleted ones (D8), no test feature (D7), the commit id removed from Status, the Delivery gaps.

Not put to the maintainer for approval before work starts: by the ruling of 2026-11-15 (#1654) the agent writes the plan, runs the two reviews and builds, and the maintainer reads the plan in its merge request.

Edit this page · latest