Repository navigation
Add default-off staged support resolution learning - #61
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
|
OpenRouter review posted ( |
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f44bfe02f3
ℹ️ 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: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: f44bfe02f306894a70da6ce15c48ab2a91380541
Judge: openai/gpt-5.6-luna
Cost: $0.3747 (lanes $0.3689 + judge $0.0058) + at least $0.16 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (5 finding(s), 130.1s, 555494+5257 tokens (460806 cached), 6 tool round(s), via Azure, $0.37)z-ai/glm-5.3-flash: ok (10 finding(s), 966.0s, 3877599+94268 tokens (3543108 cached), 30 tool round(s), 1 retried request(s), salvaged finish, via OpenInference, at least $0.16 (incomplete))
Findings
🔴 Issue 1 — One-way exclusion between ordinary and learning writes
public/staff-support-ticket.js:567 · bug · identified by openai/gpt-6.1-sol
A staff member can start an ordinary reply or lifecycle mutation and then submit a learning action while the ordinary request is still awaiting its response. If both acknowledgements are lost, the page can retain both packets: ordinary controls are blocked by learningPending(), while syncLearning() hides the learning retry controls because ordinaryPacket exists.
learningOccupied() prevents ordinary operations from starting during learning operations, but the reverse direction is not fenced. sendOrdinaryPacket() and the takeover handler call beginOperation() without suspending the learning panel. Its controls remain enabled, and its readSession adapter does not reject an ordinary busy state or an existing ordinary/takeover packet. Suspend the panel before starting those operations, or provide a bidirectional operation-admission guard.
I checked patchTicket, the compose submission handler, takeover, syncLearning, and the panel's submission guards. The integration test covers ordinary controls during an awaited learning request, but not learning controls during an awaited ordinary request.
🔴 Issue 2 — Unrecoverable pending actions after permanent binding conflicts
public/staff-support-learning.js:340 · bug · identified by openai/gpt-6.1-sol
If another author edits the draft between displaying it and submitting a review, the server returns 409, but the panel permanently retains that review packet. Its exact retry cannot succeed against the changed target. All new learning writes and ordinary ticket writes remain blocked until the user unloads the page and discards the unresolved intent.
The same problem occurs after a committed review loses its acknowledgement and the source is subsequently reopened or withdrawn: the HTTP handler calls proposal() before reaching SDK replay, so its current-generation and eligible-state checks reject the historical packet. Policy expiration or replacement can similarly prevent acknowledgement recovery. There needs to be an authenticated terminal-outcome mechanism that distinguishes a durable historical acknowledgement or a confirmed non-applied command from an unresolved write, without rebinding the command or granting current approval authority.
I checked the panel's sole pending = null path, the controller's write-blocking and unload guard, and the handler's review preflight. The tests explicitly retain a packet after 409 and refuse changed proposals, but provide no recovery path once that conflict is permanent. Arbitrarily clearing every 409 would not safely fix lost-acknowledgement cases.
🟠 Issue 3 — Staff deadline does not bound application operations
worker/src/support-learning.ts:190 · risk · identified by openai/gpt-6.1-sol
If an injected application read or mutation never settles, readSource, readWork, enrollment, evidence submission, invalidation, or withdrawal can remain pending indefinitely despite the runtime's 25-second deadline.
The deadline is raced only against staffAccess.resolve(). After initial authorization succeeds, staff() awaits operation(access) directly. The timer aborts a controller whose signal is not passed to these application operations, and rejecting the deadline does not interrupt that await. Race the operation against the same deadline and treat a timed-out mutation as an unknown outcome; propagate cancellation where the underlying port supports it.
I checked the direct application callers and the coordinator configuration. maxOperationMilliseconds protects coordinator operations, not these direct application calls. The browser's 15-second timeout stops waiting locally but does not bound the server/runtime promise. The supplied Store/application interfaces expose no timeout guarantee that disproves this scenario.
🔵 Issue 4 — Stale installed-version and policy descriptions
package.json:34 · nit · identified by openai/gpt-6.1-sol
Operators inspecting the existing composition guides or /health will receive versions that no longer describe the installed host, making release diagnosis and authorization-policy auditing misleading.
The dependency and policy changes leave these current-state descriptions unchanged:
worker/src/index.ts:200reports@pegma/support-desk-application@0.2.0in health metadata, although the manifest installs0.2.1.docs/SUPPORT_COMPOSITION.md:14–17lists Support0.2.0, and line 59 namespegma.dev-policy-4rather than policy 5.docs/KNOWLEDGE_COMPOSITION.md:6–7, 19–23, and 38 still describe the current manifest and lockfile as Support0.2.0and KB0.1.4.
I checked the manifest, lockfile, current policy, both composition guides, and the production health path. Historical release-verification evidence can remain historical, but claims about the current installed graph should be updated or explicitly qualified.
🔵 Issue 5 — Unpinned source-verifier propagation seams
worker/src/support-learning.test.ts:100 · nit · identified by openai/gpt-6.1-sol
A future omission of privateSources from any of the newly changed host factories could silently make learned articles unavailable during request or repair processing while all new learning assembly tests continue to pass.
The learning fixture constructs createKnowledgeBaseApplication() directly. Consequently, its publication and reopening cases do not exercise verifier propagation through createKnowledgeRuntime, createKnowledgeRetrievalReady, or createKnowledgeRetrievalMaintenance. Add focused cases through those actual host factories, including current-source acceptance and reopening or withdrawal denial, so removing a forwarding argument fails a test.
I searched privateSources usages and checked the learning assembly, runtime, ready, and maintenance tests. The forwarding implementation currently appears correct; the concrete gap is that none of these new security-sensitive propagation paths is pinned by a test supplying a source verifier.
🟠 Issue 6 — Human review path silently falls back to a disabled check policy when the optional checks port is omitted
worker/src/support-learning.ts:118 · risk · identified by z-ai/glm-5.3-flash
A host that composes the learning runtime with some processing ports but no checks port (processing intentionally off) gets a review/reconcile coordinator whose checks is the built-in disabledChecks, whose resolvePolicy returns { outcome: 'disabled' } and whose check returns { outcome: 'held' }. The docs promise that review rereads the current trusted check policy and binds it before the SDK guard, so an approval against such an assembly either fails with a held result or binds a 'disabled' policy rather than the real policy — and nothing surfaces that the port was missing. Only scanCandidates/processWork are gated by processingReady(), which does flag a missing checks port as learning_unavailable; reviewProposal, withdraw and reconcileSource run through the base coordinator with the silent fallback.
Evidence: in worker/src/support-learning.ts coordinatorOptions.checks = ports.checks ?? disabledChecks, while the required-port list in processingReady() includes ports.checks — showing the author considers it required for processing but substitutes a disabled stub everywhere else.
Proof gap: the SDK (@pegma/support-desk-ai) internals are not visible in the diff, so I could not confirm whether reviewProposal actually invokes checks.resolvePolicy. If review never consults the check policy, this downgrades to a nit.
🟠 Issue 7 — Native D1 suite truncates the shared IDENTITY_DB before every test, breaking isolation with any concurrent D1 suite
worker/src/support-learning.d1.test.ts:20 · risk · identified by z-ai/glm-5.3-flash
If this file runs in the same vitest worker/binding pool as the other 60+ native D1 cases the PR body mentions (64 Native D1 cases repo-wide), beforeEach here executes DELETE FROM RECORDS and DELETE FROM PEGMA_STORAGE_D1_TX_GUARD against env.IDENTITY_DB — the shared binding. Any other native D1 test file that seeds rows in the same database and runs concurrently or interleaved loses its data, producing order-dependent flakes and cross-suite failures that look like product bugs.
Evidence: worker/src/support-learning.d1.test.ts lines 19–23 delete from the shared binding without scoping to a learning-specific partition, and the beforeAll probe writes into the same DB. I could not grep the repo before the deadline to enumerate which other suites share env.IDENTITY_DB, so the concurrency trigger is unconfirmed — but the blast radius is the entire native D1 suite if the binding is shared.
🟠 Issue 8 — Panel retry-packet closing check compares CSRF tokens for equality, so legitimate token rotation can wedge the unresolved packet
public/staff-support-learning.js:250 · risk · identified by z-ai/glm-5.3-flash
A staff member performs a mutation, the server responds with a rotated csrfToken (the documented success contract is {result, csrfToken}, implying per-response rotation), and their pending packet's expected session snapshot still holds the old token. On the closing same-session check, sameSession(next, expected) compares left.csrfToken === right.csrfToken; with a rotated-but-legitimate token this fails, the packet stays unresolved with a session_changed 401, and the operator must fall back to the manual fresh-read-plus-retry recovery even though nothing about their session actually changed.
Evidence: public/staff-support-learning.js defines sameSession as subject and csrfToken equality and viewer() enforces (expected && !sameSession(next, expected)). The PR body claims the panel "preserves retries through session changes", which rotation arguably is.
Proof gap: the call sites that pass expected into viewer() are in the portion of the panel diff not embedded, and the server's actual CSRF rotation policy lives in support-learning-handlers.ts/support-api.ts, which I could not open before the deadline. If the CSRF token is stable for the session lifetime, this downgrades to a nit.
🔵 Issue 9 — Exceptions from the processingEnabled readiness callback are swallowed and misreported as learning_disabled
worker/src/support-learning.ts:108 · nit · identified by z-ai/glm-5.3-flash
When the host's readiness callback throws transiently (for example a failed KV/config read), processingEnabled() catches every exception and returns false, so scanCandidates/processWork return { outcome: 'held', reason: 'learning_disabled' }. An operator diagnosing why generation is stuck sees "disabled" — implying a deliberate switch-off — when the real cause is a callback failure, and a permanently misconfigured callback that always throws silently disables processing with no distinguishing signal anywhere.
Evidence: worker/src/support-learning.ts defines processingEnabled = () => { try { return options.processingEnabled?.() === true; } catch { return false; } }.
🔵 Issue 10 — Duplicated 25-second deadlines race each other, and the wrapper's AbortController is not threaded into the SDK operation
worker/src/support-learning.ts:148 · nit · identified by z-ai/glm-5.3-flash
Two independent 25-second timers decide the failure mode of a hung operation: the staff() wrapper's setTimeout(..., 25_000) aborts and throws SupportLearningUnavailableError, while the coordinator is constructed with maxOperationMilliseconds: 25_000. Whichever fires first (subject to timer jitter and scheduling) determines whether the caller sees the host error or the SDK timeout, making the error class for the same hang nondeterministic. Additionally, the wrapper's controller.abort() in finally only reaches staffAccess.resolve; the SDK invoke callback receives no signal, so a hung SDK mutation can still commit after the wrapper already reported unavailability. The lost-ACK replay contract covers the commit side, but the double deadline is fragile duplication that should be one value derived from the other.
🔵 Issue 11 — staff() swallows the original staffAccess.resolve rejection, conflating authorization-store outages with availability and hiding root causes
worker/src/support-learning.ts:158 · nit · identified by z-ai/glm-5.3-flash
If the host staff resolver rejects (D1 failure, network error, bug in the host resolver), the try { ... } catch { throw new SupportLearningUnavailableError(); } around Promise.race([staffAccess.resolve(...), deadline]) discards the original error including its message and stack. Every such failure surfaces as the generic support_learning_unavailable code, so an operator cannot distinguish "the role store is down" from "the wrapper deadline fired" without correlating logs, and a host-resolver bug is masked behind an availability error.
🔵 Issue 12 — Malformed learning query returns 403 forbidden instead of a 400 input-validation error
worker/src/support-learning-routing.test.ts · nit · identified by z-ai/glm-5.3-flash
A staff member who fat-fingers or a client that mis-builds the proposal query (e.g. /learning?role=Support) gets HTTP 403 with { error: 'forbidden' } because the current-authority fence is evaluated before query validation. Genuine authorization failures and malformed requests are indistinguishable to clients and to log-based analysis: an access probe and a typo produce identical responses. The routing test pins this behavior deliberately ("The closing real current-authority fence wins over the malformed query"), so it may be intended, but it trades diagnostic clarity for fence ordering.
🔵 Issue 13 — Compatibility alias ships a full second Knowledge Base application package into the bundle, creating a latent class-identity hazard
package.json:33 · nit · identified by z-ai/glm-5.3-flash
package.json adds @pegma/knowledge-base-ai-compat aliased to @pegma/knowledge-base-application@0.1.2, while the direct application stays at 0.1.5 — so the lockfile carries two full copies of the KB application, contracts and core (0.1.2 and 0.1.5). The alias exists only so @pegma/support-desk-ai can recognize the exact 0.1.2 error constructors, but with two module instances of the same package in the Worker bundle, any future or residual instanceof check against 0.1.2 classes on errors thrown by the 0.1.5 application silently fails (never matches). The explicit translation port in support-learning-ports.ts mitigates this today (tests pin the translation), but the duplicate-class hazard plus added bundle weight is a standing trap for the next contributor who reaches for instanceof.
🔵 Issue 14 — The whole Support role gains all four learning permissions at once, with no per-operator enrollment gate
worker/src/support-access.ts:30 · nit · identified by z-ai/glm-5.3-flash
The moment the optional learning handler is composed, every holder of the stored Support role — including operators who never opted into learning review — can submit staff-verified evidence, approve/reject exactly checked proposals, and withdraw learning sources, because SUPPORT_STAFF_PERMISSIONS unconditionally includes learningRead, learningEvidenceSubmit, learningReview and learningWithdraw. Revocation granularity is the whole role: an operator under investigation cannot be blocked from learning actions without also removing queue access. The doc presents this as intended ("four human learning permissions through the actual stored, audited Support role"), so this is a design observation rather than a bug, but the cost is real: broad review/withdraw authority rides along with queue duty.
🔵 Issue 15 — Panel viewer() applies no deadline to the host readSession() call
public/staff-support-learning.js:255 · nit · identified by z-ai/glm-5.3-flash
If the host-supplied readSession() primitive hangs (no internal timeout), the panel's await inside viewer() never resolves or rejects: every button stays in its pre-call state (assuming busy was set by the caller, which is in the truncated portion of the diff), cancelReads() only aborts controllers created in call() and cannot cancel the hung session read, and the staff member must reload the page to recover. The module's own contract elsewhere bounds everything (25s server-side wrapper, 10s body deadline), so an unbounded session read is an inconsistency.
Proof gap: the actual timeout behavior depends on the host readSession implementation in public/staff-support-ticket.js, which I could not open before the deadline; if that reader has its own timeout, this is moot.
| supportPermissions.manage, | ||
| supportPermissions.auditRead, | ||
| supportPermissions.takeOver, | ||
| supportPermissions.learningRead, |
There was a problem hiding this comment.
🔵 The whole Support role gains all four learning permissions at once, with no per-operator enrollment gate (nit)
The moment the optional learning handler is composed, every holder of the stored Support role — including operators who never opted into learning review — can submit staff-verified evidence, approve/reject exactly checked proposals, and withdraw learning sources, because SUPPORT_STAFF_PERMISSIONS unconditionally includes learningRead, learningEvidenceSubmit, learningReview and learningWithdraw. Revocation granularity is the whole role: an operator under investigation cannot be blocked from learning actions without also removing queue access. The doc presents this as intended ("four human learning permissions through the actual stored, audited Support role"), so this is a design observation rather than a bug, but the cost is real: broad review/withdraw authority rides along with queue duty.
There was a problem hiding this comment.
Stored Support membership grants the named human learning capabilities under the approved role model. Fresh draft and provenance access use the current Knowledge permissions. The deployment and processing configuration remains an explicit host choice. Current source.
| }); | ||
| } | ||
| async function read(kind) { | ||
| if (!ready || !canReadWork() || (kind === 'proposal' && work?.hasProposal !== true)) return; |
There was a problem hiding this comment.
🔵 Panel viewer() applies no deadline to the host readSession() call (nit)
If the host-supplied readSession() primitive hangs (no internal timeout), the panel's await inside viewer() never resolves or rejects: every button stays in its pre-call state (assuming busy was set by the caller, which is in the truncated portion of the diff), cancelReads() only aborts controllers created in call() and cannot cancel the hung session read, and the staff member must reload the page to recover. The module's own contract elsewhere bounds everything (25s server-side wrapper, 10s body deadline), so an unbounded session read is an inconsistency.
Proof gap: the actual timeout behavior depends on the host readSession implementation in public/staff-support-ticket.js, which I could not open before the deadline; if that reader has its own timeout, this is moot.
There was a problem hiding this comment.
The actual readSession adapter uses readViewer through api, whose request and body read share the existing fifteen-second deadline. Controller suspension aborts those tracked requests. Current source.
|
The remaining merge blocker is the complete staff approval workflow under Workers Free. A real Native D1 run through the registered HTTP route, sessions, roles and durable limiter reaches the 50-call ceiling before the final commit guard. The successful tail still needs independent current evidence checks, so trimming a few reads cannot qualify this workflow. The shared read-observation fix is merged in Support Desk #50. Storage #13 adds opt-in mixed keyed/partition batching and is in current-head review and CI. Implementation is underway for an opt-in durable staged review. HTTP records the exact staff command, then separate worker invocations perform the preparation and final fresh verification. The final review, audit and receipt share one ticket-partition transaction. Each stage resolves the original actor’s current authority. Exact replay, cancellation and superseded-worker fences remain required. Activation remains disabled while the complete per-invocation tests and review gates run. |
|
Integration status on November 11. The merge overlap with current main has been resolved locally. The revised implementation uses opt-in durable staged learning reviews, with separate queue invocations to fit the Workers Free D1 budget. Its development graph passed 1,002 Node tests, 121 real-D1 tests and two bench tests, plus type checks and build. The updated source requires Support Desk 0.2.5 for the staged-review APIs. That release is being prepared in pegma-dev/support-desk#52, which has a clean current review and passing CI on Node 22 and 24. Storage D1 0.4.7 is already published and adopted locally. The next steps are verified public 0.2.5 publication, installation of all five exact public packages, complete validation on that graph, then the updated branch push and fresh PR review/CI. The remote head still represents the earlier implementation. Customer AI and related activation switches remain OFF. |
f44bfe0 to
3a4e5c6
Compare
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Keep them coming! 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.
OpenRouter pull-request review
Verdict: issues
Scope: rebase (full-pr)
Mode: verify
Commit: 3a4e5c6a3924acad5764db7173046380f360166f
Judge: openai/gpt-5.6-luna
Cost: $0.8355 (lanes $0.8321 + judge $0.0033)
Lanes
openai/gpt-6.1-sol: ok (7 finding(s), 252.2s, 1332420+8895 tokens (1170620 cached), 8 tool round(s), via Azure, $0.67)z-ai/glm-5.3-flash: ok (1 finding(s), 387.6s, 2959653+64375 tokens (2617728 cached), 16 tool round(s), via Together, $0.16)
Round 2 resolution
- ✅
r1-1fixed correctly — One-way exclusion between ordinary and learning writes:beginOperation()now suspends and hides the learning panel before ordinary operations await anything.requireLearningAdmission()also rejects ordinary busy/pending states in both session and request adapters. Actual integration cases cover patch, reply and takeover through deferred and unknown acknowledgements. ⚠️ r1-2fixed incorrectly — Unrecoverable pending actions after permanent binding conflicts: Complete immutable review intents, historical receipt lookup and sticky cancellation correctly repair the original review examples, including reopening, draft edits and Knowledge revocation. However, the same permanent-binding-conflict mechanism remains for enrollment and evidence packets with obsoleteexpectedRevision: only review packets have terminal receipt/cancellation recovery, and non-rev…- ✅
r1-3fixed correctly — Staff deadline does not bound application operations:staff()now races the operation itself, as well as authority resolution, against one staff deadline. Deferred application-read and late enrollment tests verify bounded return, aborted authority signals and exact replay of a late committed mutation. - ✅
r1-6fixed correctly — Human review path silently falls back to a disabled check policy when the optionalchecksport is omitted: The fallback policy now reportsunavailable, notdisabled, and legacy review explicitly rejects missing checks withreview_checks_unavailable. Real-review and HTTP policy-unavailability tests verify refusal without review effects; historical receipt recovery intentionally avoids obsolete checks. - 🤝
r1-7disputed — Native D1 suite truncates the shared IDENTITY_DB before every test, breaking isolation with any concurrent D1 suite: The proposed shared-database concurrency trigger does not apply to the configured Workers test pool's default file isolation.vitest.d1.config.tsdoes not disable isolation, and repository searches found no concurrent tests or shared-worker override. Clearing this file's isolated binding therefore does not truncate another suite's database. - 🤝
r1-8disputed — Panel retry-packet closing check compares CSRF tokens for equality, so legitimate token rotation can wedge the unresolved packet: The host uses a per-session synchronizer token, not per-response rotation.identity-api.tscreates the token with a new session and session reads return the stored token; learning responses return that same credential after the original-session fence. Equality detects session replacement, while owner recovery after a new login uses refreshed credentials with unchanged command bytes. ⚠️ r1-4fixed incorrectly — Stale installed-version and policy descriptions: Health metadata, Support's principal version list and policy description now match the selected graph. Current-state descriptions remain stale elsewhere: both composition guides still identify D1 0.4.6, and the Worker README and assistant-stage guide identify current Support 0.2.3 despite the 0.4.7/0.2.5 manifest and lockfile.- ✅
r1-5fixed correctly — Unpinned source-verifier propagation seams:support-learning-composition.test.tsnow exercises the actual request, ready and physical-maintenance factories with the live verifier. It verifies accepted publication and denial after reopening, withdrawal or ticket removal, including fail-closed omission. - ✅
r1-9fixed correctly — Exceptions from theprocessingEnabledreadiness callback are swallowed and misreported aslearning_disabled: Throwing readiness now produces a distinctlearning_readiness_unavailableheld result rather thanlearning_disabled. Tests cover both processing and candidate scanning, with no domain effects or private error disclosure. - ✅
r1-10fixed correctly — Duplicated 25-second deadlines race each other, and the wrapper's AbortController is not threaded into the SDK operation: The ordinary staff review path no longer configures an independent coordinator deadline and passes the staff boundary's signal into SDK operations. Its current-review guards also check that boundary around proof. Tests cover deadline signal propagation and refusal after delayed target reads; staged phases have separate physical-invocation boundaries. - ✅
r1-11fixed correctly —staff()swallows the originalstaffAccess.resolverejection, conflating authorization-store outages with availability and hiding root causes: Authority resolver failures are now classified asstaff_authority_unavailable, while deadline failures retainstaff_deadline. The regression test verifies that distinction. Original dependency text and causes remain intentionally opaque rather than being exposed through the runtime error. - 🤝
r1-12disputed — Malformed learning query returns 403forbiddeninstead of a 400 input-validation error: The cited routing case submits the malformed query as an Admin-only actor without Support authority, so its closing 403 is correct. For an authorized staff actor, malformed queries yield 400; handler tests cover invalid work queries. The original finding conflated an unauthorized probe with an authorized input error. - ✅
r1-13fixed correctly — Compatibility alias ships a full second Knowledge Base application package into the bundle, creating a latent class-identity hazard: The compatibility alias is absent from the manifest and lockfile. Support AI 0.2.5 selects the same KB 0.1.5 packages as the host, and the forwarding port preserves genuine KB error instances without constructor translation. - 🤝
r1-14disputed — The whole Support role gains all four learning permissions at once, with no per-operator enrollment gate: Learning authority is intentionally represented by the stored Support role rather than an additional enrollment credential. This is a role-granularity tradeoff, not a demonstrated authorization defect. New proposal/review proof additionally requires separately current Knowledge draft/provenance permissions; human processing and agent learning scopes remain absent. - 🤝
r1-15disputed — Panelviewer()applies no deadline to the hostreadSession()call: The actual hostreadSessionadapter callsreadViewer(), which usesapi()with the existing fifteen-second request/body race. Controller suspension also aborts those tracked requests. The injected-reader hang assumed by the finding is not present in the current integration. - Open findings after this round: 10 (3 bug-severity).
Warning
z-ai/glm-5.3-flash: coverage claims 1 finding(s) in 'docs/SUPPORT_COMPOSITION.md' but 0 were reported
Findings
🔴 Issue 1 — Permanent conflicts still strand non-review packets
public/staff-support-learning.js:455 · bug · identified by openai/gpt-6.1-sol
If another operator changes the ticket revision before enrollment or evidence submission, the retained packet can become permanently unexecutable. Exact retries retain the obsolete expectedRevision, while the pending packet blocks both new learning actions and ordinary ticket writes.
The new receipt and cancellation protocol repairs review recovery, but it is restricted to packets with review === true. Enrollment and evidence packets still have only submission retry; send() clears them only after a successful mutation acknowledgement. Refreshing the ticket does not change the retained JSON bytes or settle the failed command.
I checked packet(), send(), retry(), the controller's learningOccupied() guard, and the handler's enrollment/evidence branches and conflict mapping. The panel tests explicitly retain enrollment packets after 409, but restore a successful synthetic response rather than exercise a permanently stale revision. Extend authenticated terminal-outcome recovery to these commands without treating every conflict as proof of non-application.
🔴 Issue 2 — Calendar-dependent native authentication fixtures
worker/src/support-learning-staged-review-fixture.ts:86 · bug · identified by openai/gpt-6.1-sol
Once the real runner clock passes the synthetic session's absolute expiry, the two clocked-authentication Native D1 cases will receive 401 instead of reaching their budget assertions. Their sessions are created relative to the fixed November 10, 2026 learning clock, but the actual browser fence compares expiry against real Date.now().
createStagedReviewFixture() supplies authClock to createSessionStore(), and that clock advances from the constant in support-learning-fixtures.ts:57. supportHumanBrowser() independently rejects Date.now() >= expiresAt. Advancing the synthetic clock by milliseconds or two seconds cannot keep it aligned with the calendar.
I checked both clockedAuthentication: true callers in support-learning-review-queue.d1.test.ts and their shared fixture; neither freezes the JavaScript wall clock. The installed Sessions implementation is not tracked here, so the exact calendar failure date depends on its default lifetime, but the conflicting clock domains and expiry comparison are explicit. Anchor the fixture to a current clock or consistently control both clock domains.
🟠 Issue 3 — Unqualified production queue deployment credential
worker/wrangler.jsonc:57 · risk · identified by openai/gpt-6.1-sol
The next automatic production deployment can fail before Pages deployment when Wrangler registers the newly configured queue consumer using the existing script-and-route-only credential. The learning flag being false does not prevent Wrangler from applying queue configuration.
worker/wrangler.jsonc now declares a producer, consumer and dead-letter queue. .github/workflows/deploy.yml invokes worker:deploy with CLOUDFLARE_WORKER_API_TOKEN, whose documented authority is only Workers Scripts Edit and Workers Routes Edit. Managing queue consumers requires queue-management authority; provisioning queue resources beforehand does not establish that the deployment credential can attach or update their consumers.
I checked the deployment workflow, worker/README.md, docs/PROJECT_PLAN.md, and the separate assistant-stage configuration. No tracked change qualifies the production credential for this additional deployment operation. The actual secret's permissions cannot be inspected in this review, so whether it has already been updated is a material proof gap. Qualify and document the narrowly scoped queue deployment permission before merging this unconditional configuration.
🔵 Issue 4 — Remaining stale installed-package descriptions
docs/SUPPORT_COMPOSITION.md:38 · nit · identified by openai/gpt-6.1-sol
Operators following the current composition documentation still receive package versions that disagree with this PR's installed graph.
Remaining instances include:
docs/SUPPORT_COMPOSITION.md:38lists D10.4.6, while the manifest and lockfile select0.4.7.docs/KNOWLEDGE_COMPOSITION.md:58–59explicitly describes the current manifest and lockfile as selecting D10.4.6.worker/README.md:198–209describes the current Support application and optional AI selection as0.2.3, rather than0.2.5.docs/SUPPORT_ASSISTANT_STAGE.md:54likewise calls Support0.2.3the current package selection.
I checked the exact manifest and lockfile pins, health metadata, and these current-state descriptions. Health and the principal Support version lists are corrected, but the documentation fix is incomplete. Historical release links and historical test counts can remain when clearly labelled historical.
🔵 Issue 5 — Missing staged-review HTTP contract
docs/SUPPORT_LEARNING.md:126 · nit · identified by openai/gpt-6.1-sol
An integrator using the document advertised as the exact learning HTTP contract cannot discover the staged admission, status and cancellation endpoints or their pending response semantics. Its route table documents only the inline review protocol, despite the current panel selecting the staged protocol when the capability is enabled.
The missing contract covers /review-queue, /review-queue-status, /review-queue-cancel, admission's 202 response, the pending phase/claim/hold/expiry DTO, and bounded status polling. The document also says there is no deployment flag, although this PR introduces PEGMA_SUPPORT_LEARNING_REVIEWS_ENABLED and documents it in the other composition guide.
I compared the table and activation section with support-learning-handlers.ts, staff-support-learning.js, index.ts, and SUPPORT_COMPOSITION.md. The inline contract remains useful, but it needs an explicitly separate staged contract and an accurate explanation that the flag alone cannot activate the missing trusted composition.
🔵 Issue 6 — Stale cleanup rotation descriptions
docs/KNOWLEDGE_COMPOSITION.md:384 · nit · identified by openai/gpt-6.1-sol
Operators reading the maintenance sections can still calculate cleanup cadence from an obsolete lane count, even though this PR changes the deployed rotation to sixteen lanes.
docs/KNOWLEDGE_COMPOSITION.md:384 still labels the linked implementation a 15-lane cleanup schedule. worker/README.md:174–175 and its later backlog discussion describe fourteen lanes and a 14–15-minute cadence. These disagree with CLEANUP_LANES and the updated composition sections.
I checked the schedule implementation and its day-boundary tests, which consistently use sixteen exclusive lanes. Update the remaining current schedule descriptions so the same operation is not documented with three different rotation sizes.
🔵 Issue 7 — Mojibake in source-transition documentation
docs/SUPPORT_LEARNING.md:92 · nit · identified by openai/gpt-6.1-sol
The newly added source-state explanation renders the transition as unverified0 → eligible1 instead of an arrow, making the documented transition unnecessarily confusing.
The malformed text is in the paragraph linking the real browser integration tests. Replace it with unverified0 → eligible1 or an ASCII arrow.
🔵 Issue 8 — Composition guides still describe the installed D1 adapter as 0.4.6 after this PR bumps it to 0.4.7
docs/KNOWLEDGE_COMPOSITION.md:59 · nit · identified by z-ai/glm-5.3-flash
An operator auditing the installed dependency graph against the composition guides reads that the host pins @pegma/storage-cloudflare-d1@0.4.6, while this PR's own manifest change installs 0.4.7 — release diagnosis and the guides' released-producer audit trail are wrong for the D1 adapter.
The PR bumps @pegma/storage-cloudflare-d1 from 0.4.6 to 0.4.7 in package.json and pnpm-lock.yaml, but two statements about the current graph were not updated:
docs/SUPPORT_COMPOSITION.md:38— "Peers already present on the host: …@pegma/storage-cloudflare-d1@0.4.6, …"docs/KNOWLEDGE_COMPOSITION.md:59— "The current manifest and lockfile pin released KB0.1.5,@pegma/storage-cloudflare-d1@0.4.6and genuine@pegma/storage-core@0.4.0."
Both sentences assert what the current manifest contains. Neither document contains any 0.4.7 mention or producer-verification evidence for it (grep for 0.4.7 matches only package.json and pnpm-lock.yaml), although the guides' own convention is that every installed version is a verified released producer package and must not be substituted. This is the same stale-current-graph class as earlier finding r1-4, but here it was introduced by this PR's dependency bump rather than left stale by it, so it is reported separately.
Checked: grep 0.4.7 (manifest/lockfile only), the historical 0.4.6 release-verification paragraphs in docs/KNOWLEDGE_COMPOSITION.md (framed as historical and correctly left as history), and the remaining 0.4.6 pins in evals/assembly-eval.test.ts and src/data/recipe-backlog.ts, which explicitly disclaim being claims about the installed graph.
| "producers": [ | ||
| { "binding": "SUPPORT_LEARNING_REVIEWS", "queue": "pegma-dev-support-learning-reviews" }, | ||
| ], | ||
| "consumers": [ |
There was a problem hiding this comment.
🟠 Unqualified production queue deployment credential (risk)
The next automatic production deployment can fail before Pages deployment when Wrangler registers the newly configured queue consumer using the existing script-and-route-only credential. The learning flag being false does not prevent Wrangler from applying queue configuration.
worker/wrangler.jsonc now declares a producer, consumer and dead-letter queue. .github/workflows/deploy.yml invokes worker:deploy with CLOUDFLARE_WORKER_API_TOKEN, whose documented authority is only Workers Scripts Edit and Workers Routes Edit. Managing queue consumers requires queue-management authority; provisioning queue resources beforehand does not establish that the deployment credential can attach or update their consumers.
I checked the deployment workflow, worker/README.md, docs/PROJECT_PLAN.md, and the separate assistant-stage configuration. No tracked change qualifies the production credential for this additional deployment operation. The actual secret's permissions cannot be inspected in this review, so whether it has already been updated is a material proof gap. Qualify and document the narrowly scoped queue deployment permission before merging this unconditional configuration.
There was a problem hiding this comment.
Wrangler applies the configured queue consumer independently of the runtime flag. The queue and dead-letter queue have been provisioned and read back in the deployment account.
Installed Wrangler 4.114 uses queue lookup followed by consumer creation or update. All three current Cloudflare APIs accept Workers Scripts Write, the script-write authority in the existing deployment credential contract. List queues, create consumer, update consumer.
Cloudflare describes the Scripts Edit permission as write access in its permission reference. The documented credential covers these calls through that existing grant. The README clarification records the accepted permissions and unconditional configuration behavior. Normal deployment remains part of the operational validation. Permission reference.
🛡️ 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. |
|
For body-only r1-12, the cited malformed query uses an Admin-only actor. The closing Support-authorization check yields 403. Authorized staff receive 400 for invalid work queries, as exercised in the handler tests. Handler cases. |
|
@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". |
|
Addressed body-only r2-4, r2-6 and r2-8 in 11db5fd. Current D1 and Support selections match the installed public graph, cleanup descriptions use the implemented sixteen-lane rotation, and the HTTP guide documents the staged and manual intake-recovery protocols. The full normal public-package run passed 1,023 Node tests, 125 Native D1 tests and two Bench tests, plus type checks, site build and Worker dry run. Knowledge composition, support composition, learning protocol. |
🛡️ 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: 11db5fd45ce2a28c89adbe9d030d7fefb8e60555
Judge: openai/gpt-5.6-luna
Cost: $0.3260 (lanes $0.3249 + judge $0.0011)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 38.3s, 237676+1517 tokens (185130 cached), 5 tool round(s), via Azure, $0.18)z-ai/glm-5.3-flash: ok (1 finding(s), 646.4s, 2959774+54169 tokens (2691840 cached), 30 tool round(s), via InferenceNet, $0.14)
Round 3 resolution
- ✅
r1-2fixed correctly — Unrecoverable pending actions after permanent binding conflicts: The panel retains explicit receipt and cancellation controls for unresolved reviews, including sticky cancellation retries. The HTTP handler submits the retained intent directly without reconstructing the current proposal. Runtime and handler tests cover accepted receipt recovery after reopening, withdrawal, draft edits and Knowledge-role loss; browser integration tests cover recovery and lost can… - ✅
r2-1fixed correctly — Permanent conflicts still strand non-review packets: Enrollment and evidence retries now use authenticated recovery endpoints with the original command bytes. Recovery attempts exact SDK replay before observing the ticket revision and retries again before returning a superseded fence for a strictly newer revision. The panel validates that fence and its closing actor/session context before releasing ownership. Browser integration and Native D1 tests … - ✅
r2-2fixed correctly — Calendar-dependent native authentication fixtures: Clocked authentication now anchors absolute Identity/Sessions timestamps to Date.now() at fixture creation while preserving elapsed advances from the logical learning clock. The calendar regression test checks the current anchor, real session touches and an expiry later than the wall clock. Both existing clocked Native D1 cases use this corrected shared fixture. - 🤝
r2-3disputed — Unqualified production queue deployment credential: The technical rebuttal identifies Workers Scripts Write as an accepted grant for the queue lookup and consumer creation/update APIs used by the installed Wrangler, and explains its equivalence to the documented Scripts Edit permission. The Worker README records that contract and unconditional queue configuration behavior. The current deployment workflow still supplies that grant; no specific new e… - 9 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 — Same-revision intake conflicts return pending with no owner-release path, wedging the staff page
public/staff-support-learning.js:420 · risk · identified by z-ai/glm-5.3-flash
A staff member submits evidence with a wrong solutionMessageId (or any content-invalid intake command) while the ticket revision is still current. The SDK rejects it as SupportDeskConflictError, so the panel retains the packet. On retry, recoverIntake replays the exact command, conflicts again, observes an unchanged revision, and returns {outcome:'pending'} — and the panel retains the owner again, telling the operator to "Read current state, then explicitly retry the same packet", which loops forever.
The recovery protocol can only release an intake owner via accepted or superseded, and superseded requires a strictly newer revision. Unlike review packets, which gained a cancellation escape (review-cancel / review-queue-cancel), intake packets have no receipt/cancel controls (receiptButton/cancelButton are hidden unless pending?.review === true) and the panel's exported surface offers no discard. While pending, every learning mutation is disabled panel-wide — including on other tickets after suspend()/showTicket() retain the packet — and the host blocks take-over, lifecycle buttons and reply/note compose via learningOccupied() in public/staff-support-ticket.js (updateControls()), while its beforeunload handler actively resists leaving the page. The wedge self-resolves only when some other actor mutates the ticket so the revision moves and recovery can return superseded; on a quiet resolved ticket it persists indefinitely.
Evidence that this class is real and reachable: worker/src/support-learning-handlers.test.ts "keeps an unchanged-revision conflict pending and preserves its original packet" positively constructs it with solutionMessageId: 'missing-visible-message' at the current revision, and the panel test "keeps pending recovery owned" codifies retention. I verified there is no other release path: recoverReview is review-only, mutate requires pending === null, and onPendingChange only notifies the host.
Proof gap and framing: the docs and PR body explicitly state "generic conflicts ... retain the pending owner", and the retention is positively tested, so I am not classifying this as incorrect behavior or a regression of the r2-1 fix — the obsolete-expectedRevision mechanism that finding described is resolved. The remaining risk is the asymmetry: for a command the server has proven did not apply (replay would have returned accepted) and cannot currently apply, intake packets alone offer no self-service release. A fence/release operation analogous to review cancellation, or at least operator guidance distinguishing this state, would close it.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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: latest-commit (commit-range)
Mode: verify
Commit: 0f03cba693910802f58b921bce2537e861bd8406
Judge: openai/gpt-5.6-luna
Cost: $0.1502 (lanes $0.1501 + judge $0.0001)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 36.7s, 82799+1110 tokens (54112 cached), 3 tool round(s), via Azure, $0.0970)z-ai/glm-5.3-flash: ok (0 finding(s), 281.2s, 365894+25917 tokens (131328 cached), 9 tool round(s), via Mistral, $0.0530)
Round 4 resolution
- ✅
r3-1fixed correctly — Same-revision intake conflicts returnpendingwith no owner-release path, wedging the staff page: Same-revision evidence conflicts now returnsupersededafter proving a missing resolution, unavailable customer-visible solution, or changed resolution cycle and retrying the exact SDK command again. The panel validates these fences before releasing ownership. Handler, Native D1, and registered-page integration tests cover the formerly wedged missing/internal-solution cases. Conflicts without a … - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Adds default-off staged staff resolution-learning review using all five strictly verified public Support Desk 0.2.5 packages, Knowledge Base 0.1.5, Agent Access 0.1.1, Storage Core 0.4.0 and D1 0.4.7.
Staff enroll resolved tickets, confirm evidence, inspect the delivered private KB draft and submit an exact approval or rejection command. Durable admission returns before separate proof and commit queue invocations. The panel retains the original actor-owned packet for status, receipt recovery, duplicate delivery and cancellation. Accepted work retains its owner through later logout, with current grants checked during processing.
Manual intake retry/reconciliation preserves the original enrollment or evidence packet. Accepted receipt recovery remains available. A strictly newer ticket revision followed by an exact retry conflict can return superseded. Evidence recovery also recognizes stable same-revision resolution, customer-visible solution and resolution-cycle fences, with an exact retry after the proof. These results establish a future-effect fence while retaining uncertainty about historical acceptance. Conflicts lacking that proof and availability failures retain the pending owner. The panel gives operators a concrete ordinary-ticket recovery path. Authentication fixtures use a current wall-clock anchor with their logical elapsed-time advances.
The registered Worker, private-source verifier and bounded maintenance paths compose these services explicitly. The native fixtures exercise actual Worker fetch and queue entry points with real D1 and retain the 50-call and 100-parameter guards. Queue and dead-letter resources are provisioned with 24-hour retention.
The production learning-review flag is false. Activation requires the host configuration and operational acceptance described in the composition guide. KB publication follows its staff approval workflow.
Observed validation on the actual public-package graph using Node 22.18.0 passed.
Fresh current-commit CI and review are required before merge. Existing login, actual requested clients, provider qualification, live CPU and supervised rollout retain their operational acceptance procedures.
Support Desk 0.2.5 release · D1 0.4.7 release.