Skip to content

Cover native refresh liveness and yield CTV to newer tips - #433

Merged
Anatolie merged 5 commits into
3.x.xfrom
refresh-liveness-coverage
Sep 16, 2026
Merged

Anatolie merged 5 commits into
3.x.xfrom
refresh-liveness-coverage

Conversation

@Anatolie

@Anatolie Anatolie commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Closes #375.

Adds 18 native PostgreSQL regression tests for refresh liveness through public coordinator, ledger, broadcaster, and real Stratum socket APIs:

  • Disconnect the first session at six deterministic refresh boundaries, with both empty and populated payout windows. Remaining miners receive current work with their own identity and entropy, submit durable shares, and a replacement session reuses the publication. A separate case disconnects every session before refreshing to a new tip.
  • Hold a CTV chunk completion while a newer tip is pending or already published. The current pass stops at the chunk boundary, remaining rows finish on a later pass, and same-tip refreshes do not starve settlement.
  • Hold the first startup candidate claim inside its database transaction. A newly connected miner still gets work and a durable share acknowledgment; releasing the barrier lets the claim progress.

The native broadcaster previously yielded only to Tokio, with no tip-priority check or CTV chunk metrics. It now uses the existing observed/published tip state to defer subsequent claims, and records unlabeled yield, chunk-row, and chunk-duration metrics with fixed bucket storage. Existing candidate and share persistence rules are unchanged.

All new tests are registered in test/prism-gated-tests.txt; Cargo target discovery includes the suite in native PostgreSQL CI. Fixture barriers and SQL changes operate only in disposable test databases. No schema migration or deployment changes.

Validation:

  • 52 tests passed across refresh_liveness, compact_runtime_e2e, and observability using local PostgreSQL 16; the targeted execution manifest verified all 32 gated tests in those suites.
  • 4 metrics allocation tests and 13 existing tip observation/publication lease tests passed.
  • With the database input removed and GITHUB_JOB=prism-native-postgres, all 16 new gated tests failed rather than skipping.
  • Clippy with warnings denied, workspace formatting, gate-input lint, generated metrics inventory, CI shard discovery, and diff checks passed.

Commit author: Anatolie [email protected].

Review follow-ups (Codex):

  • e92ae20 bounds the unpublished-tip CTV yield by the replacement-build budget (PRISM_TEMPLATE_REFRESH_FAILURE_EXIT_SECONDS, default 120) from the first departure, so a refresh that keeps failing before publication cannot strand settlement; documented in docs/prism-ledger-ops.md.
  • 3a651ad records the CTV chunk metrics before propagating a completion persistence failure, so every claimed attempt is counted once.
  • Both add a gated refresh_liveness test that fails against the previous code; the suite (21 tests), coordinator unit tests, clippy and fmt pass locally on PostgreSQL 16.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@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: 5331e8bf85

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 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-16T19:33:28.165456Z 1784f13 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.

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

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

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

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

Anatolie and others added 5 commits September 16, 2026 15:27
A refresh that observes a newer tip and then keeps failing before
publication (template fetch, fee validation, prepared-work persistence)
left the observed tip permanently different from the published one, so
every broadcaster pass exited at its first fanout boundary and settlement
was stranded for the whole outage even though its own chain checks could
succeed.

The yield for an unpublished tip now lasts at most the replacement-build
budget (PRISM_TEMPLATE_REFRESH_FAILURE_EXIT_SECONDS, default 120) from the
first departure, the same bound the published-tip lease already uses;
failed refreshes and newer tips do not renew it, and a zero budget
disables the yield like the lease. An unpublished startup tip anchors the
same budget so the first publication cannot strand settlement either. The
pass-tip mismatch yield is unchanged: it ends with the pass.

The new gated test breaks every template fetch after a tip change: a
frontend inside its budget yields, and one whose budget elapsed settles
every remaining row on its next pass. Without the bound the second half
fails with "settlement stayed stranded".

Co-Authored-By: Claude Fable 5.1 <[email protected]>
When a claimed fanout attempt succeeded but persisting its completion
failed, the early return skipped the chunk-row and chunk-duration
observations, so the new telemetry undercounted attempts exactly during
persistence incidents while the failed-attempt branch still counted its
own completion failures.

