Skip to content

feat(application): expose staff report receipts for host evidence binding - #15

Merged
FlyOverCoderKY merged 5 commits into
mainfrom
claude/staff-report-receipt-20261112
Nov 12, 2026
Merged

FlyOverCoderKY merged 5 commits into
mainfrom
claude/staff-report-receipt-20261112

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Change

Expose the canonical report receipt in the existing staff-authorized KnowledgeReportView. Hosts can bind staff-confirmed agent test reports to Support Desk successful-test evidence using the public report snapshot. The receipt is computed by the existing acknowledgement helper.

Existing report read permissions, submitter-bound verifier/status behavior, confirmation states, revocation handling and MCP scopes remain enforced. No collection, schema or role is added.

Prepare the synchronized 0.1.7 candidate metadata, MCP identity and upgrade notes. Publication follows review, CI and the exact-artifact release process.

Validation

  • The receipt regression suite passed all 66 MemoryStore cases on Node 22 and 24 before combining metadata.
  • A selected real D1 case passed against both this source and the unchanged 0.1.6 baseline. The earlier full local backend run was stopped without a verdict and is retained as incomplete.
  • Required formatting, types, full tests including release regressions, example, packed artifacts and authenticated protocol proof run on both Node versions in CI for this commit.
  • Additional local candidate packing and protocol checks are in progress.

The Support Desk host evidence bridge remains separate host work. Customer activation follows the approved acceptance plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-12T15:46:54.524410Z 08eca20 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.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (clean). #15 (review)

@github-actions github-actions 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.

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 08eca209365ce7e583059228a0e3dc42db2b6954
Judge: openai/gpt-5.6-luna
Cost: $0.3533 (lanes $0.3504 + judge $0.0028)

Lanes

  • openai/gpt-6.1-sol: ok (2 finding(s), 108.2s, 290518+3892 tokens (233347 cached), 7 tool round(s), via Azure, $0.23)
  • z-ai/glm-5.3-flash: ok (3 finding(s), 216.0s, 2463407+25212 tokens (2266880 cached), 45 tool round(s), via Particle AI, $0.12)

Warning

z-ai/glm-5.3-flash: coverage claims 1 finding(s) in 'packages/application/README.md' but 0 were reported

Warning

z-ai/glm-5.3-flash: coverage claims 1 finding(s) in 'packages/mcp/README.md' but 0 were reported

Findings

🔵 Issue 1 — Conflicting current-release guidance

docs/RELEASING.md:112 · nit · identified by openai/gpt-6.1-sol

A host choosing a qualified dependency graph receives conflicting instructions: the new candidate section identifies 0.1.6 as the current qualified release, while other live guidance still identifies 0.1.5 or calls 0.1.6 unpublished.

Affected guidance includes:

  • docs/RELEASING.md:44–70, which still calls 0.1.5 the current verified and qualified KB release.
  • docs/BOOTSTRAP.md:9–10, whose current-state section still selects 0.1.5.
  • docs/AGENT_API.md:282, which still labels the metadata-compatible 0.1.6 release an unpublished candidate.

I checked these sections against the new verified-release section and the package READMEs. Update the live status descriptions consistently while preserving historical receipt anchors, identities, and artifact records.

🔵 Issue 2 — Artifact-inaccessible upgrade-note link

packages/mcp/README.md:29 · nit · identified by openai/gpt-6.1-sol

A consumer reading the installed MCP package's README cannot follow the new upgrade-note link: ../application/README.md points to a nonexistent sibling package rather than @​pegma/knowledge-base-application.

The relative path works in the source checkout, but the published layout is node_modules/@​pegma/knowledge-base-mcp alongside node_modules/@​pegma/knowledge-base-application. The MCP tarball does not contain the repository's packages/application directory. Use an absolute repository or release-versioned URL for this public upgrade note.

I checked both package manifests and the surrounding MCP README links, which already use absolute versioned GitHub URLs for cross-package documentation.

🟠 Issue 3 — New "Verified 0.1.6 release" claim contradicts the repository's own release ledgers

docs/RELEASING.md:88 · risk · identified by z-ai/glm-5.3-flash

