Skip to content

fix(ingest): recover append kills; escalate stuck and silent failures - #5715

Merged
Sinity merged 10 commits into
masterfrom
claude/reliability2
Sep 29, 2026
Merged

Sinity merged 10 commits into
masterfrom
claude/reliability2

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Recovers the tail of an append whose process was killed mid-write, and turns four kinds of stuck or silent ingest/daemon failure into terminal, visible outcomes. Beads: polylogue-b8of0, polylogue-7c5k6, polylogue-wyi9p, polylogue-oulj2, polylogue-hu24g, polylogue-xf8qp, polylogue-zt8is, plus two status residuals of polylogue-qw8zp / polylogue-10a3q.

Problem

  • Append kill loses the tail (b8of0). Kill the process inside an append's index write, then restart. The first page defers the path and schedules a 60 s retry. The next page reads that not-yet-due retry as already admitted and acknowledges it as DUPLICATE. Later passes defer forever, because the writer refuses a prepared field union ("no longer applies") that its own precedence decision no longer needs. The index stays at 3 of 6 messages.
  • Worker death or hang never escalates (7c5k6). Every BrokenProcessPool was deferred, and a deferral resets failure_count, so a file that kills its worker is retried every pass for the whole build. A hung worker is stopped only at shutdown and holds its slot until then.
  • Deterministic intake failures retry forever (wyi9p). Every escaped exception became RETRYABLE, and the attempt counter restarted after each cooldown. A sqlite3.Error escaping page admission bypassed daemon.intake.page_refused.
  • Embedding cap fails open (oulj2). An unreadable spend probe returned 0.0, which granted the whole monthly budget.
  • Six swallowed failures (hu24g): the Drive config read, both heartbeat alert probes, the debt-retry pass, the Gemini typed-extraction fallback, the Codex thread-state currency check, and the browser-capture census.
  • Zero-session files are reported admitted (xf8qp), so the operator's admitted count includes files that produced nothing.
  • The delegation snapshot refuses more than 100k rows or 64 MiB (zt8is). Those caps reject valid input.
  • Status during a first build: the discovery overlay replaced the build's mode and ETA with discovery_pending / None while discovery paged. A root with no active generation had no status frame, so the snapshot read "unavailable" for the entire first build.

