Skip to content

3.x.x: answer 404, not 500, for a public artifact whose legacy body is not on the host yet (#735) - #796

Merged
kiwidream merged 4 commits into
3.x.xfrom
orca/735-artifact-fallback-404
Oct 28, 2026
Merged

kiwidream merged 4 commits into
3.x.xfrom
orca/735-artifact-fallback-404

Conversation

@kiwidream

@kiwidream kiwidream commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #735. /public/v1/artifacts/<sha> answered 500 for every legacy-body failure, including an audit whose legacy body import-audits has not stored yet and that is not on the serving host.

What changes

  • Typed reason for each failure. The legacy body reader reports absent (the body file, or a share segment its envelope names, is not on the host), a fault (unreadable, not JSON, an unsupported URI scheme, a failed envelope verification or digest check), or internal. bundle_with returns a typed BundleError { Absent, Other }, and only a proven absence reaches /public/v1/artifacts as a 404, with no-store and no CDN or immutable headers. Every fault stays a 500, logged at warn with the block, artifact sha and body URI. Read timeouts are unchanged.
  • Content-address check. The artifact routes check that the re-read row still advertises the requested address. A row re-imported between the lookup and the read answers 404 unknown public PRISM artifact instead of serving another audit's body.
  • file:// segments. qbit_prism::resolve_body_uri strips file:// for share segments, so the API, import-audits and the audit CLIs resolve them correctly.
  • Unchanged: the block audit views keep their exact 404s and messages. The settlement-artifacts link check makes the same decision as before.
  • Docs and spec: the README, the migration doc and the OpenAPI 404 (which now declares Cache-Control: no-store and lists its messages) are updated.

Tests

  • New gated api_2x tests cover the absent body and absent segment (uncached 404), each fault class (500), a body that arrives later, the audit views' messages, the log events at each step, and a re-import race under a held lock. Lib unit tests cover the typed fallback, the scheme rule and file:// resolution. Each fails without its fix.
  • api_2x, api_database, artifact_admission, api_contract, the ledger_postgres legacy-artifact subset, migration_rollback frozen 2.x import, lib api::, and the qbit-prism lib and audit tests all pass. fmt, clippy and the guards pass.
  • Two independent adversarial rounds, 12 mutations in all, every one caught.

Final round (4ad2e77)

  • The stored-canonical-bytes path refuses a row re-imported under a new address with a typed AuditReaddressed before any decode, so the old address answers 404 instead of serving the new bytes with the old ETag.
  • The bundle's second canonical read gets the same check, so that race answers 404 instead of a digest-mismatch 500.
  • A non-file:// segment scheme is a fault (500). file://localhost/<path> resolves to /<path>.
  • Logging: link-check faults log at debug again, and audit-view absences are silent as before.
  • The race test now waits on lock state, not query text, and covers three interleavings. Each fix has a mutation that the tests catch.

Out of scope: alerting on a missing audit volume, which needs a reason-labelled counter.

🤖 Generated with Claude Code

kiwidream and others added 4 commits October 27, 2026 16:29
…s not on the host yet (#735)

`/public/v1/artifacts/<sha>` turned every legacy-body failure into a 500,
including a body that `import-audits` has not stored and that is not on
that host. The legacy body reader now says why it failed: absent (the body
file, or a share segment its envelope names, is not there), a fault (there
but unreadable, not JSON, failing verification or its digest, which
includes 2.x v2 bodies until #731), or internal. The artifact routes answer
absence with a no-store 404 and keep every fault at 500, logged with its
reason; read timeouts are unchanged. The block's audit views keep their
404s and messages.

Errors were already never cached (no-store, no CDN headers, the origin
cache stores successes only); the new test pins that for the 404, checks
the 5xx count sees only faults, and serves the body as soon as it arrives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The settlement-artifacts route asks `artifact()` whether a legacy body is
servable before linking it, so a faulty body logged the artifact route's
warn on every settlement compute without serving a 500. Who reads a legacy
body is now a `BodyReader`: the audit views (404s, no logs, as before),
`/public/v1/artifacts/<sha>` (a 500 logged at warn, an absent body at
debug) and the link check (both at debug). Each event names the block, the
artifact sha256 and the recorded body URI, in the server log only.

The test now covers an envelope that proves itself but is another audit's
body (500, "audit bundle body hash mismatch"), asserts the reader's log
events at every step (warn per served fault, debug for absence and for the
link check, nothing from the audit view), and labels each step. The
OpenAPI 404 declares `Cache-Control: no-store`, and the docs name a missing
share segment and the `unknown PRISM block` race as 404s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… content address (#735)

A bundle read now fails with a `BundleError`: `Absent` for a proven
absence (the legacy body or a share segment is not at its recorded
location, or the row went away between lookup and read), `Other` for
anything else. The artifact routes let only `Absent` through as a 404,
whatever code another error carries; a read timeout keeps its 503.

An artifact read now checks that the row it reads by block still answers
the address it was found by, so a row re-imported in between is the
unknown-artifact 404 instead of another audit's body under the old
address. A body URI with a scheme other than `file://` is a fault (500,
warn), not a permanent 404, and `qbit_prism` resolves a `file://` share
segment to its local path for every reader, the import included; every
segment is digest-checked, so only the path changes.

The reader's arms are merged: the audit views answer and log absence like
the other readers, and the link check logs no fault. The docs say that a
2.x v2 body whose segments are missing is a 404 like any absent body.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…efuse segments in other stores (#735)

`audit_canonical_bytes_admitted` takes the artifact address the row was
found by and refuses a row that no longer advertises it with
`AuditReaddressed`, before any work proportional to the window. The public
route answers that with the unknown-artifact 404, so a re-import between
the lookup and the stored-bytes read can no longer serve the new bytes as
an immutable response under the old address. The bundle read's second
query, for bytes stored after its first, checks the address the same way
instead of failing the old digest with a 500. The race test now covers
all three reads.

`qbit_prism` refuses a share segment URI with a scheme other than
`file://` (a fault, for the API, the import and the CLIs alike) and
resolves `file://localhost/<path>` to the absolute path. The link check
logs its faults at debug again, and the audit views log nothing, as
before. The docs list the re-import 404.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 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-10-28T17:29:59.552773Z 4ad2e77 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.

@qbit-reviewer qbit-reviewer 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.

No findings.

@qbit-reviewer qbit-reviewer 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.

No findings.

@kiwidream

Copy link
Copy Markdown
Member Author

Closing and reopening to re-run CI (this token can't re-run workflows). Shard 1's only failure was coordinator::miner_submit::acquire_tests::block_only_poll_missing_and_sql_error_stay_unknown, the known 3.x.x flake in that test group (it also failed on 3.x.x's push CI, run 40726591893). A fix is in progress in its own PR.

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