Skip to content

fix(storage): close the append-ingest gate + declare the missed workflow-artifact reparse - #3433

Merged
Sinity merged 4 commits into
masterfrom
feature/fix/close-third-chokepoint-and-workflow-reparse
Jul 31, 2026
Merged

Sinity merged 4 commits into
masterfrom
feature/fix/close-third-chokepoint-and-workflow-reparse

Conversation

@Sinity

@Sinity Sinity commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Two related aggz-invariant-2 follow-ups ("exactly one chokepoint may write a
session"):

  1. polylogue-xwkh — closes the third of three chokepoints that decide
    whether a raw record becomes a session. PR fix(sources): require positive conversation evidence before session classification #3428 unified live daemon
    ingest and rebuild replay behind classify_artifact/
    artifact_rule_for_path; live incremental append
    (sources/live/append_ingest.py) had no such gate at all.
  2. polylogue-lzh8 — declares the missing SEMANTIC_REPARSE index-version
    bump for PR feat(sources): admit Claude Workflow artifacts through OriginSpec #3088 (1e0246d), which shipped a classification fix for
    Claude Workflow artifacts with no version declaration, so already-
    materialized wrong rows never got a reparse signal.

Also investigates (per polylogue-xwkh/lzh8's own framing) why
devtools lab policy schema-versioning didn't stop #3088's undeclared bump,
and files a follow-up bead rather than rushing a fix.

Problem

xwkh: _ingest_append_plans_archive called parse_payload on every
append unconditionally. Empirically verified (fresh in-memory archive,
ingest_append_plans called directly) that a growing OriginSpec-declared
"fact" artifact (subagents/workflows/<run>/journal.jsonl,
parse_policy="fact") reaching append tracking — e.g. after an ops.db
cursor reset resynthesizes a cursor from a durable full baseline already
recorded in source.db (batch.py's _resynthesize_cursor_from_source,
which consults only byte-provenance, never classification) — did not
leak a phantom session, but only by accident: parse_retained_raw_sessions
(used later, for replay) already applies the same gate and returns zero
sessions, tripping the did not replay to exactly one session
RuntimeError. That still meant a wasted raw write, a wasted parse, and a
crash-shaped failure log on every single observation of the file,
forever
, since a failed append never advances its cursor.

lzh8: measured live impact on index.db (read-only query,
/realm/db/polylogue/index.db, 2026-07-31): 5,193 zero-message
claude-code-session rows total, of which 172 join to a workflows/
artifact family under the pre-fix classification (164 agent_sidecar_meta,
7 workflow_run_snapshot, 1 other), all acquired 2026-07-14..07-26 —
entirely before the deployed daemon build contained 1e0246d (sinnix's
polylogue pin only advanced past it 2026-07-29).

Lint gap: devtools/verify_schema_upgrade_lane.py's
index_delta_declaration_report(INDEX_SCHEMA_VERSION) only checks that the
declaration table is internally complete/consistent up to the current
INDEX_SCHEMA_VERSION constant. It never inspects origin_specs.py,
artifact_taxonomy/, or any other classification source — a commit that
changes classification semantics without touching the version constant is
invisible to it by construction. It can only catch an undeclared bump,
never a missing bump. A real fix (content-fingerprinting the
classification tables, versioned and diffed at lint time) is a genuine
architecture addition, not a small local patch, so filed as follow-up
polylogue-qs4b instead of rushed here.

Solution

  • polylogue/sources/live/append_ingest.py: import
    revision_backfill._is_declared_non_session_artifact (the same check the
    other two chokepoints already consult) and apply it to the append's
    decoded record sample (sample=payloads[:64], same bound as the live
    daemon path) before calling parse_payload. A refused record now fails
    cleanly (mark_raw_parse_failed + failed.append) instead of via an
    uncaught-looking RuntimeError, with no wasted parse work.
  • polylogue/storage/sqlite/archive_tiers/index.py: bump
    INDEX_SCHEMA_VERSION to 48, with a header comment citing 1e0246d/feat(sources): admit Claude Workflow artifacts through OriginSpec #3088
    and the measured counts.
  • polylogue/storage/sqlite/lifecycle.py: add the matching
    IndexDeltaDeclaration(version=48, classes=(SEMANTIC_REPARSE,)) — no
    fast-forward operations, same "values depend on parser semantics, no
    clone-safe SQL delta" shape as v42/v44/v45/v46. This commit does not run
    any rebuild.
  • .beads/issues.jsonl: close polylogue-xwkh, polylogue-lzh8; file
    polylogue-qs4b for the lint-gap follow-up.

Operator action required

This PR declares the delta; it does not apply it. To reclassify the 172
contaminated rows, the operator must deliberately run:

polylogue ops reset --index && polylogued run

against the live archive. This was intentionally not run from this
branch/session per polylogue-lzh8's explicit instruction (consequential
live-daemon action, extended downtime rebuilding ~20K sessions, needs
deliberate scheduling).

AC disposition

polylogue-xwkh (no formal AC list, task framed as investigate+verify+fix+test):

  • Verified empirically what append_ingest.py currently admits — satisfied (see Problem).
  • Routed through the same classify_artifact gate the other two chokepoints use — satisfied.
  • Regression test proving a record refused by the other paths is now also refused here — satisfied (test_live_append_refuses_declared_non_session_artifact).

polylogue-lzh8:

  1. lifecycle.py gets a new IndexDeltaDeclaration bumping INDEX_SCHEMA_VERSION with classes=(SEMANTIC_REPARSE,), comment naming 1e0246d/feat(sources): admit Claude Workflow artifacts through OriginSpec #3088 and the measured counts — satisfied.
  2. PR body explicitly tells the operator a rebuild is now required — satisfied (see above).
  3. After the rebuild, the 172+ contaminated sessions reclassify — deferred: not executed per the bead's own DO-NOT-EXECUTE instruction; operator must run it deliberately.
  4. devtools lab policy schema-versioning stays green — satisfied.
  5. (informal ask) Investigate why the lint didn't catch feat(sources): admit Claude Workflow artifacts through OriginSpec #3088's original miss — satisfied, see Problem/Solution; misframed as an inline fix: filed polylogue-qs4b instead, since a real fix needs design work, not a rushed patch riding this PR.

Verification

  • devtools test tests/unit/storage/test_raw_revision_authority.py -k test_live_append → 3 passed.
  • 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 → 53 passed.
  • devtools verify --quick → exit 0 (format, lint, mypy --strict, render all --check, schema-versioning lint, schema promotion audit) — ran twice (pre-commit local + pre-push hook).
  • Not run: devtools verify --all (full non-integration suite) — left for CI's post-merge heavy test job per this repo's per-PR test-skip convention; not run against the live archive (read-only queries only, no writes, no daemon run).

Ref polylogue-xwkh, polylogue-lzh8, polylogue-qs4b

🤖 Generated with Claude Code

Sinity and others added 3 commits July 31, 2026 10:09
…check

Problem: PR #3428 unified two of the three chokepoints that can turn a raw
record into a session (live daemon ingest and rebuild replay) behind
classify_artifact/artifact_rule_for_path, but left the third -- live
incremental append (sources/live/append_ingest.py) -- untouched: it called
parse_payload unconditionally, with no session-artifact gate at all.

Empirically verified (polylogue-xwkh): a growing OriginSpec-declared "fact"
artifact (e.g. subagents/workflows/<run>/journal.jsonl, parse_policy="fact")
that reaches append tracking -- e.g. after an ops.db cursor reset resynthesizes
a cursor from a durable "full" baseline already recorded in source.db, see
batch.py's _resynthesize_cursor_from_source -- was NOT leaking a phantom
session, but only by accident: parse_retained_raw_sessions (used later for
replay) already applies the same gate and returns zero sessions, which trips
the "did not replay to exactly one session" RuntimeError. That still meant a
wasted raw write, a wasted parse, and a crash-shaped failure log on every
single observation of the file, forever, since a failed append never advances
its cursor.

Solution: import revision_backfill._is_declared_non_session_artifact (the
same check the other two chokepoints already consult) and apply it to the
append's decoded record sample before calling parse_payload. A refused record
now fails cleanly (mark_raw_parse_failed + failed.append) instead of via an
uncaught-looking RuntimeError, and does no wasted parse work.

Verification: devtools test tests/unit/storage/test_raw_revision_authority.py
-k test_live_append -- 3 passed (new
test_live_append_refuses_declared_non_session_artifact plus the two existing
live-append regression tests, confirming real Codex session appends are
unaffected).

Ref polylogue-xwkh

Co-Authored-By: Claude <[email protected]>
Problem: PR #3088 (1e0246d, merged 2026-07-18) fixed Claude Workflow
artifact classification (workflow_run_snapshot / workflow_journal /
agent_sidecar_meta / adopt_manifest now correctly resolve
parse_policy="fact"/parse_as_session=False) but declared no
INDEX_SCHEMA_VERSION delta. Per docs/internals.md's schema-versioning model,
only a declared SEMANTIC_REPARSE delta gives the daemon a signal to reparse;
an undeclared semantic change leaves already-materialized wrong-
classification rows untouched forever, because fast-forward convergence has
no version transition to act on. Measured live impact (index.db, read-only,
2026-07-31): 172 zero-message claude-code-session rows (164
agent_sidecar_meta + 7 workflow_run_snapshot + 1 other) acquired
2026-07-14..07-26, entirely before the deployed daemon build picked up the
fix (sinnix's polylogue pin advanced past 1e0246d only on 2026-07-29).

Solution: bump INDEX_SCHEMA_VERSION to 48 (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. This does NOT run any rebuild. The operator must run
`polylogue ops reset --index && polylogued run` deliberately to apply it;
see the PR body for that instruction.

Verification: 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 -- 53 passed.

Ref polylogue-lzh8

Co-Authored-By: Claude <[email protected]>
Ref polylogue-xwkh, polylogue-lzh8, polylogue-qs4b

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3e4967df-4b81-40cb-bf9c-13e36f71916b

📥 Commits

Reviewing files that changed from the base of the PR and between d2402c1 and 54c8b51.

📒 Files selected for processing (5)
  • .beads/issues.jsonl
  • polylogue/sources/live/append_ingest.py
  • polylogue/storage/sqlite/archive_tiers/index.py
  • polylogue/storage/sqlite/lifecycle.py
  • tests/unit/storage/test_raw_revision_authority.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54c8b5116e

ℹ️ 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".

Comment thread polylogue/sources/live/append_ingest.py Resolved
@Sinity
Sinity merged commit b87c85e into master Jul 31, 2026
1 of 2 checks passed
@Sinity
Sinity deleted the feature/fix/close-third-chokepoint-and-workflow-reparse branch July 31, 2026 08:26
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 70.F047 / P1: fixed-already at the checked revision: Declared non-session artifacts are admitted without entering the session parser. polylogue/sources/live/append_ingest.py:338 acknowledges the admitted artifact in succeeded, so valid fact tails advance through the success cursor path instead of entering the failure ledger.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant