Skip to content

Add governed report and background comparison observations - #16

Merged
FlyOverCoderKY merged 4 commits into
mainfrom
claude/kb018-observations-20261112
Nov 12, 2026
Merged

FlyOverCoderKY merged 4 commits into
mainfrom
claude/kb018-observations-20261112

Conversation

@FlyOverCoderKY

@FlyOverCoderKY FlyOverCoderKY commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Staff need to associate confirmed agent test reports with support resolutions and compare proposed guides against approved knowledge, including private and bot-only collections. This adds operation-local report observations and a bounded background comparison port under existing staff authoring permissions.

  • Report observations confirm the governed context, exact report and ledger, and current owner/reviewer authority. Legacy report callers keep their existing path.
  • Background comparisons require article-read and draft-read authority. They reuse the publication checker for current content, approval, evidence, policy and source eligibility. A keyed readArticle and collection readScope support subsequent proof checks.
  • Catalogue traversal materializes at most eight returned records per page and retains key/version metadata between pages. Two bounded completed traversals detect observed membership changes. Configured query limits apply before I/O, and explicit null limits are rejected.
  • A nonterminal cursor at the 256-record allowance produces a partial result. These observations describe bounded point-in-time work. Host backend, allocation, query and CPU acceptance remains measured separately.
  • The synchronized 0.1.8 candidate includes report-refusal regressions and corrected release documentation. The agent transport continues to expose its existing five operations and three authoring scopes.

Both Node 22 and 24 passed 126 selected comparison/retrieval checks on Memory, Azurite and D1, plus the nine new report-refusal cases. Normal types, formatting, four-package packing and isolated consumers pass for the combined candidate. The complete current-head CI matrix and configured OpenRouter review are running and remain required for merge.

The packages require trusted publication and complete-set registry verification before production host adoption. Actual client workflows and two-host activation acceptance remain open.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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

@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-12T20:49:53.831326Z bc1cabe 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 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: bc1cabe6aa138c1ea93648d85bf870f5f57f72b4
Judge: openai/gpt-5.6-luna
Cost: $0.4776 (lanes $0.4726 + judge $0.0050)

Lanes

  • openai/gpt-6.1-sol: ok (4 finding(s), 106.5s, 345252+3869 tokens (278142 cached), 6 tool round(s), via Azure, $0.26)
  • z-ai/glm-5.3-flash: ok (7 finding(s), 575.6s, 3707914+39712 tokens (3195648 cached), 50 tool round(s), via Particle AI, $0.21)

Warning

z-ai/glm-5.3-flash: coverage claims 3 finding(s) in 'packages/application/src/published-search-observations.ts' but 2 were reported

Findings

🔴 Issue 1 — Ignored configured query ceilings

packages/application/src/published-search-observations.ts:87 · bug · identified by openai/gpt-6.1-sol

A host that lowers maxQueryCharacters or maxQueryTerms can still submit an over-limit query to publishedSearchObservations.observe, triggering catalogue enumeration and comparison work that ordinary retrieval rejects.

searchInput calls normalizeQuery with its hard-coded 256-character/eight-term ceilings and receives only limits.maxResults. It never applies the instance's configured query ceilings. Pass the relevant limits into this validation and apply them before any storage reads.

I checked retrieval.ts:552–559, which explicitly enforces both configured ceilings, and index.ts, which passes the resolved limits to this new service. The new observation tests exercise physical-read and content overrides, but do not cover either query override.

🟠 Issue 2 — Unbounded catalogue payload materialization

packages/application/src/published-search-observations.ts:193 · risk · identified by openai/gpt-6.1-sol

A store containing fewer than 256 large private or historical records can cause a background comparison to materialize a very large page, potentially exhausting a constrained host's memory before it can return partial. Even an empty comparison scope pays this cost.

catalogue scans complete knowledgeRecords values and limits only their count. records.ts permits approximately 900 KB of native payload per record, so the page ceiling permits hundreds of megabytes of payload before decoding and temporary allocations. maxContentBytes is checked later and only against matching public projections; it does not bound the scan payload.

