Repository navigation
feat(insights): implement work-effect reconciliation adapters - #3199
Conversation
Problem: reconcile_work_effects (polylogue/insights/work_reconciliation.py)
was dead code with zero callers and no observation producers -- the
work-evidence graph's claim nodes (built by claude_workflow_materializer)
had no path to independently observed git/GitHub/Beads effects, so an
agent's structured result could never be corroborated or contradicted by
real repository state.
What changed:
- polylogue/insights/work_effects.py: real, read-only effect-observation
adapters -- GitCommitEffectAdapter (subprocess `git log`),
BeadsIssueEffectAdapter (parses a `.beads/interactions.jsonl`-shaped
ledger via the existing looks_like_beads_interaction validator), and a
typed GitHubPullRequestEffectAdapter stub that raises
EffectAdapterUnavailableError explicitly (no network/gh CLI access
assumed) instead of silently returning zero PRs. Judgment derivation
(derive_direct_identifier_judgments) links a claim to an effect only
when their text shares an exact work-item id token -- time/file overlap
is never treated as a match, so an unmatched claim stays explicitly
unevaluated rather than being inferred from session presence.
- polylogue/operations/work_effect_reconciliation.py: the production
read-modify-write consumer -- loads a stored WorkEvidenceGraph, runs the
adapters, reconciles, and (with apply=True) persists back through the
existing SessionRepository.replace_work_evidence_graph route.
- polylogue/cli/commands/reconcile_work_effects.py: `polylogue ops
reconcile-work-effects` (dry-run by default; --yes persists), the real
production caller.
- polylogue/core/refs.py, insights/work_evidence.py: added the
`beads-issue` ObjectRef kind as a valid "effect" node identity, distinct
from `github-issue`.
- insights/work_reconciliation.py: widened ObservedRepositoryEffect/
ReconciliationJudgment.evidence_ref from EvidenceRef to the existing
WorkEvidenceSourceRef union, so non-archived evidence (a commit, a
ledger line) can cite an `artifact:`-kind ObjectRef the same way raw
source-tier revisions already do elsewhere in this graph.
- storage/sqlite/queries/work_evidence.py + repository mixin: added
get_work_evidence_graph, the missing full-graph read the reconciler
needs (only one-hop traverse_work_evidence and full-replace existed).
Deferred (acceptance-criteria honesty): AC 7 of polylogue-1vpm.6.2 asks
that "existing correlate_session/provider-specific effect paths become
projections or retire". insights/session_commit.py's file/time-overlap
correlation view has its own CLI surface, API method, and test suite; a
safe retirement/projection is a separate, sizeable migration and is not
attempted here. The GitHub PR effect adapter is a typed, pluggable stub
only -- a real gh/GitHub-API-backed implementation is future work.
Verification:
- devtools test tests/unit/insights/test_work_effects.py
tests/unit/insights/test_work_evidence.py
tests/unit/insights/test_work_reconciliation.py
tests/unit/operations/test_work_effect_reconciliation.py
tests/unit/cli/test_reconcile_work_effects_command.py
tests/unit/sources/parsers/test_beads.py -> 28 passed
- devtools verify --quick -> exit 0 (format, lint, mypy --strict,
render all --check, topology, docs-coverage all green)
Ref polylogue-1vpm.6.2
Unblocks polylogue-z9gh.7's 2026-07-20 bar item 2 ("polylogue-1vpm.6.2
implemented for real"): reconcile_work_effects now has concrete git/Beads
adapters, a real production caller, and fixture-driven anti-vacuity tests
proving claim/effect/evaluated stay three distinct facts.
Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (16)
✨ 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 |
|
CodeRabbit hit its review rate limit (its green check is the limit notice, not a review). Coordinator review stand-in per campaign protocol: read the adapter module, ops entry point, CLI command, and test files. Verified: GitCommitEffectAdapter is read-only list-args subprocess (no shell=True); BeadsIssueEffectAdapter reuses the existing looks_like_beads_interaction validator; the GitHub stub fails loudly (EffectAdapterUnavailableError) instead of returning empty; judgment derivation is exact-id-token only (no time/file proximity), unmatched claims stay unevaluated; CLI is dry-run by default with --yes to persist. AC 7 deferral (session_commit retirement) is stated in the body, not silently dropped. Local verification: 28 tests across 6 files, devtools verify --quick green. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c81d3a6c8
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if apply: | ||
| await repository.replace_work_evidence_graph(reconciled) |
There was a problem hiding this comment.
Route applied reconciliation through the daemon
When --yes is used, the CLI opens the active index database and reaches this write directly, violating AGENTS.md's requirement that “the daemon owns all writes.” This is a concrete lost-update path: the daemon's polylogue/insights/claude_workflow_materializer.py::_replace_graph_family independently deletes and reinserts every claude-workflow:* graph, so concurrent materialization can be overwritten by this stale read-modify-write, while any later materialization discards the newly persisted effect nodes and edges. Submit this mutation through the daemon/coordinator and ensure materialization preserves or reapplies reconciled effects.
Useful? React with 👍 / 👎.
…eceipts; add 6qjc judgment-automation bead
…ry (#3328) ## Summary Adds `devtools/mandate_continuity_replay.py` (`devtools workspace mandate-continuity-replay`), the z9gh.7-owned artifact its own 2026-07-20 notes named as the missing residual: a replay runner wiring polylogue-t8t's continuity scenarios, polylogue-1vpm.6.2's work-evidence effect-reconciliation adapters, and polylogue-z9gh.3's query-discovery catalog into one privacy-safe JSON artifact. ## Problem `bd show polylogue-z9gh.7` (P0 terminal mandate gate, "Prove mandate recovery through real agent continuity replays") records this exact gap in its 2026-07-20 "CONCRETE BAR" note: > a z9gh.7-owned replay runner wiring t8t scenarios + work-evidence graph + discovery into one privacy-safe live-scale artifact (size M, does not exist) Each dependency is independently proven but nothing combined them: - polylogue-t8t (closed) proves the 7 continuity scenarios + parallel-Claude incident variant in isolation via `devtools/continuity_replay.py`. - polylogue-1vpm.6.2 (closed, PR #3199) supplies real `GitCommitEffectAdapter`/`BeadsIssueEffectAdapter`/`GitHubPullRequestEffectAdapter` in `polylogue/insights/work_effects.py`, but nothing outside its own tests exercises them at repository scale. - polylogue-z9gh.3 (in progress) supplies `QUERY_DISCOVERY_EXAMPLES`, but nothing cross-checks it against what the continuity scenarios actually execute. (The bead's note also names `polylogue-1vpm.6.2`'s effect adapters as "confirmed DEAD CODE" — that note predates 1vpm.6.2's own closure later the same day; source review here confirms `reconcile_graph_repository_effects` is real, wired production code with a CLI (`polylogue/cli/commands/reconcile_work_effects.py`). That gap is closed already and untouched by this PR.) ## Solution `devtools/mandate_continuity_replay.py`: - **Continuity lane**: calls `devtools.continuity_replay.replay_archive` unmodified against a freshly seeded synthetic corpus (default, CI-safe) or an authorized `--archive-root` (live-scale lane). - **Discovery lane** (`check_discovery_coverage`): for every `query`-tool route step any continuity scenario issues, proves a matching positive example exists in `QUERY_DISCOVERY_EXAMPLES` with the same unit-source/route shape — i.e. a cold model relying on the published catalog alone could have formulated that plan family. - **Work-evidence lane** (`build_repository_claim_graph` + `run_work_evidence_effect_proof`): builds independent claim nodes from this repository's own `.beads/interactions.jsonl` "issue closed" transitions, then reconciles them through the real `GitCommitEffectAdapter`/`BeadsIssueEffectAdapter`/`GitHubPullRequestEffectAdapter` against this repo's actual git history — real, full-repo scale, privacy-safe because both are already public/committed project artifacts, not private chat content. The GitHub adapter's explicit `EffectAdapterUnavailableError` is recorded as the honest "cites PR effects with uncertainty" AC clause, not a silent omission. - **`redact_report`**: recursively hashes evidence-prose fields (`label`/`claim_text`/`reason`), keeping refs/ids/counts — a no-op proof on the synthetic lane, load-bearing on an authorized live-archive run. - **AC matrix** (`build_ac_matrix`): maps the run onto z9gh.7's own 7 acceptance-criteria items, each explicitly `satisfied`/`deferred`/`blocking` with a cited reason. Registered in `devtools/command_catalog.py`; regenerated `docs/devtools.md` + `docs/plans/topology-target.yaml` (new module needs the topology projection per repo convention). **Real pre-existing bug found and fixed along the way**: t8t's own `self-inspection` oracle (`tests/data/continuity/catalog.json`) still declared 11 read-views; production `polylogue/cli/read_view_registry.py` has shipped 12 (the `hooks` view, added after #3265) for a while. `tests/integration/test_continuity_replay.py` was already failing on current master before this PR for the same reason — confirmed by running it unmodified prior to the fix. Fixed the fixture fact (11→12, added `hooks` to the id list); not otherwise in scope for this PR. ## What this PR does NOT close (stated honestly, matching the artifact's own AC matrix) - **AC2** (the live 2026-07-15 incident replay finding the real coordinator `cf0c6474-...`/run `wf_54d4fb2e-841` in a promoted live archive) needs an authorized live archive this sandbox does not have. The artifact proves the identical mechanism against t8t's synthetic 91/38/129/4 census and reports this item `deferred`, with an explicit note on how to re-run it live (`--archive-root`). - **AC6** (mutation checks) is already t8t's own proven scope (`tests/infra/continuity_mutations.py`, 6 named families); this artifact cites that suite rather than duplicating it. - polylogue-1vpm.6.2's own residual (`session_commit` retirement, named in its own PR #3199 body) is untouched — out of scope here. ## Verification - `devtools test tests/unit/devtools/test_mandate_continuity_replay.py tests/integration/test_mandate_continuity_replay.py` → 15 passed - `devtools test tests/integration/test_continuity_replay.py` → 12 passed (confirms the read-view-count fixture fix; was 11 passed/1 failed before) - `mypy --strict` on all touched files → Success: no issues found - `ruff format`/`ruff check` on all touched files → All checks passed - `devtools render all --check` → exit 0 - `devtools verify --quick` → exit 0 (ran automatically on push via pre-push hook) Ref polylogue-z9gh.7 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
…ence through AppEnv (#3356) ## Summary Routes `reconcile_work_effects_command` and `materialize_incident_evidence_command` through the standard `AppEnv.repository` / `@click.pass_obj` context-object pattern instead of constructing `SessionRepository(db_path=active_index_db_path())` directly, removing a tracked architecture-boundary allow-list exception. ## Problem Both commands (from PR #3199/#3327 and PR #3336) imported `SessionRepository` directly from `polylogue.storage.repository` and constructed it manually instead of going through `AppEnv.repository` — the pattern every other CLI command uses. `tests/unit/architecture/test_surface_storage_boundary.py` had to special-case both files in its `ALLOWED` set rather than fix the violation (tracked by polylogue-a7uk). ## Solution - Added `@click.pass_obj` to both commands, with `env: AppEnv` as the first parameter. - Replaced the manual `async with SessionRepository(db_path=active_index_db_path()) as repository:` construction with `env.repository`, which resolves to the same cached repository via `RuntimeServices.get_repository()` (same underlying archive path). - Removed the now-unneeded allow-list entries in `test_surface_storage_boundary.py`. - Updated both commands' CLI tests (`test_reconcile_work_effects_command.py`, `test_materialize_incident_evidence_command.py`) to invoke through the real `cli` root group (`ops reconcile-work-effects` / `ops materialize-incident-evidence`) instead of the bare leaf command, matching `test_excise.py`'s existing pattern — this is what lets the root callback build a properly runtime-resolved `AppEnv` (an ad hoc `AppEnv()` constructed directly in a test has no resolved database path). ## Verification - `devtools test tests/unit/cli/test_reconcile_work_effects_command.py tests/unit/cli/test_materialize_incident_evidence_command.py tests/unit/architecture/test_surface_storage_boundary.py` → 162 passed - `mypy --strict polylogue/cli/commands/reconcile_work_effects.py polylogue/cli/commands/materialize_incident_evidence.py` → Success: no issues found in 2 source files - `ruff check` / `ruff format --check` on all changed files → clean - `devtools render all --check` → no "out of sync" surfaces - Pre-push hook (`devtools verify --quick`) passed on push Ref polylogue-a7uk Co-authored-by: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Implements the work-effect adapters that make
reconcile_work_effectsreal: git commit and Beads issue-history observation adapters, a typed (honestly-degrading) GitHub PR stub, a conservative direct-identifier judgment matcher, and a production read-modify-write CLI consumer (polylogue ops reconcile-work-effects).Problem
reconcile_work_effects(polylogue/insights/work_reconciliation.py) was dead code: zero callers, no observation producers anywhere in the codebase. The work-evidence graph's claim nodes (built in production byclaude_workflow_materializer.py) had no path to independently observed git/GitHub/Beads effects, so an agent's structured result could never be corroborated or contradicted by real repository state — exactly the gappolylogue-z9gh.7's 2026-07-20 bar named as "the one substantive implementation gap" blocking its mandate-recovery replay gate.Solution
polylogue/insights/work_effects.py— real, read-only effect-observation adapters:GitCommitEffectAdapter: readsgit logvia subprocess against a caller-supplied repo path (fixture repo in tests; whatever checkout a session's repo identity resolves to in production — this module does not itself discover that path).BeadsIssueEffectAdapter: parses a.beads/interactions.jsonl-shaped ledger directly, reusing the existinglooks_like_beads_interactionvalidator fromsources/parsers/beads.py's own detection logic.GitHubPullRequestEffectAdapter: a typed, pluggable stub. PR lifecycle/review/merge evidence needs live network/ghCLI access this module does not assume is safe or available (auth, rate limits, no egress in cloud/CI lanes);collect()always raisesEffectAdapterUnavailableError— an honest "not implemented" rather than a silent empty result indistinguishable from "no PRs found".derive_direct_identifier_judgments: links a claim to an effect only when their text shares an exact work-item id token (e.g. a Beads id likepolylogue-1vpm.6.2). Time or file proximity is never treated as a match — that heuristic already exists as a candidate-only view ininsights/session_commit.py. A claim naming no id, or whose id has no matching effect, is left out of the result entirely, so it stays explicitly unevaluated."supported": a direct id match proves an independent effect exists for that work item, not that its outcome semantically agrees with the claim's prose. Distinguishing partial/contradicted/superseded needs field-level effect semantics that are explicitly out of scope for identifier matching alone.polylogue/operations/work_effect_reconciliation.py— the production read-modify-write consumer: loads a storedWorkEvidenceGraphvia a newSessionRepository.get_work_evidence_graph(the missing full-graph read; only one-hoptraverse_work_evidenceand full-replace existed before), runs the adapters, reconciles, and — withapply=True— persists back through the existingreplace_work_evidence_graphroute already proven bytest_work_evidence.py's round-trip test.polylogue/cli/commands/reconcile_work_effects.py—polylogue ops reconcile-work-effects(dry-run by default;--yespersists), the real production caller so this code has an operator entry point, not just tests.Small, motivated type extensions:
core/refs.py+insights/work_evidence.py: added thebeads-issueObjectRefkind as a valid "effect" node identity, distinct fromgithub-issue(a Beads issue is never a GitHub-hosted identity even when both trackers exist in one repo). No schema/DDL change needed —node_kind/node_refare free-text columns.insights/work_reconciliation.py: widenedObservedRepositoryEffect/ReconciliationJudgment.evidence_reffrom a bareEvidenceRefto the existingWorkEvidenceSourceRefunion, so non-archived evidence (a commit, a ledger line) can cite anartifact:-kindObjectRefthe same way raw source-tier revisions already do elsewhere in this graph (seeparse_work_evidence_source_ref's existing precedent).Alternatives rejected
claude_workflow_materializer.py's daemon convergence stage was rejected: that stage runs archive-wide with no single "the repo" to scope git effects to (Claude Code sessions can belong to many different local checkouts). An explicit, operator/agent-invoked CLI command with an explicit--repois the honest scope.Deferred (acceptance-criteria honesty)
AC 7 of
polylogue-1vpm.6.2asks that "existing correlate_session/provider-specific effect paths become projections or retire".insights/session_commit.py's file/time-overlap correlation view has its own CLI surface (correlate), API method, and test suite (tests/unit/cli/test_correlate_view.py); a safe retirement or reprojection onto the work-evidence graph is a separate, sizeable migration and is not attempted here — filing this as explicit remaining scope rather than silently dropping it.Verification
Anti-vacuity: adapter tests run real
git init/git logsubprocesses against genuine temp repositories and a real JSON-lines parse of the checked-intests/fixtures/beads/issue-interactions.jsonlfixture — not stand-in doubles. The operations-layer and CLI tests drive the realSessionRepository→ SQLite round trip. Removing the direct-identifier restriction, the git/Beads I/O, or theapplywrite-back makes the respective assertions fail.Not run:
devtools verify --all(full non-integration suite) — left for CI; a live rebuild was noted as consuming CPU during this session per operator note.Ref polylogue-1vpm.6.2
Unblocks
polylogue-z9gh.7's 2026-07-20 bar item 2 ("polylogue-1vpm.6.2 implemented for real"):reconcile_work_effectsnow has concrete git/Beads adapters, a real production caller, and fixture-driven tests proving claim/effect/evaluated stay three distinct facts and that session presence is never equated with task completion.Co-Authored-By: Claude [email protected]