Repository navigation
fix(sources): close live tool-results/file-history-snapshot classification gaps - #3663
Conversation
Problem: bd polylogue-omsw asks for a scratch acquisition run (not code reading) proving the current discovery path no longer mints independent sessions for tool-results/*.json and file-history-snapshot-only files. `polylogue import <path> --explain` reproduced two live gaps: 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). 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". Solution: - 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). - runtime.py: 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. - models.py: new ArtifactKind.FILE_HISTORY_SNAPSHOT. - support.py: 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. - tests/unit/sources/test_artifact_taxonomy.py: two new regression tests pinning both fixes, including a sanity check that genuine sessions at the same path shapes are unaffected. Verification: `devtools test tests/unit/sources/test_artifact_taxonomy.py` -> 15 passed in 12.37s. Manually re-ran the exact scratch reproduction (`polylogue import <path> --explain` against synthetic fixtures under /realm/tmp/work/omsw-scratch/) before and after the fix, confirming sessions=0 for both shapes post-fix. Ref polylogue-omsw
Problem: polylogue-omsw AC #3 requires that already-ingested tool-results/ file-history-snapshot rows be RECLASSIFIED, never deleted, following the 2026-07-22 hook-inflation postmortem's durable-tier evidence retention precedent, and that the count/disposition be recorded. No actuator existed scoped to this bead's two families (the existing devtools/binary_artifact_reclassify_apply.py covers an unrelated binary- database miscapture class, polylogue-hbtj2). Solution, mirroring the binary_artifact_sweep/reclassify_apply pattern exactly: - polylogue/storage/tool_result_history_sweep.py: read-only sweep over claude-code-session raw_sessions rows, reusing inspect_raw_artifact (now correctly classifying both families after the artifact_taxonomy fix) as a pure function. Never mutates source.db. - devtools/tool_result_history_sweep_report.py: CLI report over the sweep (human-readable + --json). - devtools/tool_result_history_reclassify_apply.py: --apply-gated actuator that persists raw_artifacts rows via the existing materialize_artifact_observations primitive (the same durable-observation machinery binary_artifact_reclassify_apply.py already uses). Default is dry-run; never touches raw_sessions, revision_authority, or index.db. - devtools/command_catalog.py + docs/devtools.md (rendered): registers both as `devtools workspace tool-result-history-sweep` / `...-reclassify-apply`. - tests/unit/storage/test_tool_result_history_sweep.py: seeds a source.db with one tool-results row, one file-history-snapshot-only row, and one genuine session, and proves (a) the sweep finds exactly the two contaminated rows, (b) dry-run writes nothing, (c) --apply persists the correct raw_artifacts.artifact_kind for each row while leaving raw_sessions row count unchanged (never deletes). Not run: this actuator is 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 is left as an explicit follow-up for an operator with that authority. `devtools workspace tool-result-history-sweep --json` (read-only, safe to run directly) reports the live count/disposition first. Verification: `devtools test tests/unit/storage/test_tool_result_history_sweep.py` -> 3 passed in 10.26s. `mypy` clean on all three new modules. `ruff format --check` / `ruff check` clean. Ref polylogue-omsw
Problem: devtools lab policy classifier-fingerprints (part of devtools verify --quick) failed after the artifact_taxonomy fix: classify_artifact's logic changed classification decisions for identical input bytes (a tool-results/*.json sidecar with a non-Claude-Code provider hint, and a file-history-snapshot-only stream) without a declared INDEX_SCHEMA_VERSION delta. Per docs/internals.md's schema-versioning model and the polylogue-lzh8 precedent (4db6b83, v48), an undeclared semantic classification change leaves already-materialized wrong-classification rows untouched forever -- fast-forward convergence has no version transition to act on. Solution: bump INDEX_SCHEMA_VERSION to 58 (archive_tiers/index.py) and add its IndexDeltaDeclaration (storage/sqlite/lifecycle.py) with classes=(SEMANTIC_REPARSE,) and no fast-forward operations -- the same "values depend on parser semantics, no clone-safe SQL delta" shape as v42/ v44/v45/v46/v48. Also recorded the classifier-fingerprint manifest entries (devtools lab policy classifier-fingerprints --ack) for classify_artifact (semantic_reparse_version=58) and the new looks_like_file_history_snapshot_only_stream helper (acknowledged_safe). This does NOT run any rebuild. The operator must run `polylogue ops reset --index && polylogued run` deliberately to apply it. Verification: `devtools lab policy classifier-fingerprints` -> "Classifier fingerprint policy intact." `devtools lab policy schema-versioning` -> "Schema evolution policy intact." `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. Ref polylogue-omsw
Problem: devtools lab policy demo-tour-freshness (part of devtools verify --quick) started failing after the polylogue-omsw INDEX_SCHEMA_VERSION 57->58 bump. polylogue/demo/receipts.py's completion-claim sample manifest embeds `PRAGMA user_version` (== INDEX_SCHEMA_VERSION) directly into its hash payload, so bumping the schema version legitimately changes the manifest hash the demo tour prints -- this is the same mechanism every prior SEMANTIC_REPARSE bump has needed a matching regeneration for. Solution: ran `polylogue demo tour --out-dir polylogue-demo-tour --force` and copied the regenerated transcript.txt, report.md, report.json, recording.tape, and command-output/*.txt into docs/examples/demo-tour/ per the tool's own fix instruction. Only the sample-manifest hash line and wall-clock timing fields changed; the mask-aware freshness check's own comparison (which zeroes timing) confirms no unmasked drift remains. Verification: `devtools lab policy demo-tour-freshness` -> "fresh tour output matches committed docs/examples/demo-tour/ (masked)". Ref polylogue-omsw
|
Warning Review limit reached
Next review available in: 9 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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 (17)
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 |
…w-tool-result-file-history-sidecars # Conflicts: # docs/devtools.md
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> --explainagainst synthetic fixtures reproduced two live gaps at HEAD (evidence, not just code reading, per the bead's own AC):classify_artifact_path(path, provider=Provider.UNKNOWN)never consults the Claude Codetool_result_sidecarOriginArtifactRule, becauseartifact_rule_for_pathgates on an exact provider match. Any acquisition route that cannot pre-fix the provider (the daemon's shared "inbox" import source backingpolylogue import <path>, and this taxonomy's own pre-decode path-only callers) admitted atool-results/*.jsonsidecar 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 undertool-results/becamesession:claude-ai:...with 1 message.A Claude Code
projects/<proj>/<uuid>.jsonlfile whose only records arefile-history-snapshot/progresscheckpoints (never a chat turn) matches the exact same path shape as a genuinecoordinator_session_stream, so the path-onlyOriginArtifactRulealways won and classified itparse_as_session=True.require_positive_conversational_evidencealready refuses to materialize this as an index-tier session post-parse, but the raw-tierartifact_taxonomy/raw_artifactsclassification 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_strongnow also checks the Claude Codetool_result_sidecarrule 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 isfile-history-snapshot/progress.polylogue/archive/artifact_taxonomy/models.py/support.py: newArtifactKind.FILE_HISTORY_SNAPSHOT+looks_like_file_history_snapshot_only_stream, mirroring the type setarchive/raw_materialization.py'sparsed_non_session_artifact_reasonalready 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 existingbinary_artifact_sweep/binary_artifact_reclassify_applypattern (polylogue-hbtj2). Persistsraw_artifactsrows via the existingmaterialize_artifact_observationsprimitive; never touchesraw_sessions,revision_authority, orindex.db. Registered indevtools/command_catalog.pyasdevtools workspace tool-result-history-sweep/...-reclassify-apply.polylogue/storage/sqlite/archive_tiers/index.py+lifecycle.py: bumpsINDEX_SCHEMA_VERSION57->58 with aSEMANTIC_REPARSEdeclaration (same shape as v42/v44/v45/v46/v48), since the classification change altersparse_as_sessionfor identical input bytes.devtools lab policy classifier-fingerprintsmanifest entries recorded via--ack.docs/examples/demo-tour/: regenerated (polylogue demo tour --force) becausepolylogue/demo/receipts.pyembedsPRAGMA 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
--applyagainst the real archive (/realm/db/polylogue) -- that live mutation, and thepolylogue ops reset --index && polylogued runthis 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 passeddevtools test tests/unit/storage/test_tool_result_history_sweep.py-> 3 passeddevtools test -k "artifact_taxonomy or sidecar"-> 151 passeddevtools 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 passeddevtools verify --quick-> exit 0 (format, lint, mypy, render-all, layering, all lab policy gates including classifier-fingerprints and schema-versioning, demo-tour-freshness)polylogue import <path> --explainagainst synthetic fixtures under a scratch dir, before/after the fix, confirmingsessions: 0for both shapes post-fix (wassessions: 1for each, pre-fix)/realm/db/polylogue(mode=ro) confirming the workflow-journal family closure and the tool-results sweep counts cited aboveRef polylogue-omsw