Skip to content

Commit cdcba4d

Browse files
samrusaniSami Rusani
andauthored
B2: ship Hermes auto-capture pipeline (#146)
Co-authored-by: Sami Rusani <sr@samirusani>
1 parent d8e8f2a commit cdcba4d

20 files changed

Lines changed: 1608 additions & 76 deletions

ARCHITECTURE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ This keeps Alice continuity semantics centralized while adding Hermes-native aut
3232
Implemented in B1:
3333
- `alice_prefetch_context`
3434

35-
Planned for B2+ (not shipped in B1):
35+
Implemented in B2:
3636
- `alice_capture_candidates`
3737
- `alice_commit_captures`
38+
39+
Planned for B3+:
3840
- `alice_session_flush`
3941
- `alice_review_queue`
4042
- `alice_review_apply`
@@ -46,17 +48,17 @@ Planned for B2+ (not shipped in B1):
4648
3. Alice returns compact continuity payload (summary, relevant memories, open loops, recent decisions/changes, optional resume brief, trust posture).
4749
4. Provider injects payload into Hermes context before model response.
4850

49-
### Flow 2: Post-response Candidate Extraction (planned B2+)
51+
### Flow 2: Post-response Candidate Extraction (implemented in B2)
5052
1. Hermes emits assistant response.
5153
2. Provider sends user/assistant turn pair to `alice_capture_candidates`.
5254
3. Alice returns typed candidates with confidence, trust class, proposed action, evidence snippet, and target object type.
5355

54-
### Flow 3: Post-response Commit (planned B2+)
56+
### Flow 3: Post-response Commit (implemented in B2)
5557
1. In `assist`/`auto`, provider submits candidates to `alice_commit_captures`.
5658
2. Policy gates auto-save vs review queue using type allowlist + confidence threshold.
5759
3. Writes are idempotent across repeated sync attempts.
5860

59-
### Flow 4: Session-End Flush (planned B2+)
61+
### Flow 4: Session-End Flush (planned B3+)
6062
1. On session end, provider calls `alice_session_flush`.
6163
2. Alice performs dedupe merge, contradiction checks, open-loop normalization, summary refresh, and review queue updates.
6264

BUILD_REPORT.md

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,83 @@
11
# BUILD_REPORT
22

33
## sprint objective
4-
Implement Bridge Sprint 1 (`B1`) Hermes provider contract foundation by extending the shipped provider with bridge-phase config normalization, deterministic lifecycle hooks (`prefetch`, `queue_prefetch`, `sync_turn`, `on_session_end`), provider status/readiness validation, and the new automation-oriented MCP prefetch surface `alice_prefetch_context`.
4+
Implement Bridge Sprint 2 (`B2`) auto-capture pipeline on top of the shipped Hermes provider and B1 contract foundation: candidate extraction, commit policy, mode support (`manual`, `assist`, `auto`), review-queue persistence for non-auto-saved items, and deterministic idempotent/no-op behavior.
55

66
## completed work
7-
- Extended (not replaced) the shipped Hermes Alice provider with bridge contract behavior:
8-
- normalized canonical bridge config keys for lifecycle operation
9-
- preserved legacy config-key compatibility
10-
- added provider status/readiness reporting without live network dependency
11-
- added deterministic session-end flush behavior
12-
- added duplicate-write suppression for repeated `sync_turn` and `on_memory_write` callback execution
13-
- fixed capture-queue worker start race and bounded dedupe behavior to avoid suppressing valid later repeats
14-
- Added MCP tool `alice_prefetch_context` with deterministic prefetch text assembled from existing continuity resumption semantics.
15-
- Updated smoke script to emit provider bridge status/lifecycle readiness evidence.
16-
- Updated install and integration docs for bridge contract keys, lifecycle mapping, compatibility keys, and MCP tool surface.
17-
- Added/updated unit and integration coverage for:
18-
- provider config compatibility and invalid-config status
19-
- deterministic lifecycle dedupe/flush behavior
20-
- MCP tool surface stability including `alice_prefetch_context`
21-
- Aligned control-doc truth checks and active control docs to the current bridge-phase baseline.
22-
- Clarified architecture docs so B2+ capture/review surfaces are marked as planned (not shipped in B1).
23-
24-
Legacy compatibility keys preserved:
25-
- `prefetch_limit`
26-
- `max_recent_changes`
27-
- `max_open_loops`
28-
- `include_non_promotable_facts`
29-
- `auto_capture`
30-
- `mirror_memory_writes`
7+
- Added B2 capture pipeline core in Alice continuity:
8+
- implemented `alice_capture_candidates` extraction from user/assistant turn pairs
9+
- implemented `alice_commit_captures` commit policy over extracted candidates
10+
- implemented candidate classes: `decision`, `commitment`, `waiting_for`, `blocker`, `preference`, `correction`, `note`, `no_op`
11+
- candidate payloads now include confidence, trust class, evidence snippet, and proposed action
12+
- Implemented commit policy operating modes:
13+
- `manual`: routes non-`no_op` candidates to review persistence
14+
- `assist`: auto-saves only explicit high-confidence allowlist candidates
15+
- `auto`: auto-saves allowlist candidates at the auto-mode confidence gate
16+
- Implemented policy allowlist and review routing evidence:
17+
- auto-save allowlist categories: `correction`, `preference`, `decision`, `commitment`, `waiting_for`, `blocker`
18+
- review-routed categories by type policy: `note`
19+
- additionally, low-confidence or policy-disallowed candidates route to review under mode gates
20+
- Added idempotent commit behavior using commit fingerprint + candidate fingerprint lookup to prevent duplicate writes on repeated sync attempts.
21+
- Added no-op protection so no-op turns (`no_op`) produce no memory writes.
22+
- Wired new HTTP surfaces:
23+
- `POST /v0/continuity/captures/candidates`
24+
- `POST /v0/continuity/captures/commit`
25+
- Wired new MCP surfaces:
26+
- `alice_capture_candidates`
27+
- `alice_commit_captures`
28+
- preserved existing `alice_capture` and other shipped tools for fallback/manual workflows
29+
- Wired Hermes provider B2 flow in `sync_turn`:
30+
- `assist`/`auto` modes now run candidate extraction then commit
31+
- `manual` mode suppresses automatic `sync_turn` capture
32+
- fallback to legacy `/v0/continuity/captures` path when B2 endpoints are unavailable
33+
- preserved dedupe queue and session-end flush behavior
34+
- Updated sprint-scoped integration docs and smoke script for B2 mode/pipeline truth.
35+
- Updated control-doc truth checker markers from B1-active to B2-active so required verification reflects active sprint state.
3136

3237
## incomplete work
33-
- No code deliverable remains incomplete in B1 scope.
38+
- None in B2 packet scope.
3439

3540
## files changed
3641
- `ARCHITECTURE.md`
3742
- `BUILD_REPORT.md`
3843
- `PRODUCT_BRIEF.md`
3944
- `README.md`
45+
- `REVIEW_REPORT.md`
4046
- `ROADMAP.md`
41-
- `RULES.md`
42-
- `docs/integrations/hermes-memory-provider/plugins/memory/alice/__init__.py`
47+
- `apps/api/src/alicebot_api/continuity_capture.py`
48+
- `apps/api/src/alicebot_api/contracts.py`
49+
- `apps/api/src/alicebot_api/main.py`
4350
- `apps/api/src/alicebot_api/mcp_tools.py`
51+
- `apps/api/src/alicebot_api/store.py`
52+
- `docs/integrations/hermes-memory-provider/plugins/memory/alice/__init__.py`
4453
- `docs/integrations/hermes-memory-provider.md`
4554
- `docs/integrations/mcp.md`
46-
- `scripts/check_control_doc_truth.py`
47-
- `scripts/install_hermes_alice_memory_provider.py`
4855
- `scripts/run_hermes_memory_provider_smoke.py`
49-
- `tests/unit/test_hermes_memory_provider.py`
56+
- `scripts/check_control_doc_truth.py`
57+
- `tests/unit/test_continuity_capture.py`
58+
- `tests/integration/test_continuity_capture_api.py`
5059
- `tests/unit/test_mcp.py`
51-
- `tests/integration/test_mcp_server.py`
60+
- `tests/unit/test_hermes_memory_provider.py`
5261

5362
## tests run
5463
1. `python3 scripts/check_control_doc_truth.py`
5564
- Result: PASS
56-
- Output: `Control-doc truth check: PASS`
65+
- Output summary: verified README, ROADMAP, sprint packet, RULES, current state, archive planning marker
5766
2. `./.venv/bin/python -m pytest tests/unit tests/integration -q`
5867
- Result: PASS
59-
- Output: `1174 passed in 186.28s (0:03:06)`
68+
- Output: `1188 passed in 191.85s (0:03:11)`
6069
3. `./.venv/bin/python scripts/run_hermes_memory_provider_smoke.py`
6170
- Result: PASS
6271
- Output summary:
6372
- single external provider enforcement validated
64-
- provider registered with expected tool set
65-
- `structural.bridge_status.ready=true`
66-
- `structural.bridge_status.errors=[]`
67-
- lifecycle hooks status present for `prefetch`, `queue_prefetch`, `sync_turn`, `on_session_end`
73+
- provider registered with expected tool schemas
74+
- `bridge_contract_version` reported as `bridge_b2`
75+
- bridge status `ready=true`, `errors=[]`
76+
- config includes `bridge_mode=assist`
77+
- lifecycle hooks report `prefetch`, `queue_prefetch`, `sync_turn`, `on_session_end`, and `bridge_mode`
6878

6979
## blockers/issues
7080
- None.
7181

7282
## recommended next step
73-
Proceed with reviewer re-check against B1 acceptance criteria using this updated evidence set.
83+
Run B2 review against acceptance criteria with focus on policy calibration (confidence thresholds) and confirm desired `auto`-mode aggressiveness before promoting B3 review actions.

PRODUCT_BRIEF.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Review-required:
7070
- low-confidence extractions
7171

7272
## Active Sprint Status
73-
Bridge Sprint 1 (`B1`) is now the active execution sprint. It is limited to provider-contract foundation work on top of the shipped Hermes provider surface.
73+
Bridge Sprint 2 (`B2`) is now the active execution sprint. It is limited to the auto-capture pipeline on top of the shipped Hermes provider surface and the `B1` contract foundation.
7474

7575
## Known Gaps To Resolve Before Build
7676
- Candidate scoring rubric and confidence calibration method are not specified.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Phase 11 is complete and shipped:
3939
- `P11-S6` Model Packs Tier 2 + Launch Clarity Assets is shipped
4040
- `P11-R1` Provider Runtime Hardening is shipped
4141
- A bridge phase is now active: Hermes Auto-Capture
42-
- `B1` Hermes Provider Contract Foundation is the active sprint
42+
- `B1` Hermes Provider Contract Foundation is shipped
43+
- `B2` Auto-Capture Pipeline is the active sprint
4344
- Historical planning and control docs: [docs/archive/planning/2026-04-08-context-compaction/README.md](docs/archive/planning/2026-04-08-context-compaction/README.md)
4445

4546
## Why Alice exists

REVIEW_REPORT.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,50 @@
44
PASS
55

66
## criteria met
7-
- The shipped Hermes provider was extended, not replaced (`docs/integrations/hermes-memory-provider/plugins/memory/alice/__init__.py`).
8-
- Bridge config normalization and readiness/status reporting are present, including legacy compatibility reporting.
9-
- Lifecycle hooks `prefetch`, `queue_prefetch`, `sync_turn`, and `on_session_end` are implemented with deterministic behavior, and duplicate callback suppression is covered.
10-
- New MCP tool `alice_prefetch_context` is implemented, wired, and documented (`apps/api/src/alicebot_api/mcp_tools.py`, `docs/integrations/mcp.md`).
11-
- Existing Hermes tools (`alice_recall`, `alice_resumption_brief`, `alice_open_loops`) remain intact.
12-
- B1 required verification commands all pass:
13-
- `python3 scripts/check_control_doc_truth.py` -> PASS
14-
- `./.venv/bin/python -m pytest tests/unit tests/integration -q` -> `1174 passed in 186.28s (0:03:06)`
15-
- `./.venv/bin/python scripts/run_hermes_memory_provider_smoke.py` -> PASS
16-
- No local identifiers were found in changed code/docs after fixes.
7+
- `alice_capture_candidates` is implemented and wired through API and MCP.
8+
- `alice_commit_captures` is implemented and wired through API and MCP.
9+
- Commit operating modes are implemented and exercised: `manual`, `assist`, `auto`.
10+
- Candidate classes required by B2 are present: `decision`, `commitment`, `waiting_for`, `blocker`, `preference`, `correction`, `note`, `no_op`.
11+
- Candidate outputs include confidence, trust class, evidence snippet, and proposed action.
12+
- Auto-save allowlist categories are explicit and implemented: `correction`, `preference`, `decision`, `commitment`, `waiting_for`, `blocker`.
13+
- Review-routed category by type policy is explicit and implemented: `note`.
14+
- Low-confidence/policy-gated candidates route to review persistence rather than auto-save.
15+
- No-op turns produce no memory writes.
16+
- Repeated sync attempts are idempotent via `(sync_fingerprint, candidate_id)` duplicate guard.
17+
- Hermes provider uses the B2 pipeline in `assist`/`auto`, preserves `manual` behavior, and keeps legacy fallback.
18+
- B2 docs/code do not claim `alice_review_queue` or `alice_review_apply` as shipped.
19+
- Previously flagged gaps are fixed:
20+
- explicit `auto` mode tests added
21+
- strict boolean validation for candidate `explicit` added
22+
- `ARCHITECTURE.md` bridge status updated to reflect B2 implementation
23+
- Local identifier hygiene check on changed files passed (no local machine paths/usernames leaked in changed code/docs/reports).
1724

1825
## criteria missed
1926
- None.
2027

2128
## quality issues
22-
- No blocking quality issues found after fixes.
23-
- Minor residual note: callback dedupe now uses a short bounded window; if callback replay behavior changes materially in Hermes, this window may need retuning.
29+
- No blocking quality issues found in B2 scope after fixes.
2430

2531
## regression risks
26-
- Low.
27-
- Primary risk area remains concurrent lifecycle callback timing; current unit coverage and full suite pass reduce risk materially.
32+
- Moderate-low risk in policy calibration (confidence thresholds), but implementation behavior is deterministic and covered by unit/integration tests.
33+
- Idempotency/no-op regressions are specifically covered.
2834

2935
## docs issues
30-
- Previously identified doc/report inconsistencies were corrected:
31-
- architecture now marks B2+ surfaces as planned
32-
- build report file list and command results are aligned with current state
33-
- Local identifier hygiene: PASS.
36+
- None blocking.
37+
- Bridge status documentation is now aligned with B2 implementation state.
3438

3539
## should anything be added to RULES.md?
36-
- Optional improvement: add a permanent rule that sprint reports must match `git diff --name-only` for the sprint-owned file list.
40+
- No required change.
3741

3842
## should anything update ARCHITECTURE.md?
39-
- No further update required for B1 acceptance after current “Implemented in B1” vs “Planned for B2+” separation.
43+
- Completed in this fix pass: B2 surfaces and runtime flow status markers were updated from planned to implemented where applicable.
4044

4145
## recommended next action
42-
1. Approve B1 for merge review.
43-
2. Carry the new capture-queue/dedupe tests forward as required regression coverage for future bridge sprints.
46+
1. Approve B2 for merge.
47+
2. Start B3 review-action scope (`alice_review_queue`, `alice_review_apply`) using B2 persisted review items as baseline fixtures.
48+
49+
## evidence summary
50+
- Required verification commands (re-run):
51+
- `python3 scripts/check_control_doc_truth.py` -> PASS
52+
- `./.venv/bin/python -m pytest tests/unit tests/integration -q` -> `1188 passed in 191.85s (0:03:11)`
53+
- `./.venv/bin/python scripts/run_hermes_memory_provider_smoke.py` -> PASS

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Phase 11 remains baseline truth and is not future scope.
99

1010
## Active Planning Status
11-
- Bridge Sprint 1 (`B1`) is the active execution sprint.
11+
- Bridge Sprint 2 (`B2`) is the active execution sprint.
1212
- The remaining bridge-phase milestones are planned but not yet promoted.
1313

1414
## Bridge Phase: Hermes Auto-Capture (Planned)

0 commit comments

Comments
 (0)