I checked the record codec, retrieval budget, and the new physical-row/content-bound tests. They establish per-record and row-count limits, not an aggregate scan-byte limit. Actual peak memory is backend-dependent and has not been measured here. Use a byte-bounded or key/version-only enumeration strategy, or a conservative page ceiling that safely bounds materialization.

🔵 Issue 3 — Null result limit accepted as omission

packages/application/src/published-search-observations.ts:105 · nit · identified by openai/gpt-6.1-sol

A runtime caller supplying limit: null receives the default result limit and can initiate comparison work instead of receiving the promised invalid-input error.

input.limit ?? maximum treats explicit null as an omitted optional field. The existing retrieval implementation defaults only undefined and rejects null through its integer validation. Use the same distinction here.

I checked requestedLimit in retrieval.ts and the new invalid-input tests. TypeScript excludes null for typed callers, but this implementation otherwise deliberately validates runtime inputs; the tests do not cover an explicit null limit.

🔵 Issue 4 — Contradictory source-version statement

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

A maintainer following the release guide encounters two different claims about the current source graph: the verified-release section says all source versions and internal pins are synchronized at 0.1.7, while the immediately following candidate section correctly says 0.1.8.

The package manifests and lockfile now use 0.1.8. Describe the 0.1.7 synchronization in the past tense, or explicitly refer to that release's artifacts rather than the current source package versions.

I checked all four changed package manifests and the root dependency pins; this is a documentation inconsistency, not a dependency-graph mismatch.

🔵 Issue 5 — Stale release-status text left in examples READMEs

examples/agent/README.md:5 · nit · identified by z-ai/glm-5.3-flash