A releaser or host consuming the repo's canonical release records cannot tell whether 0.1.6 is published. If they follow the ledgers, they conclude 0.1.5 is the current qualified release and adopt/publish against it while the new section asserts 0.1.6 is verified; if 0.1.6 publication has not actually completed (the PR body says "Publication follows review, CI and the exact-artifact release process"), then RELEASING.md now asserts a completed trusted publication with a concrete tag link that does not exist — in a repository that explicitly treats release receipts as contracts ("Existing release receipts remain historical contracts").

Contradicting evidence found in the current checkout:

  • docs/RELEASING.md:44-49 (unchanged by this PR) still states "The current verified release is 0.1.5 … at signed source 6dae20df…", and line 69 still states "The qualified release versions are KB 0.1.5 and Agent Access 0.1.1" — directly above the new section that says "The current qualified release remains 0.1.6" (line 112).
  • README.md:15-32, the repository's release-status banner that records every verified publication from 0.1.0 through 0.1.5, has no 0.1.6 entry.
  • docs/AGENT_API.md:282 still describes "The unpublished 0.1.6 source candidate", contradicting the new "verified" claim in the same docs tree.
  • docs/releases/ contains only v0.1.5/ receipt artifacts and docs/BOOTSTRAP.md contains no 0.1.6 record (searched), although prior verified releases each retained a receipt.
  • packages/mcp/README.md:9-14 still says all four packages are "verified published at 0.1.5" immediately above the edited paragraph that now says the 0.1.6 release is verified.

Whichever side is true, one set of statements is wrong and must be reconciled (either record the 0.1.6 receipt everywhere the ledger requires it, or restore the "unpublished candidate" wording until publication completes).

🔵 Issue 4 — Staff "check its revocation" wording omits that the verifier is submitter-bound

docs/RELEASING.md:106 · nit · identified by z-ai/glm-5.3-flash

A host that implements the documented staff workflow literally — checking a report receipt's revocation by calling reports.verifier.verify with a staff AccessContext — will get null for every receipt, because the verifier returns null unless request.access.principalId === report.submittedBy (packages/application/src/evidence-reports.ts, verify). The revocation check is only reachable in-component by the submitting agent; a staff-side revocation check would have to be host work comparing against getEvidence revocation history, which neither doc says.

Affected wording instances:

  • docs/RELEASING.md:106-108: "Authorized staff workflows can associate Support test results with the exact report receipt and check its revocation when another authorized staff member recorded the decision."
  • packages/application/README.md:205-207: same sentence.

Both sentences sit next to "The existing verifier and owner-only status behavior remain unchanged", so the constraint is stated only negatively. Suggest naming the actual port for the staff-side revocation check, or rewording to say the receipt enables the submitter-driven check.

I checked docs/EVIDENCE_REPORTS.md (which does say "The verifier rechecks the submitting identity") and the verify implementation; the failure is a mis-integration cost, not a security hole.

🔵 Issue 5 — read exposes the new binding receipt without the final report-row re-observation that status and query apply

packages/application/src/evidence-reports.ts:1528 · nit · identified by z-ai/glm-5.3-flash

A staff member reads the view, and concurrently a second reviewer reassesses the report (decide with "pending"), which rotates receiptGeneration. The returned view carries the now-retired receipt cycle as the newly designated Support Desk binding handle; a host persisting it fails closed later at submitEvidence/verify (receipt-generation mismatch). A concurrent ledger reset is fenced (the second active() call), but a report-row change is not.

read (evidence-reports.ts:1528-1564) loads the report once and, after the awaited context/staff reads, re-checks only the ledger head. By contrast status (:1458-1484) reloads the report and compares reportGeneration/receiptGeneration/status/reportHash before disclosure, and query re-reads with a version comparison — so read is now the only report-disclosing operation without a finite final observation. The staleness exposure itself is pre-existing for the other view fields; what is new is that this PR promotes the receipt into a durable cross-system binding handle (PR body, RELEASING.md and the application upgrade note all describe binding it), and the docs call it "the canonical acknowledgement receipt" without noting the unfenced window.

Suggest either adding the same finite final observation to read or documenting that a receipt read must be re-confirmed before it is recorded as evidence binding. I checked that the new tests pin receipt equality only within a quiesced ledger; no test exercises a concurrent reassessment against read.

Workflow run

Comment thread docs/RELEASING.md Resolved
Comment thread packages/mcp/README.md Resolved
Comment thread docs/RELEASING.md Resolved
Comment thread docs/RELEASING.md Resolved
@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed the threadless report-read finding in 61dcaaf.

