feat(#97): backport event vocabulary extension to triage (cherry-pick of e6d4b8f with §10.5.3 adaptations)#133
Merged
Conversation
Wires the missing decision-status events into the existing JSONL + materializer pipeline so the shipped event vocabulary matches the v0 architecture description (decision_ratified, decision_superseded alongside the existing ingest/bind/link_commit events). Changes: - ledger/adapter.py: add `apply_ratify(decision_id, signoff)` and `apply_supersede(new_id, old_id, ...)` to SurrealDBLedgerAdapter. Both methods are idempotent so the materializer can replay them safely. They wrap the existing inline UPDATE + project + supersedes helpers — no behavioral change for solo mode. - events/team_adapter.py: add wrappers that emit `decision_ratified.completed` and `decision_superseded.completed` events before delegating to the inner adapter. Event payloads carry `canonical_id` (UUIDv5 from description + source_type + source_ref) so cross-author replay can resolve to the peer's local row even though SurrealDB-generated decision ids are per-DB. - events/materializer.py: replay cases for the two new event types. Each looks up the local decision row by canonical_id; warns and skips if not found (out-of-order replay across authors). - handlers/ratify.py: route through `ledger.apply_ratify` instead of inline UPDATE + project_decision_status + update_decision_status. Pre-write idempotency check (early return when state already matches) is unchanged. - handlers/resolve_collision.py: route through `ledger.apply_supersede` for the supersede branch. Edge creation + frozen-signoff merge moves into the adapter so it's reachable from replay. - ledger/queries.py: new `get_canonical_id(client, decision_id)` and `find_decision_by_canonical_id(client, canonical_id)` helpers. Tests: - tests/test_team_event_replay.py (new) — three round-trip tests: ratify, supersede (with edge replay), and ingest regression. Each ingests through team adapter A, then connects a fresh team adapter B pointing at the same JSONL log + a fresh memory:// inner DB and a fresh watermark. Asserts state in B matches what A wrote. - tests/test_preflight_id_plumbing.py — updated the ratify mock to match the new `ledger.apply_ratify` shape. Out of scope (deferred to future PRs): compliance_checked event (Phase 4 uses CHANGEFEED), CHANGEFEED extension to code_subject / subject_identity / binds_to / code_region (schema migration), SHA256 chain (strictly v1). Closes part of #97. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> (cherry picked from commit e6d4b8f) Adaptation: ledger/queries.py — kept only #97's two new helpers (get_canonical_id, find_decision_by_canonical_id); auto-merge had inadvertently bundled the #77 update_decision_level block (PR #107, decision_level classifier, v0.16.0) which is a missing prerequisite on triage and not part of e6d4b8f's actual diff for this file Adaptation: handlers/ratify.py — kept only e6d4b8f's import-list change (drop update_decision_status); dropped the auto-merged preflight_telemetry import which is a missing prerequisite on triage (#65 preflight telemetry capture loop) and not referenced by the cherry-picked body Skip: tests/test_preflight_id_plumbing.py — kept triage's prior deletion of this file; e6d4b8f's update to its ratify mock is moot here
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Merged
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backports the v0.18.0 event vocabulary extension (`decision_ratified` + `decision_superseded` emit/replay) from `dev` (`e6d4b8f`) to `triage-from-dev`.
This is the first cherry-pick onto `triage-from-dev` under the new DEV_CYCLE.md §10.5 protocol. It exercises §10.5.3's adaptation clause that landed alongside it.
Cherry-pick provenance
`(cherry picked from commit e6d4b8f)` — recorded by `git cherry-pick -x` per §10.5.3.
Adaptations (per §10.5.3)
Three hunks required adaptation. All annotated in the commit message and (where load-bearing) in the code itself with `# triage-adapt:` comments:
`ledger/queries.py` — auto-merge had bundled the Tooling: bulk-classify utility for legacy
decision_level = NULLrows #77 `update_decision_level` block (PR feat: decision_level classifier + MCP primitives + CLI (#77) #107, decision_level classifier, v0.16.0) into the resolution at the same insertion point as RFC: append-only event-sourced ledger with rebuildable projection #97's two new helpers. Dropped the Tooling: bulk-classify utility for legacydecision_level = NULLrows #77 block (missing prerequisite on triage; not part of e6d4b8f's actual diff). Kept only RFC: append-only event-sourced ledger with rebuildable projection #97's intended additions: `get_canonical_id` and `find_decision_by_canonical_id`.`handlers/ratify.py` — auto-merge had bundled an import of `preflight_telemetry` (Preflight: telemetry capture loop for real-world failure feedback #65 preflight telemetry capture loop) into the resolution. Dropped the import (missing prerequisite; not referenced by the cherry-picked body). Kept the intended import-list change (drop `update_decision_status`).
`tests/test_preflight_id_plumbing.py` — file is deleted on triage. e6d4b8f updates the ratify mock in this file; that update is moot here. Kept triage's prior deletion via `git rm`.
`handlers/resolve_collision.py`'s body conflict was resolved by taking e6d4b8f's content verbatim — not an adaptation, just selecting the cherry-picked side. The HEAD inline block differed from dev's pre-#97 inline block by formatting only.
What this lands on triage
Test plan
Risk assessment
L2 (modifies existing handler APIs — but routes through existing adapter pattern; semantics identical from caller POV per §10.5.3 adaptation clause condition (1)).
DEV_CYCLE references
Linked issues
Refs #97 (RFC stays open per convention)
🤖 Generated with Claude Code