A maintainer or host operator reading examples/agent/README.md or examples/composition/README.md is told the current verified release is 0.1.6 and that "The 0.1.7 source candidate remains unpublished" — both statements are now false after this PR declares 0.1.7 published and 0.1.8 the candidate. The PR updated the identical boilerplate in README.md, AGENTS.md, test/README.md and every docs/*.md file but missed these two files, so the repository's release-status statements contradict each other.

  • examples/agent/README.md:4-5 — still cites 0.1.6 and "The 0.1.7 source candidate remains unpublished."
  • examples/composition/README.md:4-5 — same stale pair.

Concrete cost: this repository treats release/receipt prose as normative governance evidence (see AGENTS.md and docs/BOOTSTRAP.md); an agent following the documented doc-sync pattern for the 0.1.8 release will inherit the same drift, and a reader cannot tell from the examples which version is actually current.

I grepped the whole tree for 0\.1\.7; these two files are the only remaining stale occurrences outside the intentionally historical receipt sections.

🔵 Issue 6 — BOOTSTRAP.md says the 0.1.7 receipt is "below" but it was inserted above the 0.1.6 section

docs/BOOTSTRAP.md:531 · nit · identified by z-ai/glm-5.3-flash

A reader following docs/BOOTSTRAP.md's closing release-preparation section is told the historical 0.1.1–0.1.5 receipts "remain above alongside the retained verified 0.1.6 receipt and the 0.1.7 release below." But the new "### Verified 0.1.7 release" section was inserted before the "### Current verified 0.1.6 release" section, so the 0.1.7 receipt is also above, not below. Scanning downward from that sentence finds 0.1.6 first and never finds a 0.1.7 section beneath it.

Concrete cost: the bootstrap ledger is the document hosts are directed to for exact publication identities (docs/RELEASING.md points at it); a wrong directional cue sends the reader to the wrong receipt when verifying artifacts.

The diff hunk at docs/BOOTSTRAP.md ("retained verified 0.1.6 receipt and the 0.1.7 release below.") plus the insertion position of the new ### Verified \0.1.7` releaseheading (before the0.1.6` heading) are the evidence; both are in this PR.

🔵 Issue 7 — 0.1.6 receipt heading and prose now disagree about which release is current

docs/BOOTSTRAP.md:104 · nit · identified by z-ai/glm-5.3-flash

The PR relabels every prose reference to the 0.1.6 receipt as "retained"/"historical" (e.g. README.md now reads "The historical 0.1.6 receipt"), but the target heading in docs/BOOTSTRAP.md still literally reads "### Current verified 0.1.6 release". A reader who follows the link lands under a heading asserting 0.1.6 is the current verified release, directly above the intro that now says 0.1.7 is current.

Concrete cost: the page's own heading contradicts the page's intro and every cross-reference added by this PR; a reader skimming headings alone concludes 0.1.6 is current.

I kept this as one finding because it is one mechanism (stale "current" label around the 0.1.6 receipt). The anchor string current-verified-016-release is presumably retained deliberately (the 0.1.5 receipt follows the same convention), so only the heading's visible text and the surrounding presentation are stale — but the PR did edit this region of BOOTSTRAP.md and left the heading as-is.

🟠 Issue 8 — Complete observations may be unobtainable for stores at exactly the 256-row scan ceiling

packages/application/src/published-search-observations.ts:196 · risk · identified by z-ai/glm-5.3-flash

If a host's Store returns a non-null nextCursor whenever a scan page is full (a common cursor-pagination contract, including speculative cursors when records.length === limit), then a knowledge store with exactly maximumPhysicalRows (256) physical records can never produce a complete published-search observation: catalogue() treats any non-null cursor as "following pages cannot supply a single terminal membership observation" and yields partial forever, even though the entire corpus fits one page and nothing actually changed.

Concrete cost: a host sitting exactly at the ceiling permanently loses complete comparison results and cannot distinguish "store too large" from "store at boundary"; the documented bound ("a fixed ceiling of 256 rows") suggests 256 rows should be completable.

Mechanism: packages/application/src/published-search-observations.ts, catalogue() — records.scan({ limit }) with limit = min(256, remaining), then if (page.nextCursor !== null) throw new PartialObservationError(). The code only defends against records.length > limit (RepositoryIntegrityError), not against a full-but-terminal page signaled by a cursor.

Proof gap: @​pegma/storage-core@​0.4.0's scan contract is not checkable in this checkout (node_modules is absent), so I cannot confirm whether backends may report a cursor for a full terminal page. The existing tests only cover a 260-row store (partial) and small stores (complete), not exactly 256 rows. If Storage Core guarantees nextCursor === null on a genuinely terminal page, this finding is void.

🔵 Issue 9 — Published-search confirm/observe collapse every failure into one indistinguishable outcome

packages/application/src/published-search-observations.ts:415 · nit · identified by z-ai/glm-5.3-flash

observe maps every non-budget error — including RepositoryConflictError from the membership fence, RepositoryIntegrityError from corrupt stored rows, and any unexpected TypeError raised inside read — to the single outcome "unavailable", and confirm's blanket catch { throw unavailable(); } converts all of those plus KnowledgeBaseNotFoundError into the same KnowledgeBasePrerequisiteError("published_search_observation").

Concrete cost: a host operating the background comparison cannot distinguish "the scope legitimately changed, a retry is meaningful" from "stored KB data failed an integrity check, page an engineer" — both surface as the identical error code/outcome. An integrity bug in the record codec would present as routine background unavailability instead of a loud failure. The same swallowing in observe means a host-side programming error inside read (e.g. a future bad argument) is silently reported as dependency trouble.

Evidence: packages/application/src/published-search-observations.ts — observe's catch maps only PartialObservationError/RetrievalBudgetError/RepositoryCapacityError to "partial" and everything else to "unavailable"; confirm re-throws a fresh unavailable() for any rejection of read, including the unavailable() it throws itself. The tests (tests/published-search-observations.test.ts) pin this collapse (conflict → unavailable/PrerequisiteError), so it is at least intentional; the cost is diagnostic, not a correctness hole, since no failure path ever returns articles.

🔵 Issue 10 — Report observe's refusal of non-confirmed reports is untested

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

observations.observe throws report_not_verifiable when the stored report is not confirmed or has no confirmation (packages/application/src/evidence-reports.ts, the report.status !== "confirmed" || report.confirmation === null || ... gate), but no test in the new suite drives observe against a pending or rejected report. The suite only reaches that gate via the revoked-evidence and expired-proof paths, where the report was confirmed at observe time.

Concrete cost: a regression that drops or weakens the status check (e.g. treating pending reports as observable) would pass the entire new test file while disclosing provisional private views for unconfirmed reports — the exact disclosure the gate exists to prevent.

What I checked: tests/report-observations.test.ts exercises observe only on confirmed reports (f.confirmed), plus observe-time refusals for revoked evidence, missing staff authority, and missing evidence-read permission. tests/evidence-reports.test.ts covers pending reports for the legacy read path, not for observe. The fixture supports the scenario trivially (f.decide(f.confirmed.ack, "pending") exists and is already used for the confirm-side reassessment test).

🔵 Issue 11 — publishedSearchObservations is typed optional but always constructed

packages/application/src/index.ts:39 · nit · identified by z-ai/glm-5.3-flash

KnowledgeBaseApplication.publishedSearchObservations is declared optional (packages/application/src/types.ts: "Optional bounded background comparison observations"), and the README leans on that optionality ("The optional property preserves structural legacy applications"), but createKnowledgeBaseApplication unconditionally assigns it (packages/application/src/index.ts) — there is no configuration under which the property is absent.

Concrete cost: a host that writes app.publishedSearchObservations ? ... : fallback gets permanently dead fallback code and may believe absence is a supported runtime state (as it genuinely is for reports.observations, which is conditional on authoringContext). The two optional ports look parallel in the docs but only one can actually be absent.

Evidence: packages/application/src/index.ts builds the property with no guard, unlike the report factory's ...(authoringContext === undefined ? {} : { observations }) pattern in evidence-reports.ts. This is a type/documentation mismatch, not a runtime fault; the tests use app.publishedSearchObservations! accordingly.

Workflow run

Comment thread docs/RELEASING.md Resolved
Comment thread docs/BOOTSTRAP.md Resolved
Comment thread docs/BOOTSTRAP.md Resolved
Comment thread packages/application/src/index.ts 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: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 19f1ee26a1769d1bcd06d19a00b41f0286b5bd65
Judge: openai/gpt-5.6-luna
Cost: $0.1435 (lanes $0.1434 + judge $0.0001) + at least $0.0627 (incomplete)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 40.8s, 181462+1402 tokens (140543 cached), 5 tool round(s), via Azure, $0.14)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 784.3s, 956531+85361 tokens (819288 cached), 17 tool round(s), 1 retried request(s), salvaged finish, via OpenInference, at least $0.0627 (incomplete))

Round 2 resolution

  • ✅ r1-1 fixed correctly — Ignored configured query ceilings: searchInput now receives the resolved instance limits and checks both maxQueryCharacters and maxQueryTerms before storage access. Both observation and confirmation use this validation. The new tests verify rejection under lowered ceilings with no keyed reads or scans.
  • ✅ r1-2 fixed correctly — Unbounded catalogue payload materialization: catalogue now scans pages of at most eight records, independently bounding each page using the existing 900,000-byte native record estimate and a 7.2 MB page allowance. Only keys, versions, and article IDs are retained between pages. Large-history tests exercise multiple bounded pages without exposing private payloads. Backend allocation overhead and measured heap acceptance remain explicitly ou…
  • 🤝 r1-8 disputed — Complete observations may be unobtainable for stores at exactly the 256-row scan ceiling: The exact-ceiling speculative-cursor behavior is now an explicit, technically justified conservative tradeoff. Completion requires a terminal cursor, while each pass forbids fetching a possible 257th physical row; without an additional adapter guarantee, an empty continuation cannot be established within that hard bound. The README documents this limitation, and boundary tests accept partial onl…
  • 8 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • 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

The body-only example README finding is fixed in 64f0e38. Both example introductions identify verified 0.1.7 and the unpublished 0.1.8 candidate.

Current head 19f1ee2 has clean OpenRouter review 5882501608 and passing Node 22/24 CI and CodeQL. Each Node lane passed 1,286 runtime tests and 128 release tests, plus composition, package and authenticated agent protocol checks. The ten inline threads now have documented responses and are resolved.

@FlyOverCoderKY
FlyOverCoderKY merged commit 04d07b6 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