Skip to content

aggregator: throat healthHook extension — full C3 incident record in the alerts ledger (#12602) - #12646

Merged
dezren39 merged 1 commit into
mainfrom
archer-lane-v/12602-aggregator-healthhook
Nov 22, 2026
Merged

dezren39 merged 1 commit into
mainfrom
archer-lane-v/12602-aggregator-healthhook

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Implements #12602, the aggregator half of the #12599 decision-b pair (the runner half is #12603, which lands after this — its ordering constraint).

Gate: PR #12226 merged first (fd83eaa2fb), re-verified at its head before merging: claimant 240 OK, health-hooks 22 passed, aggregator health-hook bun tests 9 pass, typecheck exit 0. The #12226 AuditEvent append is untouched and composes in the same stackHealth intake branch.

What lands

  • Intake extension — POST /api/alerts accepts a healthHook extension carrying the full C3 incident record, gated to source: "health-hook". Validated by a dedicated validator in the validateStackHealth house style (src/health-hook.ts): strict scalar validation, every error names its field, malformed = 400 before anything is stored. evidence is validated as an object only — its members are probe-defined and evolve (the runner already emits a confirmFailure member the design predates). Store failure stays logged-and-never-fails-the-post, per the existing discipline.
  • Mutual exclusion, amended for exactly one pairing — healthHook may co-ride with stackHealth (health-hook source only); healthHook + needsDrew/decisionSet is a 400, and all pre-existing pairings stay exclusive with their original error.
  • Ledger storage — the named slot — the incident events' detail: the down record on the opened event (merged into postIncident's opened detail, existing members preserved), the recovery record on the closed event (via closeOpenIncidentByKey/closeIncident). No new tables.
  • Read projection — new per-incident read GET /api/alerts/:id returns the incident plus its full event history (C6's detail path); records also ride the existing /api/alerts.json events projection. No secret material exists in these records by design.
  • Design amendment (same PR, per the issue) — the C3 note now states the two-store contract (ledger = record of detail; stream = audit index; hook-local JSONL = dedup/lineage working state, not a consumer surface), the authHealth.status vocabulary resolved|missing|unknown with unknown defined, and the title template's <target> as the display name.

Tests (oracle: the C3 design record shape / the Slice D harness record the runner actually emits)

  • test/health-hook.test.ts (new, 8 tests): validator accept/normalize + per-field rejects; a store round-trip drill — down + recovery pair reads back from listIncidentEvents with incidentId/recoveryOf lineage and full evidence intact; extension-less posts keep byte-identical opened/closed details.
  • Existing suites: test/alerts.test.ts 55/55; health-hook audit-event + dispatch suites pass; bun run typecheck exit 0.
  • Full aggregator suite: 2875 pass / 14 fail — the identical 14 failures occur on pristine main in this environment (boot/source-gate timing suites; verified by running both and diffing the failing-file sets). No new failures.

Closes #12602


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…the alerts ledger (#12602)

#12599 decision b: the alerts ledger is the C3 incident record of
detail; the events stream stays the thin audit index.

- Intake: POST /api/alerts accepts a `healthHook` extension carrying
  the full incident record (C3 design shape), health-hook source
  only, validated by a dedicated validator in the validateStackHealth
  house style (src/health-hook.ts) — malformed = 400 naming the
  field, before anything is stored. The mutual-exclusion rule is
  amended for exactly one pairing: healthHook may co-ride with
  stackHealth (health-hook source only); every other pairing stays
  exclusive.
- Storage (the named ledger slot): the record rides the incident
  events — the down record on the `opened` event's `detail` (merged
  into postIncident's opened detail), the recovery record on the
  `closed` event's `detail` (via closeOpenIncidentByKey /
  closeIncident). No new tables.
- Read projection: new per-incident read GET /api/alerts/:id returns
  the incident plus its full event history (C6's detail path); the
  records also ride the existing /api/alerts.json events projection.
  The #12226 AuditEvent append is untouched and composes in the same
  stackHealth branch.
- Design amendment (same PR): doc note states the two-store
  contract, the authHealth.status vocabulary resolved|missing|
  unknown (unknown = the lookup itself could not run; reason in
  detail), and the title template's <target> as the display name.

Tests (oracle: the C3 design record shape / Slice D harness record):
test/health-hook.test.ts — validator accept/reject per field, and a
store round-trip drill (down + recovery pair reads back from
listIncidentEvents with incidentId/recoveryOf lineage and full
evidence intact; extension-less posts byte-identical details).
Existing alerts suite 55/55 and the health-hook suites pass;
typecheck clean.

Closes #12602
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 18:05
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a13a4484-dfe9-460f-897b-ffb6896e6f19
Commits

Reviewing files that changed from the base of the PR and between 24d33a5 and 7fe455e.

Files selected for processing: 5

  • doc/2026-11-20T00-46-00Z_design_c3-health-hooks/note.md
  • pm-stack/aggregator/src/alerts.ts
  • pm-stack/aggregator/src/health-hook.ts
  • pm-stack/aggregator/src/server.ts
  • pm-stack/aggregator/test/health-hook.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T18:06:56.001391Z 7fe455e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 167b8b1 into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the archer-lane-v/12602-aggregator-healthhook branch November 22, 2026 18:06
dezren39 added a commit that referenced this pull request Nov 22, 2026
…extension (#12603)

Implements #12603, the runner half of the #12599 decision-b pair,
on top of the aggregator half (#12602, PR #12646 — landed first per
the ordering constraint: the intake had to accept the extension
before the runner could post it without silent drops).

One record shape: the incident record is built once in main, in
the full design shape including its stackHealth member (serviceId /
name / state / since / detail). post_to_throat reuses
record["stackHealth"] instead of rebuilding it, and posts the full
record as the healthHook extension alongside the existing envelope
members — so the JSONL record, the POST body, and the ledger-bound
extension are the same shape. Failure discipline unchanged:
best-effort inside the sequence deadline; a failed post never
changes the verdict or the JSONL record (the recoveryDelivered
re-post loop is untouched).

Recovery title: "Health hook: <display name> recovered" for a
recovery (up with recoveryOf set); down/transient/plain-up titles
unchanged. Dedupe is by key, not title, so the wording cannot
split an incident.

Tests (test_run.py, 25 passed — 22 pre-existing + 3 new; oracle:
the #12599 record shape): the JSONL record and the record handed
to post_to_throat are identical and carry the built-once
stackHealth member; the posted body carries the full record as
healthHook with a sentinel proving stackHealth reuse-not-rebuild;
a recovery's title reads "recovered" with recoveryOf lineage and
an "up" stackHealth member. End-to-end seam verified against the
merged #12602 intake: runner-generated down + recovery bodies
validate, store, and read back from the ledger with lineage and
evidence intact.

Closes #12603
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C3 aggregator: throat healthHook extension — store the full incident record in the alerts ledger + read projection (#12599 decision b)

1 participant