The pass now observes the chunk after either completion path and then
propagates a completion failure, so every claimed attempt is counted once.
The gated test severs the completion write after it executes: the pass
ends with the error, the attempt is counted, its claim stays fenced and a
later pass finishes the other rows. Without the fix the test fails with
"chunk rows missed the attempt".

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The pass-tip mismatch yield compared the last tip observation with the
tip the pass had just read from the node, regardless of when that
observation was recorded. When the node advanced before any refresh or
block notification observed it, every pass read the newer tip while the
observation still named the published one, so each pass yielded at its
first fanout boundary. Unlike the unpublished-tip yield, this mismatch
had no budget: settlement stayed stranded until a blocked or absent
refresh caught up with the node.

The pass now records when it began and yields only to an observation
recorded after that instant that differs from the pass tip, including a
replacement that already published. An observation older than the pass
is stale evidence, not a newer tip, so the mismatch yield is bounded by
the pass as its comment already claimed. The unpublished-tip yield keeps
its replacement-build budget.

The new gated test advances the node without any observer and expects
the pass to settle every row; on the previous commit it fails with
"0 of 5 rows". A unit test pins the observation-order semantics.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The native chunk-row histogram keeps the 2.x.x name and type but counts
rows with a single finite bound of 1, while the metric inventory and the
histogram consumer guide still said every event histogram measures
elapsed seconds on the default time ladder and that only the share ACK
histogram differs. A consumer following those documents would query
`le` series that the native exposition never emits, or read the row
count as seconds. Both documents also still counted the pre-branch coordinator
family total after this branch added three.

The compatibility annotations now describe the row unit, the `le="1"`
and `+Inf` bounds, the `_sum` equals `_count` identity and the retired
2.x.x ladder, so the generated inventory row carries them; the consumer
guide gains a section on reading the family and the family count is 46.
A comment beside the bucket arm points at the guide. No exposition
changes; the generator drift check and the four inventory tests pass.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Anatolie
Anatolie force-pushed the refresh-liveness-coverage branch from 9b1e433 to 1784f13 Compare September 16, 2026 19:29
@Anatolie
Anatolie merged commit 1865dd7 into 3.x.x Sep 16, 2026
20 checks passed
Anatolie added a commit that referenced this pull request Sep 18, 2026
29 of the map's 34 issue links pointed at closed issues, and every open
gap row named one, so by the map's own legend each gap was either filled
or orphaned and the map did not say which (#448). The pull requests that
closed #266, #271, #272, #280, #285, #287 and #288 never touched it.

Every row that linked a closed issue now names the native tests that
landed, retires what has no native subject with the reason, and writes
what is still uncovered as "not covered, no open issue". No row links a
closed issue. The five open gap rows and the open gap case are partial.

tests/test_prism_landing_interleavings.py is decided: partial with
nothing left uncovered, and no new native test. The issue's premise that
no native test has the two-distinct-block shape does not hold. #355 added
three tests for exactly that #272 criterion which the map never cited, a
checks each block's audit row, and the #133 mechanism (a shared
publication floor gating a per-block evidence file written after
confirmation) has no native counterpart: the audit row is inserted, keyed
by block hash, in the landing transaction.

