AUDIT-WP-0009 T04/T06/T07 — heartbeats, reconciliation, and a home for findings
The detection half audit-core argued up to a MUST and then could not support. Two registered sources were waiting on it. T04, heartbeats. A heartbeat is an ordinary event — same envelope, same append-only custody, same chain, no special table. Deliberate: a heartbeat stored outside the chain would be the one record here that could be back-dated. Declared per class rather than per source, because a per-source heartbeat from a mixed-volume emitter is satisfied by its chattiest class and says nothing about the quiet, security-relevant one, which is the only reason heartbeats exist. Not the §17 cadence schema T05 waits on: cadence describes expected rate, this says how often a source promises to say "nothing to report" for a class that may legitimately be silent. no_heartbeat_since_registration is its own finding kind rather than a skip — it is the case most likely to be a broken integration and the one a naive "compare against last seen" implementation silently drops. Grace widens the window so one late run does not flap; it never removes a finding. T06, reconciliation. Counts, never payloads. The awkward part is that every registered sender holds may_read: false, which taken literally makes the §9.6 reconciliation obligation undischargeable by every source actually registered. Resolved by observing that a source asking how many of its own events we hold is not reading the archive — it learns nothing it did not itself emit. So the surface is scoped to the caller's own sources and tenants and returns no payloads; anything wider stays behind may_read and full tenant scope. Another source's counts return 403 rather than an empty count, because a zero would read as "we hold none of yours" — a false answer to a question about completeness. No default window, since a count whose bounds the caller did not choose is not comparable to anything the caller computed. T07, the findings surface. /v1/stream-findings, following the dead-letter and secret-finding conventions: may_read plus full tenant scope, since findings span every sender and carry no tenant key to filter on. The bound is on every response rather than in a document nobody opens beside it. A missing heartbeat is not proof of suppression, and agreement on counts proves neither completeness nor that any event occurred. Both controls cover loss, outage, drain failure and accident; neither covers a source lying about itself, and where the emitter is compromised both agree with it. Closing that needs an observer independent of the emitter, which §16 put outside our scope. The scope overlay may shorten a heartbeat interval or add a class, never lengthen or remove one — same asymmetry as evidence_kind, and for the same reason: a ConfigMap refresh must not widen the window in which a suppressed class goes unnoticed without anyone deciding to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nb7Q6ZmXppNDkTWytfYqfv Assistant: claude-code Assistant-Model: opus Assistant-Process: 2069992@bnt-lap001 Assistant-Session: 167dd7f8-2a25-4be1-aa46-3b6f1a5f94c6
This commit is contained in:
parent
de9e3abe5f
commit
b098fb12ca
7 changed files with 780 additions and 1 deletions
|
|
@ -68,6 +68,20 @@ class SenderIdentity:
|
|||
# §9.6 requires the trade be declared where the trail is documented, so it
|
||||
# travels with the identity rather than living only in prose.
|
||||
completeness_trade: str | None = None
|
||||
# §9.6 heartbeat declaration (AUDIT-WP-0009-T04): event class -> the
|
||||
# longest gap, in seconds, that is not yet a finding.
|
||||
#
|
||||
# This is deliberately NOT the §17 emission-cadence schema that T05 waits
|
||||
# on. Cadence describes a stream's expected *rate* and belongs to Taxonomy;
|
||||
# this is a registration property saying how often a source promises to say
|
||||
# "nothing to report" for a class that may legitimately be silent. The two
|
||||
# are complementary and audit-core is not inventing a competing rate shape.
|
||||
#
|
||||
# Keyed per class, not per source, on purpose. A per-source heartbeat from
|
||||
# a mixed-volume emitter is satisfied by its chattiest class and says
|
||||
# nothing about the quiet, security-relevant one — which is the only case
|
||||
# heartbeats exist for.
|
||||
heartbeat_classes: tuple[tuple[str, int], ...] = ()
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if not self.name:
|
||||
|
|
@ -102,6 +116,17 @@ class SenderIdentity:
|
|||
"completeness_trade — §9.6 requires emission atomicity of it"
|
||||
)
|
||||
|
||||
for action, interval in self.heartbeat_classes:
|
||||
if not action or not str(action).strip():
|
||||
raise ValueError(
|
||||
f"sender {self.name!r}: a heartbeat class needs an event class"
|
||||
)
|
||||
if not isinstance(interval, int) or isinstance(interval, bool) or interval <= 0:
|
||||
raise ValueError(
|
||||
f"sender {self.name!r}: heartbeat interval for {action!r} must "
|
||||
f"be a positive number of seconds, got {interval!r}"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_load_bearing(self) -> bool:
|
||||
return self.evidence_kind == EVIDENCE_LOAD_BEARING
|
||||
|
|
@ -118,6 +143,7 @@ class SenderIdentity:
|
|||
"evidence_kind": self.evidence_kind,
|
||||
"completeness_claimed": False,
|
||||
"completeness_trade": self.completeness_trade,
|
||||
"heartbeat_classes": dict(self.heartbeat_classes),
|
||||
"detection_surface": None,
|
||||
}
|
||||
|
||||
|
|
@ -288,6 +314,7 @@ def _apply_scope_overlay(
|
|||
if "completeness_trade" in extra
|
||||
else identity.completeness_trade
|
||||
),
|
||||
heartbeat_classes=_overlay_heartbeats(identity, extra),
|
||||
)
|
||||
)
|
||||
return merged
|
||||
|
|
@ -313,6 +340,36 @@ def _overlay_evidence_kind(identity: SenderIdentity, extra: dict[str, Any]) -> s
|
|||
return declared
|
||||
|
||||
|
||||
def _overlay_heartbeats(
|
||||
identity: SenderIdentity, extra: dict[str, Any]
|
||||
) -> tuple[tuple[str, int], ...]:
|
||||
"""The overlay may add a heartbeat class or shorten an interval, never
|
||||
lengthen or remove one.
|
||||
|
||||
Same asymmetry as ``evidence_kind`` and for the same reason: a ConfigMap
|
||||
refresh must not be able to widen the window in which a suppressed class
|
||||
goes unnoticed, or drop the obligation entirely, without anyone deciding
|
||||
to. Tightening detection is safe in the direction a mistake would take it.
|
||||
"""
|
||||
if "heartbeat_classes" not in extra:
|
||||
return identity.heartbeat_classes
|
||||
declared = dict(identity.heartbeat_classes)
|
||||
proposed = dict(_heartbeat_classes(extra["heartbeat_classes"]))
|
||||
for action, interval in declared.items():
|
||||
if action not in proposed:
|
||||
raise ValueError(
|
||||
f"sender {identity.name!r}: the scope overlay may not remove "
|
||||
f"heartbeat class {action!r}"
|
||||
)
|
||||
if proposed[action] > interval:
|
||||
raise ValueError(
|
||||
f"sender {identity.name!r}: the scope overlay may not lengthen "
|
||||
f"the heartbeat interval for {action!r} "
|
||||
f"({interval}s -> {proposed[action]}s)"
|
||||
)
|
||||
return tuple(sorted(proposed.items()))
|
||||
|
||||
|
||||
def _parse_identities(raw: str) -> list[SenderIdentity]:
|
||||
try:
|
||||
entries = json.loads(raw)
|
||||
|
|
@ -338,9 +395,18 @@ def _identity_from(entry: Any) -> SenderIdentity:
|
|||
expires_at=_parse_expiry(entry.get("expires_at")),
|
||||
evidence_kind=str(entry.get("evidence_kind", EVIDENCE_ATTRIBUTIVE)),
|
||||
completeness_trade=_clean_trade(entry.get("completeness_trade")),
|
||||
heartbeat_classes=_heartbeat_classes(entry.get("heartbeat_classes")),
|
||||
)
|
||||
|
||||
|
||||
def _heartbeat_classes(value: Any) -> tuple[tuple[str, int], ...]:
|
||||
if not value:
|
||||
return ()
|
||||
if not isinstance(value, dict):
|
||||
raise ValueError("heartbeat_classes must be an object of class -> seconds")
|
||||
return tuple(sorted((str(k), v) for k, v in value.items()))
|
||||
|
||||
|
||||
def _clean_trade(value: Any) -> str | None:
|
||||
if value in (None, ""):
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue