Skip to content

fix(markers): replace uncommitted pending carriers, retire late-parent prefixes - #5747

Merged
Sinity merged 3 commits into
masterfrom
claude/marker-carrier-lifecycle
Sep 28, 2026
Merged

Sinity merged 3 commits into
masterfrom
claude/marker-carrier-lifecycle

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Two marker-carrier lifecycle defects that change what a fresh build stores (polylogue-1tyq5.139, polylogue-1tyq5.135):

  • A raw whose index transaction rolled back now retries through the ordinary session writer. Its uncommitted pending carrier is replaced by the retry's interpretation. Before this change, a hash-only shortcut skipped the writer.
  • When a child session is ingested before its parent and the parent then arrives, the child's already-accepted prefix marker candidates are superseded when the parent's carrier is delivered. Before this change they stayed live next to the parent's copies.

Problem

Pending-carrier shortcut (1tyq5.139, seven Codex findings on #5507). If a raw's index transaction rolled back and another raw then published an identical session hash, _reuse_current_accepted_marker_carrier returned early and skipped _drain_ready_session_entries. The retry then:

  • left sessions.raw_id on the intervening raw;
  • skipped stale-session deletion, ingest-flag convergence and FTS repair detection;
  • recorded no skipped session;
  • accepted the stale pending bytes. For a prefix-sharing child those bytes held candidates for rows the committed index does not contain.

A related liveness defect: a pending carrier from a replaced index incarnation was refused on every retry. A cold build that restarts after its generation is reclaimed would therefore strand those raws permanently.

Child-before-parent markers (1tyq5.135, #5493). A child written before its parent is stored whole, so marker_candidates_for_prepared_write sealed candidates for the replayed prefix under the child's message ids. When the parent arrived, _reextract_prefix_tail_db deleted those rows and the parent's carrier sealed the same markers under the parent's ids. Assertion ids include the evidence refs, so delivery kept two candidate assertions for each inherited marker.

Solution

  • _reuse_current_accepted_marker_carrier now reuses a carrier only when a witness proves it committed in the current incarnation.
  • A pending carrier is the prepare half of a two-tier commit: its witness is inserted in the same index transaction as the writes it describes. When the open index transaction has no witness for the request, _publish_marker_witnesses_before_index_commit replaces the pending carrier through replace_uncommitted_pending_marker_input_sync. The replacement is compare-and-swap on the retained digest and is declared in the durable-write census as two_phase_recovery. Accepted carriers are never replaced.
  • Re-extraction streams each removed prefix text block of the child to a sink (report_reextracted_prefix_blocks), which keeps only the derived ids. The writing raw's carrier records the child assertion ids those blocks produced, as retired_assertions, computed with the same extraction the child's carrier used (retired_marker_assertion_ids). Delivery records each retired id in the new user-tier table retired_marker_assertions, marks an existing untouched candidate superseded, and lower_markers skips any retired id, so delivery order between the child's and parent's carriers does not matter. Only untouched agent candidate rows are changed; human assertions and existing judgments are preserved. The marker recipe format moves from 3 to 4.

Derived-identity closure: storage/sqlite/archive_tiers/write.py, storage/accepted_marker_inputs.py and pipeline/services/ingest_batch/_models.py are members, so this must land before the fresh build starts. Schema classification: additive-durable, meaning one new user.db table in USER_DDL, written through user_write.record_retired_marker_assertion. No v1 archive has been built, so the change follows the repository's fresh-floor route (the same one #5657 used): ARCHIVE_FORMAT_LINEAGE moves from polylogue.archive-format.v4 to v5, and every tier stays at user_version=1. Any v4 development root is therefore fenced at open rather than opened without the table. devtools gate schema-manifest reports durable-schema-evolution: PASS and devtools gate layering reports violations: [].

Verification

  • agentctl job start polylogue pytest_focused -- tests/unit/markers tests/unit/storage/test_accepted_marker_consumer.py tests/unit/storage/test_bulk_fts_prefix_reextract.py tests/unit/storage/test_fresh_archive_format.py tests/unit/storage/test_durable_tier_version_authority.py tests/unit/devtools/test_verify_schema_manifest.py on head 50d7a48 (job 1194): Success.
  • An earlier run on 1b8c464 (job 869) also covered tests/unit/security/test_excision_carrier_reach.py. Its one failure is inherited and unrelated: raw_existence_changes is declared TOMBSTONE, and the test expects RETIRED.
  • mypy on the changed files: no issues.

Anti-vacuity:

  • Restoring the hash-only shortcut leaves sessions.raw_id on the intervening raw, records zero skipped sessions, and accepts the stale pending bytes. test_public_marker_retry_replaces_uncommitted_pending_carrier asserts all three.
  • Removing retirements leaves two live candidates for the inherited marker, which fails test_late_parent_supersedes_the_childs_prefix_markers.
  • If a retirement only supersedes rows that already exist, delivering the parent's carrier first leaves a live candidate, which fails test_retirement_delivered_before_the_child_carrier_still_holds.

Residuals

  • Accepted carriers encode lineage state at ingest time: a tail-only child and a whole child produce different bytes. A later rebuild that ingests in a different order than the original run would be refused on byte equality. The fresh v1 build starts with no accepted carriers, so it is not affected. Filed as polylogue-gubtm.
  • If a person already judged a child prefix assertion (accepted or rejected, for example) before the parent arrived, that judgment is kept, and the parent's copy remains alongside it.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T22:28:02.552843Z 50d7a48 New commits
🔒 Security Review ✅ Completed 2026-09-28T19:43:55.801628Z 71ef5f2 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 71ef5f27cd

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

@Sinity
Sinity force-pushed the claude/marker-carrier-lifecycle branch from 71ef5f2 to 1b8c464 Compare September 28, 2026 20:21

@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: 1b8c464173

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

@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Answers to the Codex review threads. Inline replies to review threads are currently being rejected by GitHub's secondary rate limit, so all three answers are here.

  1. Preserve retirements until child candidates exist (P1, marker_domain.py): fixed in 1b8c464. retire_marker_assertions now records each retired id in the new user-tier table retired_marker_assertions (INSERT OR IGNORE), in addition to superseding a live agent candidate. lower_markers skips any retired id, so a child carrier delivered after the parent's retirement never lowers that candidate live. Regression test: test_retirement_delivered_before_the_child_carrier_still_holds appends the parent's retirement carrier before the child's carrier and asserts that no live candidate remains.
  2. Stream retirement extraction (P2, write.py): fixed in 1b8c464. _reextract_prefix_tail_db now streams each removed (message_id, position, text) row into a caller-supplied sink (report_reextracted_prefix_blocks). The ingest caller turns each row into assertion ids immediately, so it keeps only the ids and never the prefix text.
  3. Add a numbered user-tier migration (P1, user.py): not applicable. No v1 user.db exists yet: the fresh v1 archive has not been built, and earlier Polylogue state is inert salvage that is never opened or migrated (AGENTS.md, Storage tiers). This change lands before the first v1 build, so every v1 user.db will be created from this USER_DDL. Numbered durable migrations apply to changes made after a v1 format has shipped.

@Sinity
Sinity force-pushed the claude/marker-carrier-lifecycle branch from 1b8c464 to 47ad959 Compare September 28, 2026 22:07
@Sinity
Sinity merged commit 3142c56 into master Sep 28, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the claude/marker-carrier-lifecycle branch September 28, 2026 22:42
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