The seven needs triage rows were re-read at a193705. Two are now partial
(the CTV yield contract from #433, the changed-amount balance fence from

it from a needs triage row, and the new closed-issue check failed on the
next run. That row was re-read at cb2aa8b: #450 covers its one owned
case (no hash or height in /metrics), and it stays needs triage because
landing-phase attribution still has no native family and no owner.

Also corrected, because they made the same claim in plain text or were
stale for the same pull requests: the job-builder, #224 cadence, #224
ledger, representative-independence and coordinator-metrics rows. The legend now
says a linked issue must be open and a plain #N is history, and a new
section documents the checks.

Summary: 5 full, 76 partial, 0 open gap, 5 needs triage, 56 retired.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 21, 2026
…eck that keeps it honest (#455)

* ci: check the deleted-test map against the tree and against issue state

docs/prism-deleted-test-map.md is parity evidence for the cutover go/no-go
(#291), and nothing read it: the issues it linked closed one by one while
the map kept naming them as the owners of uncovered behaviour (#448).

scripts/check_deleted_test_map.py reads it. Offline, in the required
lint-compile-compose job, it fails when a `path::name` reference does not
resolve to a test function, when a table line does not parse (a line it
cannot read is an error, never a skipped row), when a status breaks the
legend, or when the summary, the section counts or the needs triage index
differ from the rows.

With --check-issues it asks GitHub for the state of every issue the map
depends on and fails when one is closed. That runs as an advisory job kept
out of `checks`, so an issue closing cannot block an unrelated pull
request, and it can still go red. It lives in ci.yml because schedule and
workflow_dispatch only fire from the default branch and this map lives on
3.x.x. An unknown state (network, rate limit, unexpected reply) exits 2
and is never read as open.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs: reconcile the deleted-test map with the issues that closed

29 of the map's 34 issue links pointed at closed issues, and every open
gap row named one, so by the map's own legend each gap was either filled
or orphaned and the map did not say which (#448). The pull requests that
closed #266, #271, #272, #280, #285, #287 and #288 never touched it.

Every row that linked a closed issue now names the native tests that
landed, retires what has no native subject with the reason, and writes
what is still uncovered as "not covered, no open issue". No row links a
closed issue. The five open gap rows and the open gap case are partial.

tests/test_prism_landing_interleavings.py is decided: partial with
nothing left uncovered, and no new native test. The issue's premise that
no native test has the two-distinct-block shape does not hold. #355 added
three tests for exactly that #272 criterion which the map never cited, a
checks each block's audit row, and the #133 mechanism (a shared
publication floor gating a per-block evidence file written after
confirmation) has no native counterpart: the audit row is inserted, keyed
by block hash, in the landing transaction.

The seven needs triage rows were re-read at a193705. Two are now partial
(the CTV yield contract from #433, the changed-amount balance fence from

it from a needs triage row, and the new closed-issue check failed on the
next run. That row was re-read at cb2aa8b: #450 covers its one owned
case (no hash or height in /metrics), and it stays needs triage because
landing-phase attribution still has no native family and no owner.

Also corrected, because they made the same claim in plain text or were
stale for the same pull requests: the job-builder, #224 cadence, #224
ledger, representative-independence and coordinator-metrics rows. The legend now
says a linked issue must be open and a plain #N is history, and a new
section documents the checks.

Summary: 5 full, 76 partial, 0 open gap, 5 needs triage, 56 retired.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs: correct the map's new citations after an adversarial review

Five reviewers who had not written the reconciled rows read the body of
every newly cited test, 152 citations in all, and tried to break each
claim. 142 held, 10 were overstated, none was unsupported, and five
"retired" clauses named something that still exists natively. The
corrections all move the map toward claiming less:

- test_prism_hot_path.py: the 600-client submit burst is not retired.
  Native submits read-lock what publication write-locks and no test
  bounds the wait, so it is now "not covered, no open issue".
- prism_postgres_a1_migration_gate.py: the pre-ordinal backfill and the
  non-positive and duplicate ordinal refusals are not retired. 001 still
  runs them under the native migrator, which does not refuse a
  pre-v2.0.0 source.
- test_prism_settlement_balance_comparison.py: a re-spelled payout
  address is a digest divergence natively, the opposite of what the row
  said, and is untested.
- test_prism_share_ledger.py: "no automatic SQL retry" had one exception,
  the share append re-run after a no-partition refusal, which has a test.
- The representative-independence and CTV rows called live things
  retired (per-solver bootstrap identity, PRISM_CTV_BROADCASTER_LIMIT);
  the validation, delivery, retained-jobs, landing, reward-window,
  compose and perf rows each had a clause worded past what its test
  asserts.

Two under-claims are fixed too: the TipState::observe sequence guard is
tested, and the reward-window row now cites the test that pins 8.

The landing-interleavings decision was attacked directly and held.
Statuses and summary counts are unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix: validate deleted-test names against pinned manifest

* fix: pin deleted-test case inventory

* fix: require test citations in partial map rows

* fix: include unowned partial gaps in map summary

* fix: require Python map citations in unittest discovery

* fix: exclude empty native remainders from map summary

* fix: include open case rows in deleted-test summary

* fix: ignore Rust fixture text in test citations

* fix: reject Rust map citations to tests skipped by CI

* fix: reject skipped Python parity citations

* fix: require reachable Cargo tests for parity citations

* fix: recognize uncovered markers without semicolon separators

* docs: reconcile deleted-test owners after issue 270 closed

* fix: require successful runs for Python parity citations

* fix: reject malformed deleted-test owner links

* fix: include case rows in the triage index check

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
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