Staff read now captures the existing observedReport row/version and performs one closing versioned observation after the context, staff and active-ledger awaits. Changed rows return the existing report_changed error. Actual reassessment races reproduce stale receipts against the sealed predecessor package, and both Node versions pass all 70 MemoryStore report cases with the fix, plus types and formatting.

The four documentation threads are fixed and resolved. Fresh review and the ordinary full backend CI lanes are running for this commit.

@github-actions github-actions 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.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 61dcaaf19f7a0db644709aef8f52a826f3c1b34d
Judge: openai/gpt-5.6-luna
Cost: $0.1501 (lanes $0.1473 + judge $0.0028)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 32.7s, 82703+972 tokens (57179 cached), 4 tool round(s), via Azure, $0.0872)
  • z-ai/glm-5.3-flash: ok (3 finding(s), 470.1s, 792274+48547 tokens (691328 cached), 14 tool round(s), via Crusoe, $0.0602)

Round 2 resolution

  • ✅ r1-3 fixed correctly — New "Verified 0.1.6 release" claim contradicts the repository's own release ledgers: The canonical release records now agree: docs/BOOTSTRAP.md identifies 0.1.6 as the current verified release and records its verification timestamp, signed source, tag object, original artifact and manifest digests, writer attempts, and verification-job links. docs/RELEASING.md, the root README, and package release summaries consistently distinguish verified 0.1.6 from unpublished candidate…
  • 4 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 3 (0 bug-severity).

Findings

🟠 Issue 1 — Sibling docs still present the 0.1.5 receipt as "current" after 0.1.5 was re-designated historical

docs/AGENT_WORKFLOW.md:13 · risk · identified by z-ai/glm-5.3-flash

This commit makes docs/BOOTSTRAP.md record 0.1.6 as the current verified release and renames the 0.1.5 section to "Historical verified 0.1.5 release" (preserving the current-verified-015-release anchor), but it synced only AGENTS.md, README.md, docs/AGENT_API.md, docs/RELEASING.md and the four package READMEs. Nine other files still call the 0.1.5 receipt "current" and never mention 0.1.6 at all, so a releaser or host consulting them concludes 0.1.5 is the current qualified release and adopts or publishes against it — the same ledger-vs-docs adoption mismatch that r1-3 described, now inverted by the re-designation.

The preserved anchor means these links still resolve, so they read as current-release guidance rather than broken links:

Evidence of the new canonical state: docs/BOOTSTRAP.md:91 ("Current verified 0.1.6 release") and :117 ("Historical verified 0.1.5 release"), AGENTS.md:36, README.md:31, and docs/RELEASING.md:69 ("The qualified release versions are KB 0.1.6"). The commit's own edits to the sibling files (e.g. README.md's "retained 0.1.5 receipt" relabel plus a "current 0.1.6 receipt" sentence) show the intended convention; these files were missed and need the same relabel/0.1.6 sentence.

Checked: grepped every current-verified-015-release and current-verified-016-release reference repo-wide and read each surrounding context; 0.1.6 appears in none of the listed files, and no stale "unpublished 0.1.6" wording remains anywhere.

🟠 Issue 2 — Staff receipt read's re-observation runs after the last epoch fence, so a concurrent reset can still return a retired receipt

packages/application/src/evidence-reports.ts:1554 · risk · identified by z-ai/glm-5.3-flash

Scenario: a staff read is in flight while another staff member runs reset. If the reset commits in the gap between the read's final await active(articleId, epoch) and the newly added await observedReport(...), the read still returns the KnowledgeReportView with its receipt for the epoch-E report even though the ledger has already advanced to epoch E+1/resetting — i.e. it discloses exactly the "retired receipt binding" the new in-code comment says must not happen, and it contradicts docs/RELEASING.md's "The read refuses observed concurrent report or ledger changes before returning the view."

Mechanism: reset writes only the head row (single records.transact put at packages/application/src/evidence-reports.ts:1728); old-epoch report rows keep their stored versions until drain deletes them. The new fence latest.version !== observed.version therefore cannot detect a reset — the report row's version is unchanged. The reset is caught only by the active(articleId, epoch) call that runs before the re-observation; after that call resolves, the new code inserts an await (observedReport), and a reset interleaving in that window is never re-checked. In the parent commit the function returned synchronously immediately after that final active, so a reset either committed before it (ledger_epoch_changed) or after the response was complete; the new await re-opens the disclosure window. A concurrent drain in the same gap instead surfaces as report_not_found from the re-read rather than ledger_epoch_changed.

