Repository navigation
fix(sources): tighten sidecar admission for tool-results and antigravity brain metadata - #3614
Conversation
Problem: sources/dispatch.py's parse_drive_payload (structural audit M5, polylogue-194qk) re-implements chunk detection and list recursion that _lower_drive_like_payload -> _parse_lowered_spec already owns, with zero production callers -- only self-recursion, __all__, and a self-validating test pair in tests/unit/sources/test_source_laws.py that exercises the dead function against itself rather than against the live lowering pipeline, so it stays green regardless of live-path drift. What changed: removed parse_drive_payload and its __all__ entry from dispatch.py; removed test_parse_drive_payload_contract and test_parse_drive_payload_recurses_lists_and_detected_payloads plus their now-unused parse_drive_payload/drive_parser imports from test_source_laws.py. Pure deletion, no behavior change to any live path. Verification: devtools test tests/unit/sources/test_source_laws.py -> 129 passed, 2 pre-existing failures unrelated to this change (confirmed via git stash: both fail identically on master before this commit -- _detect_provider_from_raw_bytes monkeypatch target rename and an unrelated claude-ai zip-entry detection assertion). grep confirms no remaining parse_drive_payload references outside .beads/ bookkeeping. Ref polylogue-194qk
…ion admission Problem: sources/live/tool_result_sidecars.py joins Claude Code's tool-results/<tool_use_id>.<ext> overflow content back to its owning tool_result block by tool_use_id -- these files are never independent conversation content. Content-shape classification alone cannot refuse them: a tool call's own output can coincidentally reproduce a genuine session-document shape byte-for-byte. Verified live against this machine's real ~/.claude/projects corpus (12,821 non-hook tool-results files, 411 valid-JSON among them): a tool-results/*.txt sidecar whose content was a real claude.ai export document (some earlier turn's tool call had fetched and dumped one) classified as SESSION_DOCUMENT/parse_as_session=True under the prior content-only rules, because it legitimately has uuid/title/messages fields. What changed: added a `tool_result_sidecar` OriginArtifactRule (parse_policy="raw-only") to the Claude Code OriginSpec in sources/origin_specs.py, matching `tool-results/<name>` paths (excluding `hook-*`, which keeps its own already-correct HOOK_EVENT content classification) so `classify_artifact`/`classify_artifact_path` refuse session admission by path alone, before any content heuristic runs -- the same shape as the existing AGENT_SIDECAR_META/WORKFLOW_JOURNAL path rules. Added ArtifactKind.TOOL_RESULT_SIDECAR. path_suffixes is scoped to `.json` only (not the `.txt`/`.html` also found live in the real corpus scan) because `artifact_suffixes_for_provider` feeds `live/watcher.py`'s Claude Code acquisition suffix filter directly -- widening it would expand what gets *acquired* archive-wide, which is out of this fix's scope; the path_pattern match still refuses any other extension's content once a raw row exists via some other acquisition route. Re-scoped the pre-existing `test_bare_tool_use_id_record_does_not _classify_as_session` regression from an UNKNOWN/METADATA_DOCUMENT fallback assertion to the new, stronger path-based TOOL_RESULT_SIDECAR guarantee. Acknowledged the classifier-fingerprint drift gate as acknowledged_safe (tightens acceptance only, no reparse needed -- existing contaminated rows are the already-planned polylogue-x1gd index rebuild's job, not this change's). Cleanup of existing contaminated raw_sessions rows is explicitly out of scope (raw-authority path owns it, per this repo's durable-tier policy). Verification: devtools test tests/unit/sources/test_artifact_taxonomy.py tests/unit/sources/test_origin_specs.py tests/unit/sources/test_dispatch_ payloads.py -> 51 passed. devtools lab policy classifier-fingerprints -> "Classifier fingerprint policy intact." devtools render all --check -> no "out of sync" surfaces. devtools verify --quick -> exit 0 (format, lint, mypy --strict, render-all-check, schema-versioning, classifier-fingerprints, and 20 other lab policy gates all green). Live-corpus scan (ad hoc script, not committed) against 12,821 real tool-results files on this machine: 1 leak found pre-fix, 0 post-fix. Ref polylogue-omsw
…logue-3m3de Problem: polylogue-3m3de reports 232 growing raw_sessions rows for origin=antigravity-session, all brain/<uuid>/*.md.metadata.json sidecars, zero real .pb conversations acquired, asking to "stop sidecar admission the same typed way" as the sibling omsw fix. Investigation (evidence, not the bead's raw-count framing alone): scanned classify_artifact/classify_artifact_path against this machine's real ~/.gemini/antigravity/brain corpus (940 files: 820 path-classified, 120 never reach JSON classification at all -- bare .md prose + one .png, both refused earlier in the pipeline). 0 parse_as_session leaks, 0 schema_eligible leaks. The AGENT_SIDECAR_META path rule for *.md.metadata.json (polylogue-eo81, landed 2026-05-11 in #1024, refined 2026-07-31 in #3441) already refuses session admission by path, and schemas/sampling_db.py's _iter_schema_units_from_db already excludes any schema_eligible=False row from schema-inference sampling -- so both downstream harms the bead names (session materialization, tnqqt's schema inference contamination) are already closed. The growing raw_sessions count is source.db's durable raw-tier retention of every acquired file regardless of classification -- by design, same as the tool-result sidecar raw-tier growth documented in the omsw fix. It is not evidence the classification gate is missing. The real unaddressed gap is the OTHER half the bead itself flags as possibly out of scope: sources/live/watcher.py's live daemon WatchSource for antigravity only watches suffix ".metadata.json" -- it never watches ".pb", so the real conversation files are never discovered by the live daemon at all, regardless of the separate iter_antigravity_language_server _sessions/language-server-RPC bridge that exists in pipeline/services/archive_ingest.py (a path not wired into the live daemon's regular ingest flow). Wiring that up needs acquisition/daemon work, not a classification change -- left explicitly open per this fix's scope. What changed: added test_antigravity_brain_metadata_sidecar_never_schema_eligible_or_session, a regression pin (using real corpus-derived content) that closes the gap in test coverage this bead's investigation exposed -- test_artifact_ taxonomy.py had zero antigravity coverage despite being the module that owns this exact classification decision. Verification: devtools test tests/unit/sources/test_artifact_taxonomy.py -> 13 passed. Ref polylogue-3m3de
|
Warning Review limit reached
Next review available in: 55 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 Plus Run ID: 📒 Files selected for processing (7)
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 |
…ation gaps (#3663) ## Summary Closes two live artifact-taxonomy classification gaps described in polylogue-omsw: tool-results/*.json sidecars and file-history-snapshot-only Claude Code JSONL streams could still be admitted as independent sessions under specific acquisition conditions, despite recent work (PR #3614) already fixing the primary daemon-watcher path. Adds a non-destructive reclassification actuator for already-contaminated raw rows, declares the required SEMANTIC_REPARSE index-schema bump, and regenerates the demo-tour evidence that bump legitimately shifts. ## Problem `polylogue import <path> --explain` against synthetic fixtures reproduced two live gaps at HEAD (evidence, not just code reading, per the bead's own AC): 1. `classify_artifact_path(path, provider=Provider.UNKNOWN)` never consults the Claude Code `tool_result_sidecar` OriginArtifactRule, because `artifact_rule_for_path` gates on an exact provider match. Any acquisition route that cannot pre-fix the provider (the daemon's shared "inbox" import source backing `polylogue import <path>`, and this taxonomy's own pre-decode path-only callers) admitted a `tool-results/*.json` sidecar as an independent session whenever its content happened to resemble a different provider's session-document shape. Reproduced live: a claude-ai-export-shaped payload under `tool-results/` became `session:claude-ai:...` with 1 message. 2. A Claude Code `projects/<proj>/<uuid>.jsonl` file whose only records are `file-history-snapshot`/`progress` checkpoints (never a chat turn) matches the exact same path shape as a genuine `coordinator_session_stream`, so the path-only `OriginArtifactRule` always won and classified it `parse_as_session=True`. `require_positive_conversational_evidence` already refuses to materialize this as an index-tier session post-parse, but the raw-tier `artifact_taxonomy`/`raw_artifacts` classification is a separate layer that must independently say "sidecar", not "session that later turned out empty". A live read-only query (source.db, 2026-08-03) also confirmed the bead's third question: the workflow-journal family (polylogue-lzh8) is closed -- 0 sessions join to `raw_artifacts.artifact_kind='workflow_journal'` -- with one unrelated residual (1 unclassified zero-message session whose raw_artifacts row was never materialized; noted as a minor follow-up, not contamination). ## Solution - `polylogue/archive/artifact_taxonomy/runtime.py`: `_classify_artifact_path_strong` now also checks the Claude Code `tool_result_sidecar` rule regardless of the caller-supplied provider hint, scoped narrowly to that one rule kind (`tool-results/` is a directory name specific enough to Claude Code to check provider-agnostically; `coordinator_session_stream`'s generic pattern is not). `classify_artifact`'s path-rule fast path now runs a content override (`_file_history_snapshot_override`) before returning a session verdict, refusing when every decoded record's type is `file-history-snapshot`/`progress`. - `polylogue/archive/artifact_taxonomy/models.py` / `support.py`: new `ArtifactKind.FILE_HISTORY_SNAPSHOT` + `looks_like_file_history_snapshot_only_stream`, mirroring the type set `archive/raw_materialization.py`'s `parsed_non_session_artifact_reason` already checks post-parse. - `polylogue/storage/tool_result_history_sweep.py` + `devtools/tool_result_history_sweep_report.py` + `devtools/tool_result_history_reclassify_apply.py`: read-only sweep and `--apply`-gated actuator, mirroring the existing `binary_artifact_sweep`/`binary_artifact_reclassify_apply` pattern (polylogue-hbtj2). Persists `raw_artifacts` rows via the existing `materialize_artifact_observations` primitive; never touches `raw_sessions`, `revision_authority`, or `index.db`. Registered in `devtools/command_catalog.py` as `devtools workspace tool-result-history-sweep` / `...-reclassify-apply`. - `polylogue/storage/sqlite/archive_tiers/index.py` + `lifecycle.py`: bumps `INDEX_SCHEMA_VERSION` 57->58 with a `SEMANTIC_REPARSE` declaration (same shape as v42/v44/v45/v46/v48), since the classification change alters `parse_as_session` for identical input bytes. `devtools lab policy classifier-fingerprints` manifest entries recorded via `--ack`. - `docs/examples/demo-tour/`: regenerated (`polylogue demo tour --force`) because `polylogue/demo/receipts.py` embeds `PRAGMA user_version` (== `INDEX_SCHEMA_VERSION`) in its completion-claim sample-manifest hash. **Not run**: the reclassification actuator was built and tested against a synthetic fixture archive only, per instruction. It was NOT run with `--apply` against the real archive (`/realm/db/polylogue`) -- that live mutation, and the `polylogue ops reset --index && polylogued run` this SEMANTIC_REPARSE bump requires to actually re-materialize the affected sessions, are left as explicit operator follow-ups. `devtools workspace tool-result-history-sweep --json` (read-only, safe to run directly) reports the live count/disposition first: 3 tool-results rows found (matching the operator's own prior investigation), 0 file-history-snapshot-only raw rows found in the current live scan. ## Verification - `devtools test tests/unit/sources/test_artifact_taxonomy.py` -> 15 passed - `devtools test tests/unit/storage/test_tool_result_history_sweep.py` -> 3 passed - `devtools test -k "artifact_taxonomy or sidecar"` -> 151 passed - `devtools test tests/unit/storage/test_index_fast_forward_lifecycle.py tests/unit/storage/test_index_fast_forward_executor.py tests/unit/devtools/test_archive_schema_fast_forward.py tests/unit/storage/test_schema_policy_contracts.py` -> 60 passed - `devtools verify --quick` -> exit 0 (format, lint, mypy, render-all, layering, all lab policy gates including classifier-fingerprints and schema-versioning, demo-tour-freshness) - Manual scratch reproduction: `polylogue import <path> --explain` against synthetic fixtures under a scratch dir, before/after the fix, confirming `sessions: 0` for both shapes post-fix (was `sessions: 1` for each, pre-fix) - Read-only live query against `/realm/db/polylogue` (`mode=ro`) confirming the workflow-journal family closure and the tool-results sweep counts cited above Ref polylogue-omsw
Summary
Closes the source-admission/classification cluster spanning three beads: Claude Code tool-result sidecar admission (polylogue-omsw), Antigravity brain-metadata sidecar admission (polylogue-3m3de), and dead-code removal of
parse_drive_payload(polylogue-194qk).Problem
polylogue-omsw:
sources/live/tool_result_sidecars.pyjoins Claude Codetool-results/<tool_use_id>.<ext>overflow content back to its owningtool_resultblock bytool_use_id-- these files are never independent conversation content. Content-shape classification alone cannot refuse them: a tool call's own output can coincidentally reproduce a genuine session-document shape byte-for-byte. Verified live against this machine's real~/.claude/projectscorpus (12,821 non-hook tool-results files, 411 valid-JSON among them): onetool-results/*.txtsidecar whose content was a real claude.ai export document (an earlier turn's tool call had fetched and dumped one) classified asSESSION_DOCUMENT/parse_as_session=Trueunder the prior content-only rules.polylogue-3m3de: reported 232 growing
raw_sessionsrows fororigin=antigravity-session, allbrain/<uuid>/*.md.metadata.jsonsidecars, zero real.pbconversations acquired. Investigation (scannedclassify_artifact/classify_artifact_pathagainst this machine's real~/.gemini/antigravity/braincorpus, 940 files): 0 leaks. The existingAGENT_SIDECAR_METApath rule (polylogue-eo81, #1024/#3441) andschemas/sampling_db.py'sschema_eligibleexclusion already close both downstream harms the bead names (session materialization, schema-inference contamination). The growing raw-row count issource.db's durable raw-tier retention by design, not an admission-scope bug. The real unaddressed gap --sources/live/watcher.py's antigravityWatchSourceonly watches.metadata.json, never.pb-- is acquisition/daemon wiring work, explicitly left open per this fix's scope.polylogue-194qk:
sources/dispatch.py:1777-1828'sparse_drive_payloadre-implements chunk detection/list recursion the lowering pipeline (_lower_drive_like_payload->_parse_lowered_spec) already owns, with zero production callers -- only self-recursion,__all__, and a self-validating test pair that exercises the dead function against itself.Solution
tool_result_sidecarOriginArtifactRule(parse_policy="raw-only") to the Claude CodeOriginSpec, matchingtool-results/<name>paths (excludinghook-*, which keeps its own correctHOOK_EVENTcontent classification) soclassify_artifact/classify_artifact_pathrefuse session admission by path, before any content heuristic runs -- same shape as the existingAGENT_SIDECAR_META/WORKFLOW_JOURNALrules. AddedArtifactKind.TOOL_RESULT_SIDECAR.path_suffixesscoped to.jsononly (not the.txt/.htmlalso found live) becauseartifact_suffixes_for_providerfeedslive/watcher.py's acquisition suffix filter directly -- widening it would expand what gets acquired archive-wide, out of scope.docs/plans/classifier-fingerprints.json) asacknowledged_safe: tightens acceptance only, no reparse needed (existing contaminated rows are the already-planned polylogue-x1gd index rebuild's job).parse_drive_payloadand its self-validating tests/imports.Verification
devtools test tests/unit/sources/test_artifact_taxonomy.py tests/unit/sources/test_origin_specs.py tests/unit/sources/test_source_laws.py tests/unit/sources/test_dispatch_payloads.py-> 181 passed, 2 pre-existing failures unrelated to this change (confirmed via isolated diff-based comparison to origin/master: both fail identically before this branch's commits -- a_detect_provider_from_raw_bytesmonkeypatch-target rename and an unrelated claude-ai zip-entry detection assertion).devtools lab policy classifier-fingerprints-> "Classifier fingerprint policy intact."devtools render all --check-> no "out of sync" surfaces.devtools verify --quick-> exit 0 (format, lint, mypy --strict, render-all-check, schema-versioning, classifier-fingerprints, and other lab policy gates all green).~/.claude/projectstool-results files (12,821) and~/.gemini/antigravity/brainfiles (940): 0 classification leaks post-fix.Cleanup of existing contaminated
raw_sessionsrows is explicitly out of scope for both beads (raw-authority path owns it, per this repo's durable-tier policy).Ref polylogue-omsw, polylogue-3m3de, polylogue-194qk