Solution

  • watcher.classify_ingest_candidates splits a page into paths that are needed now and paths that are waiting on a scheduled retry; it is the only selection route (select_ingest_candidates is removed). FileIntakeAdapter reports a pending path as DEFERRED, never DUPLICATE. The writer drops a prepared union its precedence does not need and writes the parsed rows it already holds.
  • LiveParseStage (rebuilt on perf(sources): overlap parsing, decode once, never abandon preparation #5691's read-ahead model) charges each worker loss to the one file whose task a worker held. _run_holding_attempt marks the parent-assigned attempt directory when a worker takes a task and when it lets go, so the tasks held at a pool break are exactly those started and not finished. One held task is charged. Several are deferred uncharged and become solo suspects, which run on an otherwise idle pool (and are never read ahead) until a worker comes back from them, so each later loss names one file. Losses are counted per observation (size, mtime_ns, inode). The third consecutive loss on an unchanged observation is a non-deferred failure carrying failed_observation, and pop_path applies it only to a capture of that same revision; the cursor's failure budget then quarantines the file.
  • Hangs: perf(sources): overlap parsing, decode once, never abandon preparation #5691 bounds only read-ahead (lifetime and preemption) and leaves required work waiting forever, so this PR keeps one hang mechanism, for required work only, and measures it the way perf(sources): overlap parsing, decode once, never abandon preparation #5691 measures progress. A process worker whose attempt directory has not grown for 600 s plus its source size at 256 KiB/s is stopped through _stop_process_workers, the same restart-and-settle path that reaps read-ahead. Only that path is charged; interrupted required siblings lose their restart deferral and the waiting warm resubmits them. Slow work that keeps writing is never stopped. The earlier submission-time deadline reaper, its _path_started clock and the plural failed_attempts restart argument are gone.
  • AdmissionResult.transient records whether a failure can clear on its own. Locks, OS errors and storage faults are transient and retry without bound. An unchanged item that repeats the same non-transient failure is isolated after max_deterministic_cooldowns (3). The page handler also catches sqlite3.Error and emits page_refused.
  • The spend probe returns None when unreadable, and the pass then refuses with spend_unmeasured.
  • Each of the six hu24g sites now emits an event, returns the failure to its owner (the debt retry re-raises into the loop's last_error), or narrows its handler (Gemini now catches only ValidationError).
  • Zero-session paths are carried through the batch result and the metrics, and are reported EXCLUDED.
  • Delegation evidence is read in 1,000-row keyset pages, whose key coalesces only NULL exactly as the SQL order does. Both caps are gone, and the snapshot digests every row.
  • The overlay keeps build keys once a planned denominator exists. _status_frame returns no-active-generation for a missing active index.
  • Retargets a stale monkeypatch in the ZIP streaming test, which named a detector batch.py has not imported since fix: retain JSON evidence through size-independent preparation #5557.

Schema identity: devtools schema closure marks sources/live/{batch,batch_support,metrics,parse_prefetch,watcher}.py, sources/dispatch.py, sources/codex_state_evidence.py and storage/sqlite/archive_tiers/write.py IN, and the new idx_delegation_facts_query_order changes index DDL. This PR moves the derived identity (parse_prefetch.py included), so it must land before the fresh rebuild starts.

Verification

On head dbccb4817b, through AgentCTL jobs (never in-process):

  • agentctl job start polylogue verify_quick (job c1c21522): verify: PASSED exit=0 ... head=dbccb4817b15
  • agentctl job start polylogue pytest_focused -- <15 files: derivation kernel laws, parse-stage equivalence, live watcher, daemon cli, derivation admission, parse prefetch, watcher locking, prefetch cache, dispatcher intake measurement, fair intake, delegation materializer, page selection, batch convergence, excluded-cursor proof, canonical ingest> (job f43837d3): 580 passed, 3 failed. Four daemon-cli tests failed in the batch and passed on isolated rerun (host load; one of them, the cold-build transient settlement test, also passed alone on the previous head as 2 passed in 47.56s).
  • The 3 failures reproduce identically on master 0156f3b97a (clean detached worktree, pytest_focused -- --on-default-branch: 3 failed), so they are inherited, not caused here: test_live_batch_convergence::test_page_admission_runs_lease_free_owners_outside_the_writer_gate, test_live_watcher_locking::test_watcher_queues_behind_daemon_maintenance_writer, test_dispatcher_intake_measurement::test_dispatcher_page_compaction_cost_is_one_scoped_hold_at_archive_scale.

New behavior tests, each naming what would make it fail:

  • append kill: 3 restart pages all DEFERRED (pre-fix: DUPLICATE), then 6/6/1 messages and no parse errors; a scheduled retry is DEFERRED with zero cost at the adapter and pending in watcher classification
  • a killer file escalates on its third loss on real process pools; a pool break charges only the task still held; two held tasks charge neither and run alone until attributed; a restart-preserved success or a worker error ends the streak; rewritten content starts a new streak and an escalated failure does not apply to it
  • a hung required preparation is stopped at its hang bound and charged alone while the sibling is prepared in the same warm; a slow preparation that keeps writing is never stopped
  • deterministic isolation with a draining sibling; a lock never isolates; an IntegrityError page emits page_refused
  • unmeasured spend refuses the pass; one test per hu24g site; a zero-session file is EXCLUDED
  • a population larger than a page materializes completely; an empty-string block id keys the keyset as COALESCE does
  • the overlay keeps the build ETA; the status frame names a root without a generation

Self-review

A full read of the PR diff against master after the merges. Each item says how it applied.

  • Cancellation and shutdown in every loop. _warm_until checks cancelled on every poll, and the hang reaper runs inside that loop. It never waits itself: it stats attempt directories and restarts the pool. After _closing, pool-death attribution returns the shutdown deferral and does not restart the pool. After an unverified stop (_cleanup_blocked), it charges nothing. That second case fixes a finding: a later collection of the same break would otherwise have charged a sibling a second time.
  • Unbounded reads and state. The hang signal is one scandir per running required path per poll. _path_worker_losses and _path_solo_suspects grow only with distinct files that lost a worker. They are cleared when a worker comes back from a file, and they are not pruned for files that are never seen again (see Residuals).
  • Fail-open fallbacks. A loss with no submission observation is deferred, not charged: it cannot be bound to a revision. An escalated failure applies only while the file's (size, mtime_ns, inode) is unchanged.
  • Sibling sites of each defect class. The per-path bookkeeping (future, observation, progress, attempt directory, in-flight bytes) is released in one helper, _release_slot. Collection, pool restart and thread-orphan reaping all use it. That removed the parallel _path_sizes and _path_started dicts, each of which every release site had to remember. A streak ends at every site where a worker comes back from a file: a collected success, a collected exception, and a success the restart preserved. Two sibling defects were found and fixed. DelegationPageKey.after_row used or, so an empty-string block id keyed on the child session id, a position the SQL COALESCE order never has; it now coalesces NULL only, with a test. pop_path's changed-source branches were checked against fix(intake): one interpretation across live and retained routes #5643's _discard_retained_path. A failed result never carries retained members, so the new failed_observation branch needs no discard.
  • Master's new FAILED site. Master added a FAILED outcome at the post-publication requiredness recheck (requiredness inspection: {exc}). Like this branch's other exception-backed FAILED sites, it now names the exception type and carries transient, with a test.
  • Compatibility shims. One was found and removed. The adapter kept select_ingest_candidates as a fallback beside the new classify_ingest_candidates, and LiveWatcher.select_ingest_candidates had become a wrapper. Classification is now the only selection route. Fakes, docs/daemon.md and the excluded-cursor proof receipt name it.
  • Tests prove the production route. The worker-loss tests run real process pools through warm_paths/pop_path. The worker helper is wrapped by the production _run_holding_attempt, so the markers are the production ones rather than test-written. The hang test runs a warm on a thread with a join bound, so a missing reaper fails instead of hanging. A slow worker whose attempt directory keeps growing proves the bound measures lack of progress, not time since submission. The scheduled-retry split had no test; it now has a watcher test (pending vs. settled exclusion) and an adapter test (DEFERRED, actual_cost 0, never DUPLICATE).

Residuals

  • _path_worker_losses and _path_solo_suspects are cleared when a worker comes back from a file, but they are not pruned for a file that never returns. They are bounded by the distinct files that lost a worker during one daemon's life.

  • A worker lost under a retained-member preparation (fix(intake): one interpretation across live and retained routes #5643 runs those on the same pool during reconciliation) restarts the pool without attribution, so such a loss is never charged. It errs toward under-charging, never toward a false charge.

  • 7c5k6 "visible in status": escalation reaches the cursor quarantine through the writer's generic parse-failure path (batch.py per-record except Exception → mark_raw_parse_failed). I confirmed this by reading the source; no end-to-end quarantine test drives a killer file through five cursor failures.

  • The hu24g optional ratchet (a devtools pattern rule for broad excepts) is not included.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@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: c27787c08d

ℹ️ 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/daemon/intake.py Resolved
Comment thread polylogue/daemon/intake.py Resolved
@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:19:27.101285Z afbbaf6 New commits
ℹ️ 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.

@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 14:20

@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: cfcb45fa89

ℹ️ 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/daemon/intake.py Resolved
Comment thread polylogue/operations/intake_adapters.py Resolved

@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: be22f38112

ℹ️ 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/operations/intake_adapters.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
@Sinity
Sinity force-pushed the claude/reliability2 branch from be22f38 to 6ffe238 Compare September 28, 2026 15:05

@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: 6ffe23847e

ℹ️ 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/daemon/intake.py Resolved
Comment thread polylogue/daemon/status_snapshot.py Resolved
@Sinity
Sinity disabled auto-merge September 28, 2026 15:26

@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: 557670962c

ℹ️ 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/operations/intake_adapters.py Resolved
Comment thread polylogue/daemon/intake.py Resolved

@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: bd270c461a

ℹ️ 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/batch.py Resolved
Comment thread polylogue/sources/dispatch.py Resolved
Comment thread polylogue/daemon/intake.py Resolved
Squash of the reliability2 branch onto current master: worker-death
attribution per held task with solo retries, revision-bound intake
isolation and failure streaks, keyset and text-byte-bounded delegation
pages, no-session accounting as a typed exclusion, derivation failure
transience, and sanitized census validation logging.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity
Sinity force-pushed the claude/reliability2 branch from bd270c4 to 3bf67ed Compare September 28, 2026 21:02

@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: 3bf67ed3dd

ℹ️ 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/daemon/derivation.py Resolved
A failed key's reason now leads with its phase and exception type, so the
dispatcher's failure signature tells a KeyError from a TypeError in the
same phase and alternating defects do not extend one exhaustion streak.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@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: 26dba7c242

ℹ️ 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/daemon/derivation.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
The per-key inspection fallback classifies its exception and names its
type in the reason. A worker that returns or raises alive ends its loss
streak. index.db gains an expression index matching the query_delegations
order, so a keyset page seeks instead of sorting a parent's cohort. The
no-session attempt disposition now requires that every offered path was a
no-session exclusion and that the time budget left nothing unattempted.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity and others added 5 commits September 29, 2026 04:13
#5691 rewrote the live parse stage around worker read-ahead, pool
restarts, and preemption. The worker-death and hang handling from this
branch is re-implemented on that model: per-file attribution by attempt
markers, solo suspects, and escalation after repeated losses on an
unchanged observation. The submission-time deadline reaper is replaced
by a per-path no-progress hang bound that stops workers through the
same pool restart that reaps read-ahead. daemon/cli.py takes master's
_derivation_admission and keeps the failed outcome's transient flag.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The adapter kept select_ingest_candidates beside the new
classify_ingest_candidates, and LiveWatcher kept select as a wrapper.
Classification is now the one selection route: the wrapper and the
adapter's select branch are removed, and fakes, docs and the proof
receipt name classify. A scheduled retry that is not yet due is covered
by a watcher test and an adapter test (DEFERRED, never DUPLICATE).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
DelegationPageKey used `or`, so an empty-string instruction block id
keyed on the child session id, a position the SQL COALESCE order never
had. A pool break seen again after an unverified stop is no longer
attributed a second time.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…ity2

Master added a FAILED outcome at the post-publication requiredness
recheck. Like every other exception-backed FAILED outcome in this
branch, it now names the exception type first and carries
transient=_is_transient_failure(exc), with a test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Sinity
Sinity merged commit b7cb9bd into master Sep 29, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the claude/reliability2 branch September 29, 2026 04:57
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