The correct pattern already exists in this file: query (lines ~1325-1355) finishes with a keyed-read wave that re-observes head and report together and checks ledgerEpoch, head version and report version before its synchronous return. The new read fence checks only the report row, so it does not reach even that bound.

Checked: reset/drain implementations (reset touches only the head; rows are deleted only by drain), active/headVersion (head read plus epoch/status throws), the new tests (both gate inside context via hooks.afterContext, i.e. before the final active, so the tested interleavings are fenced; no existing hook can gate between the final active and the re-observation), and the fixture helpers (reportBarrier, capture exist). Residual within-wave races are accepted design elsewhere (query documents "these separate authorities still provide no lock"), but this change regresses the parent's atomic tail and skips the established wave; a fix is to re-observe the head together with (or after) the report and only then return synchronously. Downstream submitEvidence verification fails closed on a fenced receipt, which limits practical impact.

🔵 Issue 3 — packages/mcp/README.md now links the nonexistent v0.1.7 tag for the unpublished candidate note

packages/mcp/README.md:30 · nit · identified by z-ai/glm-5.3-flash

The commit replaces the working relative link ../application/README.md#unpublished-017-candidate with https://github.com/pegma-dev/knowledge-base/blob/v0.1.7/packages/application/README.md#unpublished-017-candidate. The v0.1.7 tag does not exist — the same paragraph states the candidate is unpublished — so the link 404s today and stays dead until that future release, and its anchor depends on a future file state.

The repo's own convention for unpublished candidates is to avoid nonexistent-tag links: docs/AGENT_API.md previously described the 0.1.6 candidate without a tag link, and docs/RELEASING.md:123 still links the identical upgrade note with a relative path. If the motivation is published-tarball README rendering (where cross-package relative links break), a default-branch link or a relative link retained alongside the absolute one would avoid the dead state.

Workflow run

Comment thread packages/mcp/README.md Resolved

@github-actions github-actions 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.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 67c71b08b2a912a26a3d102e45453361aa8d501e
Judge: openai/gpt-5.6-luna
Cost: $0.1213 (lanes $0.1212 + judge $0.0001)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 39.1s, 88080+1321 tokens (64605 cached), 4 tool round(s), via Azure, $0.0862)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 412.8s, 355696+40401 tokens (273280 cached), 8 tool round(s), via Cohere, $0.0350)

Round 3 resolution

  • ✅ r2-1 fixed correctly — Sibling docs still present the 0.1.5 receipt as "current" after 0.1.5 was re-designated historical: The affected sibling documentation now explicitly identifies 0.1.6 as the current verified release and 0.1.7 as unpublished. References to the 0.1.5 receipt are labeled retained or historical, and test/README.md now names 0.1.6 as current. Repository-wide reference checks and the preserved anchors in docs/BOOTSTRAP.md confirm that the historical links remain valid.
  • ⚠️ r2-2 fixed incorrectly — Staff receipt read's re-observation runs after the last epoch fence, so a concurrent reset can still return a retired receipt: The added closing head observation catches resets committed before that observation, but the original interleaving remains possible within the Promise.all wave: the closing headVersion can finish at epoch E, then reset can commit E+1 while observedReport is still pending. Reset updates only the head and retains the old report row until drain, so both version comparisons can pass and read…
  • 1 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 1 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed the threadless r2-1 finding in 67c71b0.

The nine sibling guides now identify the current verified 0.1.6 receipt and label retained 0.1.5 receipts consistently. Historical anchors, artifact records, hashes and URLs remain available. Scoped formatting passed.

@github-actions github-actions 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.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 9364f65041e78faf2696dbbc2dfdc75cb590c4ee
Judge: openai/gpt-5.6-luna
Cost: $0.0767 (lanes $0.0756 + judge $0.0011) + at least $0.0430 (incomplete)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 29.2s, 72525+915 tokens (50706 cached), 4 tool round(s), via Azure, $0.0756)
  • z-ai/glm-5.3-flash: ok (1 finding(s), 724.4s, 400370+38004 tokens (180800 cached), 10 tool round(s), 1 retried request(s), salvaged finish, via Morph, at least $0.0430 (incomplete))

