Repository navigation
[PG-01] Add governed knowledge authoring and scoped local-agent access - #59
Conversation
|
OpenRouter review posted ( |
|
@codex security review |
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 898b183883
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 898b1838836512821eabb8886aa37834e8cbffe6
Judge: openai/gpt-5.6-luna
Cost: $0.4534 (lanes $0.4460 + judge $0.0074) + at least $0.0799 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (6 finding(s), 152.7s, 764935+6398 tokens (654511 cached), 7 tool round(s), via Azure, $0.45)z-ai/glm-5.3-flash: ok (15 finding(s), 911.0s, 659345+76191 tokens (379648 cached), 5 tool round(s), 1 retried request(s), salvaged finish, via BaseTen, at least $0.0799 (incomplete))
Findings
🟠 Issue 1 — Permanent per-article report exhaustion
worker/src/knowledge-evidence.ts:500 · risk · identified by openai/gpt-6.1-sol
Once an article accumulates 16 reports, agents can never submit another report for that article through this composition. A walkthrough requiring two reports per revision reaches this limit after eight revisions, sooner when tests fail or governance changes require resubmission.
write() increments the article-wide report counter for every submission, regardless of revision or report status. No operation decrements it, expires reports, or restores capacity. Invalid and rejected submissions also consume the same lifetime allowance.
I checked knowledge-evidence.ts, its capacity regression in knowledge-evidence.test.ts, and the host maintenance implementations and schedule. The test confirms refusal of report 17, but there is no recovery path. The disabled deployment configuration postpones the trigger; it does not resolve it when authoring is enabled. Add bounded retention or another integrity-preserving capacity recovery mechanism before sustained use.
🟠 Issue 2 — New durable limiters are omitted from maintenance
worker/src/knowledge-runtime.ts:94 · risk · identified by openai/gpt-6.1-sol
After activation, requests from additional IP addresses create durable admission records that the existing scheduled cleanup never sweeps. Continued traffic can therefore accumulate expired limiter state in the shared Identity D1 database.
The agent runtime creates six durable limiters and exposes them through limiters; the knowledge runtime creates another browser limiter without exposing a maintenance surface. Neither runtime is composed by the scheduled handler. Existing cleanup lanes only select the four Identity and four Support limiters.
I checked index.ts, maintenance-schedule.ts, identity-maintenance.ts, support-maintenance.ts, and searched the Worker sources for sweep calls. Existing maintenance explicitly calls each selected limiter's sweep(), but none of the new policies is selected. The package's internal storage implementation is not available in this checkout, so the precise growth rate is unverified; the missing host cleanup integration is direct evidence. Include the new policies in bounded scheduled cleanup.
🔴 Issue 3 — Stale read failures overwrite newer browser state
public/knowledge.js:125 · bug · identified by openai/gpt-6.1-sol
A user can click guide A and then guide B, receive B successfully, and subsequently see an error from A replace B's success status. If A returns an authorization failure, its stale handler also clears the newer results and hides the panel. Similar races exist when submitting successive device codes or looking up successive grant IDs.
Successful responses are generation-checked, but rejected promises are not:
public/knowledge.jscallsshowArticle(...).catch(failure)without checking the article request's generation.public/agent-access.jspasses device approval failures directly tofailure()and does not checkgrantGenerationin the grant lookup catch block.
I compared these paths with the knowledge search handler, which already checks its generation before applying a failure. The forms and result buttons permit overlapping reads; mutationPending only prevents overlap with mutations. Apply generation checks to failures as well as successes, or cancel superseded reads.
🔵 Issue 4 — Owner-denied grant lookup disables valid Admin controls
public/agent-access.js:44 · nit · identified by openai/gpt-6.1-sol
A current Admin who enters another owner's grant ID loses the entire agent-access panel, including the ability to retry with their own grant or approve a pending request. The UI can also incorrectly tell them that their account lacks Admin access.
failure() treats every HTTP 403 as account-wide authority loss, clears both the approval and grant state, and hides panel. However, owner-only grant authorization also returns 403 while the caller remains a valid Admin.
I checked the released-service integration assertions in agent-access-runtime.test.ts: both another Admin's grant read and revocation explicitly return 403. The API does not distinguish those failures with a status that justifies hiding all controls. Keep resource-specific denials local, or recheck /api/agent-access/state before treating a 403 as account-wide demotion.
🔵 Issue 5 — Collection read controls are hidden from Support
src/pages/staff/knowledge.astro:14 · nit · identified by openai/gpt-6.1-sol
A signed-in Support reviewer cannot load or inspect a collection through the staff page, even though their current role is authorized to read it. The entire Collection section disappears because its visibility is tied to management permission.
The section contains both Load collection and mutation controls, but is marked data-kb-permission="collectionManage". Startup hides that section for Support. Management-only visibility should instead apply to creation and policy mutation controls, leaving collection lookup and details available to authorized readers.
I checked KNOWLEDGE_STAFF_PERMISSIONS and the regression in knowledge-runtime.test.ts, which explicitly proves that Support can call getCollection while collectionManage is false. Backend authorization is correct; this is a browser access mismatch.
🔵 Issue 6 — No staff controls for publication or evidence withdrawal
public/staff-knowledge.js:452 · nit · identified by openai/gpt-6.1-sol
When staff discover that a published guide or accepted test result is wrong, the supplied administration page offers no control to retire the article or revoke the evidence. Operators must construct a manual authenticated API request instead of using the reviewed staff workflow.
The API already exposes retireArticle and revokeEvidence, and the state response advertises retire and evidenceRevoke permissions. Neither permission is consumed by the browser script, and the page contains no corresponding forms. Rejecting a report is not a substitute: decisions only apply to pending reports, while actual evidence revocation is a separate KB command.
I checked the complete staff page and script, the command allowlist in knowledge-api.ts, and the actual revocation regression in knowledge-evidence.test.ts. The backend escape hatch exists, so withdrawal is not impossible, but the missing browser controls add manual work and increase the chance of an incorrect emergency withdrawal request.
🟠 Issue 7 — Report ledger capacity is permanently consumable; exhausted article can never accept reports again
worker/src/knowledge-evidence.ts · risk · identified by z-ai/glm-5.3-flash
An agent (or anyone holding a delegated grant) can file 16 junk or stale reports for one article, after which every future report() call for that article returns 409 report_capacity forever. Staff rejection also consumes a slot: decide() with rejected keeps the row, and revokeEvidence only revokes KB evidence, never ledger rows. There is no delete/retention path in this slice, so the only recovery is manual D1 surgery.
Mechanism: knowledge-evidence.ts enforces MAX_REPORTS = 16 per article partition in write(), counting every stored report row regardless of whether it was confirmed, rejected, or rendered unverifiable by a later draft edit (stale-binding reports can never be confirmed, yet still occupy slots). The docs defer retention to "before enabling a customer cohort", but the flag-off default does not prevent an enabled cohort from hitting this.
Concretely: an Admin links an agent, the agent (or a buggy automation loop with rotating commandIds) submits 16 reports bound to superseded revisions; the genuine report the human wants to review then cannot be filed at all for that article. I checked knowledge-evidence.ts (write, decide, revokeEvidence paths) and found no operation that frees report rows or resets the head counters.
🟠 Issue 8 — No separation of duties: the agent's owner can confirm the agent's own reports
worker/src/knowledge-evidence.ts · risk · identified by z-ai/glm-5.3-flash
A single Admin can originate and independently "verify" agent-submitted evidence: the Admin links their own agent (device or PKCE consent only requires the current Admin role), the agent submits a report via /api/knowledge/reports, and the same Admin then confirms it from their browser session. The PR narrative ("authorized staff confirm the complete exact revision/build/check/governance binding", "Confirmation is a human review decision") implies independent review, but nothing enforces confirmer ≠ submitter/owner.
Mechanism: staff()/decide() in knowledge-evidence.ts only check KNOWLEDGE_EVIDENCE_CONFIRM_PERMISSION, never comparing report.submittedBy (or the grant owner) with the confirming principal. support-access.ts grants the Admin role both AGENT_LINK_PERMISSION and the confirm permission. The staff state endpoint even pre-fills governance trusted attesters with the configuring admin's own principal (attesterId: access.principalId in knowledge-api.ts, consumed by staff-knowledge.js #kb-attesters), so self-trust is the out-of-the-box configuration; the trustedAttesterIds mitigation is itself Admin-controlled.
I checked knowledge-evidence.ts (staff, decide, verify) and agent-authority.ts for any owner-vs-reviewer check and found none.
🟠 Issue 9 — Per-IP browser rate limit (120 per 5 min) is shared by all staff behind one egress IP and is tight for real review sessions
worker/src/knowledge-runtime.ts · risk · identified by z-ai/glm-5.3-flash
A small staff team behind one office NAT shares a single pegma.knowledge.browser budget of 120 requests per 5 minutes (keyed by CF-Connecting-IP digest in knowledge-runtime.ts). One article review costs roughly 10–20 requests (state, loadCollection, governance, review load, report list, one read per report, confirm/reject, publish), so two or three reviewers working simultaneously can 429 each other mid-workflow, and the staff UI surfaces 429 only as the generic "operation could not be completed" message.
Similarly, pegma.agent.resource (300 per 5 min per IP) is one shared limiter across /api/knowledge/mcp, /api/knowledge/v1, and /api/knowledge/reports (transportOptions.limit and the reports branch both use agents.resourceLimit), so a polling MCP agent and report submission contend for the same budget.
I checked knowledge-runtime.ts, agent-access-runtime.ts (admission policies) and knowledge-api.ts; the limits are fixed constants with no per-principal dimension for browser traffic.
🟠 Issue 10 — Malformed PEGMA_AGENT_CLIENTS_JSON degrades every knowledge route, contradicting the documented browser/agent independence
worker/src/knowledge-host.ts · risk · identified by z-ai/glm-5.3-flash
docs/KNOWLEDGE_COMPOSITION.md states that empty client configuration "disables the OAuth issuer and delegated transports, while the browser KB composition can still operate independently." That independence only holds for empty input. For malformed JSON, oversized input (>16 KiB), more than 16 clients, unknown fields, or unregistered scopes, readAgentClients throws inside handleKnowledgeRequest's try block, and the catch converts it into 503 knowledge_unavailable for ALL knowledge paths — including /api/staff/knowledge/*, /api/knowledge/portal, and both .well-known metadata routes.
Concrete failure: an operator typo in the optional client var (e.g. trailing comma) takes down the entire staff review UI and signed-in guides, not just agent linking, and the only signal is an error.name log line. Fail-closed is right for the OAuth issuer, but the browser-only composition could and arguably should tolerate agent-config parse failure, since it never touches agentAccess.
I verified knowledge-host.ts calls readAgentClients inside the shared try before the metadata/agent-vs-knowledge split, and that knowledge-api.ts's browser paths only need agentAccess for the reports branch.
🔵 Issue 11 — Agent-access 405 responses skip the Referrer-Policy header applied to every other response
worker/src/agent-access-api.ts · nit · identified by z-ai/glm-5.3-flash
In agent-access-api.ts, the early return json({ error: 'method_not_allowed' }, ...) for a disallowed method exits the try block directly, so the trailing response.headers.set('Referrer-Policy', 'no-referrer') / X-Content-Type-Options statements after the try/catch never run for 405s. json() does set X-Content-Type-Options and Cache-Control, but not Referrer-Policy, so agent-access 405 responses are the only ones in this surface missing the no-referrer policy that the PR's own threat posture (sensitive Admin consent endpoints) relies on. Compare knowledge-api.ts, which consistently wraps its 405s in secured(...).
🔵 Issue 12 — TypeError/SyntaxError mapped to 400 invalid_request without logging hides internal faults and ledger corruption
worker/src/knowledge-api.ts · nit · identified by z-ai/glm-5.3-flash
knowledge-api.ts's catch maps any TypeError or SyntaxError to 400 invalid_request with no log line (logging happens only for status 503). The evidence service deliberately throws bare TypeError('Invalid evidence ledger.') from decodeReport/load when a stored row fails validation — so a corrupted or tampered ledger row surfaces to staff/agents as a generic client error and leaves no server-side trace. Likewise an internal coding bug (e.g. undefined dereference inside a service) is reported as the caller's fault. Failures in this path are exactly the ones operators need logged.
🔵 Issue 13 — Staff can confirm reports that can never be accepted (trustedAttesterIds only enforced at submitEvidence)
worker/src/knowledge-evidence.ts · nit · identified by z-ai/glm-5.3-flash
valid() in knowledge-evidence.ts checks the confirming reviewer's permission but never whether that reviewer appears in the collection governance's trustedAttesterIds; that check happens only later inside verifier.verify() against request.configuration. Scenario: a Support reviewer with the confirm permission but not listed in trusted attesters confirms a report — the UI reports success and the status becomes confirmed — then the agent's submitEvidence returns 412 prerequisite forever. The staff UI gives no indication at confirm time that the confirmation can never take effect, producing a permanently stuck "confirmed" report that also occupies one of the 16 ledger slots.
🔵 Issue 14 — Evidence verification performs ~20+ store/identity reads per submitEvidence
worker/src/knowledge-evidence.ts · nit · identified by z-ai/glm-5.3-flash
verifier.verify() in knowledge-evidence.ts resolves the reviewer principal four separate times (inside verified(), via staff() twice, and directly), calls the expensive readContext twice (each doing four SDK reads plus a digest comparison in knowledge-runtime.ts), and load()s the report twice. A single agent evidence submission therefore costs on the order of twenty D1/identity operations before the KB command even runs, on the hottest agent write path. This is defense-in-depth by intent, but the duplication (e.g. verified() already called readContext and staff(reviewer) with the same inputs moments earlier) is pure repeated cost and latency.
🔵 Issue 15 — Approval success tells the user to keep a grant ID the UI never displays
public/agent-access.js · nit · identified by z-ai/glm-5.3-flash
After a device-flow approval, agent-access.js shows "Approved. Return to your agent to finish connecting. Keep this grant ID for revocation." — but no grant ID is rendered at that point. The code relies on grantInput.value = result.requestId (set during loadApproval) still holding the value in the lookup field, and on the assumption that requestId equals the AA package's grantId. If the released package's grant identifier ever differs from the request identifier, the instruction is unactionable and the owner cannot revoke without the agent's help. The displayed label "Grant / request ID" suggests they are the same, but that equivalence is an assumption about @pegma/agent-access internals, not something this diff verifies.
🔵 Issue 16 — Device user-code input allows 200 characters but the API bound is 128
src/pages/account/agents/device.astro · nit · identified by z-ai/glm-5.3-flash
device.astro sets maxlength="200" on #agent-user-code (and agent-access.js parameter() accepts up to 512), but agent-access-api.ts validates the selector with boundedString(..., 1, 128). A user code longer than 128 characters is accepted by the form and then rejected with a 400 invalid_request (rendered as the generic "Check the request or device code" message), a silent client/server validation mismatch.
🔵 Issue 17 — Lockfile adds duplicated zod, MCP SDK, and json-schema versions to the Worker bundle
pnpm-lock.yaml · nit · identified by z-ai/glm-5.3-flash
The lockfile now ships @modelcontextprotocol/sdk at both 1.30.0 (via agents) and 1.32.2 (via @pegma/knowledge-base-mcp), @cfworker/json-schema at both 4.1.1 (direct dep of agents) and 4.1.6 (the re-resolved optional peer), and three zod versions (3.25.76, 4.4.3, 4.6.7). Because @pegma/knowledge-base-mcp pins sdk 1.32.2/zod 4.6.7 while agents@0.20.1 keeps sdk 1.30.0, the sdk's optional peer re-resolves to 4.1.6 and both copies end up in the tree — Worker bundle bloat plus the classic zod dual-instance hazard (instanceof/schema identity failures across the two zod 4.x copies if any shared types cross the package boundary). Nothing in the diff documents this duplication as intentional.
🔵 Issue 18 — Nav exposes the signed-in-only Knowledge base link to signed-out visitors
src/layouts/Base.astro · nit · identified by z-ai/glm-5.3-flash
Base.astro adds { href: '/knowledge', label: 'Knowledge base' } to the global nav rendered for every visitor, including signed-out users, while /knowledge requires a session (knowledge.astro shows a sign-in wall). Signed-out visitors get a nav item that always dead-ends at "Sign in required"; every other nav destination is publicly usable.
🔵 Issue 19 — New durable rate-limit policies are not wired into the existing maintenance cleanup lanes
worker/src/agent-access-runtime.ts · nit · identified by z-ai/glm-5.3-flash
agent-access-runtime.ts creates seven new durable limiter policies (pegma.agent.authorize/device/token/revoke/browser/resource) and knowledge-runtime.ts adds pegma.knowledge.browser, all backed by rows in the shared Store. The repo has an existing maintenance machinery for limiter cleanup (maintenance-limiters.ts, maintenance-schedule.ts cleanup lanes used by the support runtime's limiters), but nothing in this diff registers the new policy names with it, so their counter rows accumulate in D1 indefinitely.
Proof gap: I could not read maintenance-limiters.ts before the deadline, so I cannot rule out name-agnostic cleanup; if cleanup is per registered policy/index, these rows never expire.
🔵 Issue 20 — Two near-identical ~1200-line integration suites will drift
worker/src/knowledge-integration.test.ts · nit · identified by z-ai/glm-5.3-flash
knowledge-integration.test.ts (memory store) and knowledge-integration.d1.test.ts are line-for-line duplicates of the fixture plus five long test bodies (device/pkce helpers, submitReport, confirmedReport, the full report-confirmation and binding-rejection scenarios), differing only in store construction. Any future behavioral change must be mirrored in both files; a one-sided edit silently weakens one lane while CI stays green. Extracting the shared scenario into a helper module would remove the drift risk.
🔵 Issue 21 — Generated worker-configuration.d.ts regenerated with a whole-file whitespace change
worker/worker-configuration.d.ts · nit · identified by z-ai/glm-5.3-flash
The worker-configuration.d.ts diff reformats every pre-existing line from tabs to spaces in addition to adding the two new vars, producing a large no-op diff in a generated file. This inflates review surface and will recur on every regeneration unless the generator invocation/format is pinned.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 654e137b784813b247bd9b47cc539a8f940e05ed
Judge: openai/gpt-5.6-luna
Cost: $0.5179 (lanes $0.5176 + judge $0.0003)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 34.4s, 500360+1508 tokens (370551 cached), 3 tool round(s), via Azure, $0.41)z-ai/glm-5.3-flash: ok (1 finding(s), 99.5s, 2011857+19307 tokens (1621952 cached), 14 tool round(s), via Particle AI, $0.10)
Round 2 resolution
- ✅
r1-3fixed correctly — Stale read failures overwrite newer browser state:showArticlenow checks its generation before handling failures, matching the existing search guard. Agent approval and grant lookups likewise pass generation predicates intofailure, which rechecks them after its asynchronous authority lookup. Superseded failures no longer overwrite the newer result in the reported successive-request scenarios. - ✅
r1-1fixed correctly — Permanent per-article report exhaustion: The report service now exposes permission-gated, expected-epoch-fenced reset and bounded drain operations through the browser API and staff UI. Capacity tests and shared Memory/D1 integration scenarios cover exhausting the ledger, restoring admission, and refusing old commands and receipts. Capacity remains bounded, but is no longer permanently exhausted. - ✅
r1-2fixed correctly — New durable limiters are omitted from maintenance:index.tsnow schedulesrunKnowledgeMaintenanceon the new Knowledge cleanup lane, independently of feature enablement and client registration. It uses the separately installed paged limiter helper to scan global limiter storage rather than only currently configured instances. Tests cover expired-window deletion, retained legacy counters, checkpoint recovery, and scheduler dispatch. - ✅
r1-7fixed correctly — Report ledger capacity is permanently consumable; exhausted article can never accept reports again: The same epoch-reset and bounded-drain implementation addresses this duplicate capacity finding. Authorized staff can recover an exhausted article without manual D1 edits; earlier receipts and command replays remain invalid, while accepted KB evidence and publication are preserved. Both service tests and shared Memory/D1 integration scenarios exercise that recovery. - 🤝
r1-8disputed — No separation of duties: the agent's owner can confirm the agent's own reports: The current contract explicitly permits an authorized human Admin to review their own agent's report and states that no two-person rule applies. A regression test demonstrates acceptance when that Admin is explicitly trusted by collection governance. Browser-session confirmation remains separate from delegated submission and actual KB acceptance, so independent reviewer identity is not a requireme… - ✅
r1-9fixed correctly — Per-IP browser rate limit (120 per 5 min) is shared by all staff behind one egress IP and is tight for real review sessions: Browser and protected-resource budgets are now bounded, configurable host settings, with immutable policy names incorporating the selected limit. The browser UIs surface HTTP 429 andRetry-Afterrather than only a generic failure. Documentation explicitly identifies these as shared IP abuse budgets and warns about shared egress capacity; operators can raise the defaults for the intended cohort. - ✅
r1-10fixed correctly — Malformed PEGMA_AGENT_CLIENTS_JSON degrades every knowledge route, contradicting the documented browser/agent independence: Optional agent parsing and runtime construction now have an isolated failure boundary that leavesagentAccessnull while continuing browser KB composition. The actual-D1 host test verifies that malformed registrations still reach browser authentication and leave discovery, OAuth, and delegated routes unavailable without exposing configuration contents. - 14 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 1 (0 bug-severity).
Findings
🟠 Issue 1 — New limiter cleanup lane deletes at most ~40 rows/hour across seven IP-keyed policies and can fall permanently behind
worker/src/knowledge-maintenance.ts:34 · risk · identified by z-ai/glm-5.3-flash
The fix for the unswept durable limiters adds a cleanup lane, but its throughput is far below the row-creation rate of the limiters it must cover, so expired window rows can still accumulate without bound once the feature is activated.
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 137d8dd41a125ad181102f6a2927aa21d8eeaad4
Judge: openai/gpt-5.6-luna
Cost: $0.3070 (lanes $0.3065 + judge $0.0006)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 37.3s, 367618+1373 tokens (287127 cached), 4 tool round(s), via Azure, $0.27)z-ai/glm-5.3-flash: ok (1 finding(s), 555.9s, 327319+47058 tokens (147490 cached), 2 tool round(s), via OpenInference, $0.0384)
Round 3 resolution
⚠️ r2-1fixed incorrectly — New limiter cleanup lane deletes at most ~40 rows/hour across seven IP-keyed policies and can fall permanently behind: Cleanup capacity is substantially improved, but sustained row creation can still exceed it. For example, 50 distinct IPs using only the browser API in each five-minute window create 600 counters/hour, exceeding the new ceiling of 580 physical rows/hour before descriptors, live windows, retries, and cursor-cycle overhead consume scan slots.
knowledge-maintenance.ts now scans 20 rows per invocati…
- Open findings after this round: 2 (0 bug-severity).
Findings
🟠 Issue 1 — Report-context draft-generation fence removed without a visible replacement
worker/src/knowledge-runtime.ts · risk · identified by z-ai/glm-5.3-flash
In the rewritten report flow in worker/src/knowledge-runtime.ts, the host no longer re-reads the draft after the requirements/evidence reads to fence them. The diff deletes the block that threw 409 'report_target_changed' when draft.generation !== latestDraft.generation (with the comment "The final draft generation fences the requirements/evidence reads") and replaces the return with return observed.context.
If observed is built without an equivalent generation re-check, a report can now be assembled from a draft/requirements pair that was concurrently modified between the two reads; previously the host surfaced a clean 409 so the caller could retry against the new generation. The removed comment also noted the SDK separately rechecks governance around evidence acceptance, so whether this is a real hole depends on whether that SDK recheck validates draft generation or only permission/governance state.
Proof gap: the embedded diff is truncated around this hunk and the observed construction above it is not shown, so the fence may have been relocated rather than dropped (for example into the shared read group, or made redundant by the SDK's own recheck). Please confirm the draft-generation consistency check still runs on the report path, or document why the SDK recheck makes the host-side fence unnecessary.
|
For r3-1, the draft-version fence moved into the published KB The released getAuthoringContext implementation explicitly confirms the article's opaque head version alongside collection and validation versions before returning context. confirmResourceVersions re-reads those heads and rejects changed or missing versions. The one-use confirmation checks the same tuple later in report query and decision paths; this covers the article, not only governance or permission state. The upstream read-context race test changes the actual draft on its second head read and requires a conflict. The report-query race test changes the draft immediately before confirmation and requires This rebuts the alleged lost initial snapshot check, not a new distributed-atomicity guarantee. The separate cleanup-capacity finding is being corrected. This round was incremental; full-PR review remains required before merge. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da9a8622a2
ℹ️ 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".
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: full-pr (full-pr)
Mode: verify
Commit: da9a8622a22e7bb2f3947d2c61b2df12a2abd974
Judge: openai/gpt-5.6-luna
Cost: $0.6372 (lanes $0.6371 + judge $0.0001) + at least $0.15 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 69.9s, 1046114+3247 tokens (861914 cached), 5 tool round(s), via Azure, $0.64)z-ai/glm-5.3-flash: ok (0 finding(s), 853.3s, 4002865+41852 tokens (3559476 cached), 20 tool round(s), 1 retried request(s), salvaged finish, via OpenInference, at least $0.15 (incomplete))
Round 4 resolution
- ✅
r2-1fixed correctly — New limiter cleanup lane deletes at most ~40 rows/hour across seven IP-keyed policies and can fall permanently behind: The current schedule assigns 39 isolated limiter invocations per hour, each scanning at most 20 physical rows, rather than the original approximately 40 rows/hour. The continuing-load regression creates 672 counters/hour for four hours, checks expired backlog and oldest-expiry age at comparable workload phases, and verifies subsequent drainage. Real-D1 tests cover whole scheduled invocations, incl… - 🤝
r3-1disputed — Report-context draft-generation fence removed without a visible replacement: The current host pins KB 0.1.4 and passes the application's real getAuthoringContext/confirmAuthoringContext pair to the shared report factory. Its fallback readContext also uses getAuthoringContext rather than separate unfenced draft and requirements reads. The supplied technical rebuttal identifies the released aggregate's article-head confirmation and upstream draft-race tests, explaining why a… - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: verify
Commit: ea8962026e14acc84124dd79787b0ff67d289e92
Judge: openai/gpt-5.6-luna
Cost: $0.5826 (lanes $0.5806 + judge $0.0020) + at least $0.11 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 49.4s, 698608+2264 tokens (517223 cached), 3 tool round(s), via Azure, $0.58)z-ai/glm-5.3-flash: ok (3 finding(s), 878.2s, 1857186+53082 tokens (1276160 cached), 7 tool round(s), 1 retried request(s), salvaged finish, via Modal, at least $0.11 (incomplete))
Round 5 resolution
- No prior findings were open.
- Open findings after this round: 3 (0 bug-severity).
Findings
🟠 Issue 1 — Merge deploys a fifth cron expression; the account-wide cron confirmation is deferred to pre-activation but is needed at merge
worker/wrangler.jsonc:37 · risk · identified by z-ai/glm-5.3-flash
The new RATE_LIMIT_CRON (0-57 * * * *) is a real Cloudflare cron trigger, and .github/workflows/deploy.yml runs pnpm run worker:deploy on every push to main. The fifth trigger is therefore installed at merge time, independent of PEGMA_KNOWLEDGE_ENABLED=false — the limiter-cleanup lane is documented to run "independently of the Knowledge flag".
docs/KNOWLEDGE_COMPOSITION.md frames the capacity question as a pre-activation gate ("Before activation, confirm account-wide cron usage: this configuration already uses five expressions and does not add a sixth for retrieval"), but the cron deploy is not gated by any flag or acceptance step, so that confirmation actually becomes load-bearing when the PR merges.
On the Workers Free plan the account-wide cron trigger allowance is 5, and main already deploys four expressions. The merge lands exactly at that allowance with zero headroom; if anything else in the account consumes cron triggers (or the account's effective cap is lower), wrangler deploy fails closed and the Deploy job blocks main.
The schedule arithmetic itself is correct — I verified the 39 rate pages / 19 ready pages per hour split from rateKnowledgeLaneAt (the epoch minute at every UTC hour boundary is congruent to 0 mod 3, so wall-clock minute equals the residue; minutes 0-57 minus the nineteen residue-2 minutes give 39 rate and 19 ready lanes). The concern is only account capacity at deploy time.
I checked .github/workflows/deploy.yml, worker/wrangler.jsonc, worker/src/index.ts, and the maintenance-schedule tests. I could not observe the live Cloudflare account, so the actual headroom is unverified; that gap is the substance of this risk.
🔵 Issue 2 — Stale "not yet on npm" prose left behind by the DynamoDB publication bump
src/pages/runbooks.md:20 · nit · identified by z-ai/glm-5.3-flash
This PR makes @pegma/storage-dynamodb machine-readably published — it adds the '0.4.5' pin to EVAL_NPM in evals/assembly-eval.test.ts and rewrites the component-page enrichment in src/data/catalog-enrichment.ts to drop "Requires pegma-dev/storage-core#7 to be merged ... Not yet on npm." — but leaves the consumer-facing prose that still calls the adapter unpublished:
src/pages/runbooks.mdline 20: "requires that adapter PR to be merged beforepnpm addsucceeds"src/pages/runbooks/aws.md: "Ifpnpm add @pegma/storage-dynamodbfails because the package is not on npm yet, stop ..." plus the matching troubleshooting rowsrc/pages/examples.astro: the adapter still described as gated on the unmerged PRpublic/llms.txt: "AWS (DynamoDB via forthcoming@pegma/storage-dynamodb)"docs/catalog/RECIPE_BACKLOG.md: "forthcomingstorage-dynamodb"recipes/bench-ticket/composition.ts: "once published" comments
A reader following the AWS runbook will now find pnpm add @pegma/storage-dynamodb succeeding while the docs instruct them to stop and wait for a merge; the compiled site catalog (versions resolved from live npm at build time) advertises the adapter while its own linked runbook says it does not exist.
This fails safe rather than wrong: src/data/compile-catalog.ts documents that version authority is npm at compile time and "Never parse versions from registry now prose", and the components.ts now string this PR touched is explicitly labeled "Fallback snapshot (2026-08-15)". So this is stale-doc follow-through on the PR's own publication-status change, not a functional defect.
🟠 Issue 3 — Agent report POST lacks the body deadline applied to the staff command route
worker/src/knowledge-api.ts:320 · risk · identified by z-ai/glm-5.3-flash
The staff-command route reads its body with a deadline — readJson(request, { timeoutMs: 10_000 }), backed by the dedicated suite worker/src/knowledge-body-deadline.test.ts — but the parallel agent-facing /api/knowledge/reports POST branch in worker/src/knowledge-api.ts calls plain readJson(request) with no timeoutMs.
A holder of a valid bearer token can trickle request bytes to keep that invocation parked in streaming reads for as long as the platform tolerates; the 64 KiB JSON_LIMIT caps bytes, not time. Since the PR description claims "bounded request handling" for the new KB routes and treats hung body reads as a first-class hardening concern for the staff path, the same bound should apply to this route.
Mitigations I verified: agents.protectedResource.authenticate(request) completes before the body read, so the path already requires a live grant; the byte cap still applies; and pre-existing endpoints (e.g., Support Desk POSTs via the same readJson) share the same no-deadline posture, so this is a hardening inconsistency within the PR rather than a new unauthenticated primitive. The repair is mechanical — pass the same option (or an SDK-transport-equivalent bound) at the reports POST readJson call.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
R5-2 is addressed in 4c6dbfa: the six flagged public runbook/example/backlog/fixture surfaces now reflect published DynamoDB 0.4.5. Existing AWS code snippets and executable fixture code are unchanged. The committed host and CI still use MemoryStore; package publication does not establish an AWS deployment. |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: verify
Commit: 4c6dbfad738109a2227c990c1153a7381d64bd0c
Judge: openai/gpt-5.6-luna
Cost: $0.7996 (lanes $0.7989 + judge $0.0008)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 63.8s, 1472228+3065 tokens (1274678 cached), 7 tool round(s), via Azure, $0.72)z-ai/glm-5.3-flash: ok (1 finding(s), 179.1s, 1369037+25552 tokens (790272 cached), 5 tool round(s), via Particle AI, $0.0817)
Round 6 resolution
- ✅
r5-1fixed correctly — Merge deploys a fifth cron expression; the account-wide cron confirmation is deferred to pre-activation but is needed at merge: The operator guide now explicitly requires an account-wide Cron Trigger inventory before merge, explains that main deploys the five schedules even while Knowledge is disabled, and requires holding the merge if the replacement exceeds the effective allowance. This matches the deploy workflow and scheduler. The supplied reply reports four existing triggers and no triggers on another Worker; that liv… - ✅
r5-3fixed correctly — Agent report POST lacks the body deadline applied to the staff command route: The report POST branch now callsreadJson(request, { timeoutMs: 10_000 }). The helper enforces one total streaming-read deadline, cancels without awaiting a potentially hanging cancellation, and releases its reader lock. Actual bearer/AA+KB regressions cover stalled input, late trickled input, and timely completion, asserting 408 without a report commit for timeout cases and one pending report f… - 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).
Warning
z-ai/glm-5.3-flash: coverage claims 1 finding(s) in 'worker/src/agent-access-api.ts' but 0 were reported
Findings
🟠 Issue 1 — New /api/knowledge/portal and /api/agent-access/approval POST routes still lack the total body deadline
worker/src/knowledge-api.ts:425 · risk · identified by z-ai/glm-5.3-flash
A credential holder can trickle request bytes to park a Worker invocation indefinitely on two of the PR's new authenticated POST routes — the same mechanism that this fix round just removed from the agent report route. The 64 KiB JSON_LIMIT caps bytes, not time, and both routes complete authentication before reading the body, so a valid-credential request reaches the unbounded read.
worker/src/knowledge-api.ts:425— the shared body read isreadJson(request, staffCommand ? { timeoutMs: 10_000 } : undefined), so/api/knowledge/portalPOST getsundefined. Session, same-origin, CSRF andarticleReadauthority are all verified inrequireCurrentBrowserAccessimmediately before it.worker/src/agent-access-api.ts:128— the consent approval POST uses plainreadJson(request)with notimeoutMs.options.limit, header capture, andrequireAgentBrowserContext(Admin + CSRF + same-origin) all run first.
The repair is the same one already applied twice in this PR: pass { timeoutMs: 10_000 } as the staff command route and, as of this round, the report POST (worker/src/knowledge-api.ts:300) now do. This also reconciles the code with the PR/docs claim that new KB/agent-access routes use "bounded request handling".
I checked all readJson( call sites at the head commit: every other caller (identity-api.ts, support-api.ts, admin-api.ts) is pre-existing and unchanged by this PR, so only these two new routes carry the gap. Exposure is limited to holders of valid browser credentials (self-DoS or a hijacked session), which is the same threat standard the staff route and the report route were held to.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: full-pr (full-pr)
Mode: verify
Commit: 69722b44a335f1825e5591b7250f0605a0a3784b
Judge: openai/gpt-5.6-luna
Cost: $0.7997 (lanes $0.7996 + judge $0.0001)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 66.2s, 930362+3216 tokens (732116 cached), 4 tool round(s), via Azure, $0.66)z-ai/glm-5.3-flash: ok (0 finding(s), 351.9s, 1750013+37666 tokens (1116288 cached), 7 tool round(s), via Mistral, $0.14)
Round 7 resolution
- ✅
r6-1fixed correctly — New /api/knowledge/portal and /api/agent-access/approval POST routes still lack the total body deadline: Both affected routes now pass{ timeoutMs: 10_000 }toreadJson: the shared portal/staff POST read inworker/src/knowledge-api.ts:425and consent approval inworker/src/agent-access-api.ts:128. The shared reader enforces one total deadline, cancels without awaiting cancellation, and releases its lock. Existing admission and post-body/final authority checks remain. The committed tests cover… - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Adds a governed knowledge base to the existing account and staff interfaces. Staff can author guides, review test reports, and approve exact article revisions. Current admins can link local tools through device authorization or PKCE; linked agents receive draft and test-report scopes. Private verification details remain behind staff permissions.
Consumes published KB
0.1.4, Agent Access0.1.1, and D10.4.6over Core0.4.0. The host uses the SDK's version-fenced authoring-context get/confirm API for shared reports. It rechecks authority across asynchronous work and withholds article, search and collection results if the session, principal or captured permissions change. Consent POSTs reauthenticate after the complete body has been validated and bind the fresh context to the original session, principal and credential headers before approval. Essential Knowledge role controls preserve existing Support authority.Maintenance keeps the same five cron expressions and isolated bounded invocations. The dedicated schedule gives rate cleanup 39 opportunities and publication-readiness hints 19 opportunities per hour, with unchanged 20-row cleanup pages and three bookmark-write attempts. Its gross limiter scan ceiling is 780 physical rows/hour, not guaranteed deletions. Physical recovery remains independent. Because pushes to
maininstall these schedules even while Knowledge is disabled, the operator must verify the entire account’s cron capacity before merge and hold the merge if the replacement does not fit. Live CPU, daily quotas and sustained production acceptance remain activation gates.Validation on Node
22.18.0:The additional dependency audit still reports the same 99 advisory/version rows as the recorded
mainbaseline; this is not a clean audit. New KB routes use the released web-standard transport and bounded request handling. Existing public-catalog and toolchain dependency maintenance remains open.PEGMA_KNOWLEDGE_ENABLEDremainsfalse, and agent registrations remain empty. Actual existing-login/client interoperability, deployed ingress/telemetry, Free-plan operational limits and supervised pilots remain separate acceptance gates. This is PG-01 source integration; customer-support model composition follows in PG-02.Public AWS runbooks and fixture comments now reflect qualified DynamoDB
0.4.5availability. The committed Bench Ticket host and CI still use MemoryStore; publication does not establish its AWS deployment.