Round 4 resolution

  • ✅ r2-2 fixed correctly — Staff receipt read's re-observation runs after the last epoch fence, so a concurrent reset can still return a retired receipt: Staff read now completes report re-observation before its final headVersion read, then validates the ledger epoch, status and opaque head version and returns without another await. A reset committed while the closing report result is pending is therefore detected by the subsequent head read.

The added Store-barrier tests cover this late window both with retained report rows and after reset/dr…

  • Open findings after this round: 1 (0 bug-severity).

Findings

🟠 Issue 1 — Sibling receipt-returning reads keep the retired-receipt race r2-2 fixed in staff read only

packages/application/src/evidence-reports.ts:1484 · risk · identified by z-ai/glm-5.3-flash

The commit closes the r2-2 window in the staff read by making the re-observed report read precede a final headVersion observation, with only synchronous checks and a synchronous acknowledgement(report) build after it. I verified that sequence: any reset or drain that commits before the final head read's snapshot is detected (status flips to resetting pre-drain, epoch advances post-drain, and drain deletes rows in the same transaction as the head write), and the new gated test at tests/evidence-reports.test.ts:501 would fail against the prior concurrent wave, so r2-2 is genuinely fixed for that path.

Two sibling paths return the same receipt but were not reordered:

  • packages/application/src/evidence-reports.ts:1484 (status): after the second await active(articleId, epoch) fence, the final awaited read is load(...) on the report row; there is no head re-observation after it. A reset committing between the fence's head snapshot and the report read returns {...acknowledgement(latest), status} for epoch E while the ledger is resetting/E+1 — the same masked-staleness disclosure r2-2 described.
  • packages/application/src/evidence-reports.ts:1326-1330 (agent-facing lookup/query path): closes with Promise.all([headVersion, observedReport]) followed by an await current(...) before returning {ledger, status: {...acknowledgement(latestReport.value)}}. A reset committing between the wave's head snapshot and the report read passes all checks (retained report row, same version, stale head matches), and the current() await after the wave reopens the window further.

Docs promise that reset "immediately [fences] old report receipts" (docs/EVIDENCE_REPORTS.md:276) and RELEASING.md ties the read refusal to returning the view; these windows are weaker than the fixed staff read for the same receipt.

What I checked: acknowledgement is pure/synchronous; drain writes the head and deletes rows atomically, so no row-without-fence state exists; decide and report writes are fenced by active() so rows cannot mutate while resetting; no existing test gates status or the lookup path against a late reset. Scope caveat: these functions predate the latest commit and were not edited by it; I could not run the tests to confirm the interleavings live, so this rests on code reading of the commit's current state.

Workflow run

@github-actions github-actions 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.

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: bbfd052bde19d3580691858c8ca2cdda13abf1e1
Judge: openai/gpt-5.6-luna
Cost: $0.1256 (lanes $0.1255 + judge $0.0001)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 30.5s, 81635+911 tokens (56722 cached), 4 tool round(s), via Azure, $0.0848)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 572.1s, 924121+26220 tokens (814592 cached), 23 tool round(s), via Together, $0.0407)

Round 5 resolution

  • ✅ r4-1 fixed correctly — Sibling receipt-returning reads keep the retired-receipt race r2-2 fixed in staff read only: Both sibling receipt-returning reads now close the ledger observation after their other awaits.

  • status re-observes the report before its final headVersion read and rejects epoch, resetting-state, or head-version changes before synchronously constructing the response.

  • query performs a closing headVersion read after its current-authority check and rejects epoch, status, or version chang…

  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed the receipt-returning status/query finding in bbfd052.

Status now closes with a final head epoch/status/version observation after its report comparison. Query preserves its owner, resource, version and credential-ceiling checks, then closes the head after all awaited work before synchronous disclosure. Six actual reset/drain schedules fail against the sealed predecessor artifact. Both Node lanes passed the complete 1,076-test suite, including all 81 report cases on each MemoryStore, Azure Tables and Miniflare D1 backend, plus all 128 release regressions with zero skips, examples, package checks and authenticated protocol proof. The configured OpenRouter review is clean for this commit.

@FlyOverCoderKY
FlyOverCoderKY merged commit 27074b8 into main Nov 12, 2026
5 checks passed
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