Repository navigation
Ignore stale workspace refreshes and clear private state on 401 - #15
Conversation
Overlapping GET responses could apply an older payload after a newer one, and a 401 only flipped signedOut while jobs, sources, events, editor, and import text stayed in memory. Gate refreshes by request generation, drop private workspace state on auth expiry, and keep in-flight editor typing plus save acknowledgement on the current session. Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>
POST 401 and GET 401 now use the same generation bump as overlapping refresh tickets. A deferred 200 after expiry is dropped, and a successful mutation does not show a saved notice if the following refresh expired the session. Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>
There was a problem hiding this comment.
Stale comment
Review (
6013f17)Scoped to the four-file delta vs
main. NoAGENTS.mdordocs/threat-model.md; usedREVIEW.md/ARCHITECTURE.mdpluslib/editor.tsandGET/POST401 JSON inapp/api/workspace/route.ts. No prior review threads. No migration or workflow changes.One defect: a GET 401 is dropped when its generation ticket is no longer current, so private workspace state is not cleared. That misses issue #7's rule that any 401 clears private state and invalidates pending refreshes. POST 401 correctly calls
expireWorkspaceand bumps the generation.editorAfterRefreshstill usesacknowledgeSave+reconcileEditor; exact-draft / OCC behavior looks unchanged.Ran: diff + adjacent editor/API contracts; 401 vs generation trace; issue #7 acceptance; re-checked head
6013f17still current. Inspected only: GitHubvalidateis green. Not run:pnpm test(this environment is Node 22;enginesrequire Node 24 for.tsimports); no browser pass.Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
There was a problem hiding this comment.
Stale comment
Review (
6013f17)Subsequent pass on the same head as the prior automation review. No new commits.
AGENTS.mdanddocs/threat-model.mdare absent; usedREVIEW.md/ARCHITECTURE.mdpluslib/editor.tsand the JSON 401 replies inapp/api/workspace/route.ts.Still open: a GET
401is dropped when its ticket is no longer current, soexpireSession/expireWorkspacenever run for that response. Issue #7 requires any 401 to clear private state and invalidate in-flight refreshes. POST 401 already does that. Exact-draft save acknowledgement and database OCC are unchanged (acknowledgeSave+reconcileEditor). No additional defects on this delta.Ran: three-dot diff vs
main(4 files), generation/401 trace, prior thread check, head recheck (6013f17). Inspected only: GitHubvalidateis green. Not run:pnpm test(this environment is Node 22;enginesrequire Node 24 for.tsimports); no browser pass.Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
Check HTTP status before JSON so a plaintext gateway Unauthorized expires the session instead of throwing. Epoch-invalidate in-flight POST and GET continuations so a delayed preview or import cannot restore private report state or start a new refresh. Keep the accepted save on the session so a later snapshot-less refresh still acknowledges it, while unsaved external version bumps remain conflicts. Tests drive processRefresh/processMutation, the same functions Workspace calls. Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>
There was a problem hiding this comment.
Stale comment
Review (
ee9a952)Subsequent pass after
6013f17. NoAGENTS.mdordocs/threat-model.md; usedREVIEW.md/ARCHITECTURE.mdpluslib/editor.ts(acknowledgeSave/reconcileEditor) and GET/POST 401 + save OCC inapp/api/workspace/route.ts. Issue #7 acceptance checked.Prior finding (stale GET 401 dropped): fixed.
processRefresh/processMutationexpire onstatus === 401before the live-ticket check, beforejson(), and bumpgate.epochso a later 200 cannot restore records. Workspace appliesexpiredPrivateWorkspace()onexpire. Regression: older 401 while a newer refresh is in flight.No new actionable defects on this four-file delta.
lastAckis session-scoped and still requires job + editor session + version, so A-to-B-to-A cannot bless stale text; an external version bump without an own save still conflicts. No migration or workflow changes.Ran: three-dot diff vs
main, incremental diff vs6013f17, generation/401/lastAck traces, prior-thread verification, HEAD recheck (ee9a952still current). Inspected only: GitHubvalidateis green. Not run:pnpm test/tsc(this environment is Node 22;enginesrequire Node 24 for.tsimports);tests/api.test.mjs; no browser 401 pass.Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
|
Cleanup coordination: the complete ee9a952 session fix is now included in #11 (head 9b561f7), together with a reproduced/fixed CSV-specific 401 path and browser coverage. Standalone #15 remains useful as the focused security change if it lands before CSV; otherwise it can be closed as included once #11 merges. Its package-script edit must be dropped against current main because scripts/ci/run-unit.mjs discovers all tests; incoming node:test registrations also need void to satisfy canonical lint (already corrected in #11). Do not discard the session fix when replaying the CSV delta. |
There was a problem hiding this comment.
Stale comment
Review (
137aea89)Subsequent pass after
ee9a952. Head is the merge ofmain(e037ebf, #14) plusvoid test(...)registrations. Unique delta vsmainis stillapp/workspace.tsx,lib/workspace-refresh.ts, andtests/workspace-refresh.test.mjs. ReadAGENTS.mdanddocs/threat-model.md.Prior finding (stale GET 401 dropped): still fixed.
readWorkspaceResponsetreatsstatus === 401beforejson();processRefresh/processMutationexpire and bumpgate.epochbefore the live-ticket check. Workspace appliesexpiredPrivateWorkspace()onexpire. Regression for older 401 while a newer refresh is in flight remains.No new actionable defects.
lastAckstays session-scoped and still requires job + editor session + version, so A-to-B-to-A cannot bless stale text; an external version bump without an own save still conflicts. The earlierpackage.jsontest-script edit is gone vs currentmain;scripts/ci/run-unit.mjsdiscoverstests/workspace-refresh.test.mjs. No migration or workflow changes in this three-file delta.Ran: three-dot diff vs
main, incremental diff vsee9a952, 401/epoch/lastAck/OCC traces againstlib/editor.tsand GET/POST 401 inapp/api/workspace/route.ts, issue #7 acceptance, prior-thread verification, HEAD recheck (137aea89matchesrefs/pull/15/head). Inspected only: GitHubQuality and release buildandIntegration (api)are green (pnpm testran there). Not run here:pnpm test/tsc(this environment is Node 22;enginesrequire Node 24);tests/api.test.mjs; browser 401 pass. Browser integration was still pending at review time.Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
processMutation can return ok on epoch 0, then a concurrent 401 bumps the epoch before run resumes. Recheck mutationIsLive immediately after ignore handling so a pre-expiry preview cannot write report state or start a refresh that restores jobs. The regression compiles the actual Workspace callbacks with an async fetch mock, native Response, and four yields. Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>
|
Independent targeted verification completed for The immediate Cursor Grok 4.6 Extra High implemented the correction; Astra performed this bounded independent verification. This is verification evidence, not a human approval. Main reconciliation, current-head CI, and Mateo's required review still apply. |
There was a problem hiding this comment.
Stale comment
Review (
8faab98)Subsequent pass after
137aea89. Unique delta vsmainis stillapp/workspace.tsx,lib/workspace-refresh.ts, andtests/workspace-refresh.test.mjs. Incremental change is the immediatemutationIsLivecheck inrunplus the compiled-callback regression. ReadAGENTS.mdanddocs/threat-model.md.Prior finding (stale GET 401 dropped): still fixed.
readWorkspaceResponsetreatsstatus === 401beforejson();processRefresh/processMutationexpire and bumpgate.epochbefore the live-ticket check. Workspace appliesexpiredPrivateWorkspace()onexpire.lastAckstays session-scoped and still requires job + editor session + version. No migration or workflow changes.New defect:
runnow rechecksmutationIsLiveafterawait processMutation(fixes the epoch-0okthen 401 thenrefresh()restore).refreshdoes not recheckrefreshIsLiveafterawait processRefresh. The same one-microtask gap can apply arecordspayload and setsignedOut=falseafterapplyExpired().Ran: three-dot diff vs
main, incremental diff vs137aea89, 401/epoch/lastAck/OCC traces againstlib/editor.tsand GET/POST 401 inapp/api/workspace/route.ts, issue #7 acceptance, prior-thread verification, HEAD recheck (8faab98matchesrefs/pull/15/head). Inspected only: GitHubQuality and release build,Integration (api), andIntegration (browser)are green. Not run here:pnpm test/tsc;tests/api.test.mjs; browser 401 pass.Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
|
Cleanup handoff complete at 700dc97: merged current main e0f69c9 while preserving independently verified 8faab98 runtime code and regression exactly. Only main context documentation changes from the verified tree. Fresh CI is running, peer review is requested, and protected squash auto-merge is queued. The CSV PR #11 already contains this runtime correction plus its own CSV 401 cleanup. If #11 lands first, close this PR as included rather than replaying old code. |
There was a problem hiding this comment.
Stale comment
Review (
700dc979)Subsequent pass after
8faab98. Incremental change is a merge ofmain(context-management docs only). Unique delta vsmainis stillapp/workspace.tsx,lib/workspace-refresh.ts, andtests/workspace-refresh.test.mjs. ReadAGENTS.mdanddocs/threat-model.md.Prior finding (stale GET 401 dropped): still fixed.
readWorkspaceResponsetreatsstatus === 401beforejson();processRefresh/processMutationexpire and bumpgate.epochbefore the live-ticket check. Workspace appliesexpiredPrivateWorkspace()onexpire.runstill rechecksmutationIsLiveimmediately after expire/ignore.lastAckstays session-scoped and still requires job + editor session + version. No migration or workflow changes.Prior finding (stale GET
recordsafter a later 401): not addressed.refreshstill appliesrecordsandsetSignedOut(false)with norefreshIsLivecheck afterawait processRefresh. The merge did not change this path. Issue #7 acceptance ("cannot restore state after logout") still fails on that interleaving.Ran: three-dot diff vs
main, incremental diff vs8faab98, 401/epoch/lastAck/OCC traces againstlib/editor.tsand GET/POST 401 inapp/api/workspace/route.ts, issue #7 acceptance, prior-thread verification, HEAD recheck (700dc979matchesrefs/pull/15/head). Inspected only: GitHubQuality and release build,Integration (api),Integration (browser),Integration (production), CodeQL, and Dependency security are green. Not run here:pnpm test/tsc;tests/api.test.mjs; browser 401 interleaving.Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
There was a problem hiding this comment.
Review (8102c81)
Subsequent pass after 700dc979. Incremental change is the immediate refreshIsLive check in refresh plus tests/refresh-expiry.test.mjs. Unique delta vs main is app/workspace.tsx, lib/workspace-refresh.ts, tests/workspace-refresh.test.mjs, and tests/refresh-expiry.test.mjs. Read AGENTS.md and docs/threat-model.md.
Prior finding (stale GET 401 dropped): still fixed. readWorkspaceResponse treats status === 401 before json(); processRefresh / processMutation expire and bump gate.epoch before the live-ticket check. Workspace applies expiredPrivateWorkspace() on expire.
Prior finding (stale GET records after a later 401): fixed. After expire/ignore, refresh now returns when !refreshIsLive before setJobs / setSignedOut(false). The compiled-callback test expires in that gap across 20 microtask offsets and asserts signedOut === true and jobs === []. run still rechecks mutationIsLive immediately after expire/ignore.
No new actionable defects. lastAck stays session-scoped and still requires job + editor session + version, so A-to-B-to-A cannot bless stale text; an external version bump without an own save still conflicts. No migration or workflow changes.
Ran: three-dot diff vs main, incremental diff vs 700dc979, 401/epoch/lastAck/OCC traces against lib/editor.ts and GET/POST 401 in app/api/workspace/route.ts, issue #7 acceptance, prior-thread verification, HEAD recheck (8102c81 matches refs/pull/15/head). Inspected only: GitHub Quality and release build, Integration (api), and Integration (browser) are green (pnpm test ran there). Integration (production) failed 503 !== 200 at scripts/ci/run-production.mjs on a same-origin save; this delta does not change the worker/API path, so that failure is not a defect in the session-expiry code. Not run here: pnpm test / tsc (this environment is Node 22; engines require Node 24); tests/api.test.mjs; browser 401 interleaving.
Human approval remains mandatory.
Sent by Cursor Automation: RELAY pull request review
…landing PR. Fold the current #15/#11 continuation checks and regressions, keep history loads from applying after expiry, and match the lockfile to shadcn 4.18.0. Remove the deferred profile calibration loop and the production-diagnostics changes that were rejected for #22. Co-authored-by: sykosyber <sykosyber@users.noreply.github.com>
sykosyber
left a comment
There was a problem hiding this comment.
Partner Extra High review of 8102c816f22af6ecdb56ee7d5bc7cb6f9e49871d.
Traced: HTTP 401 is classified in readWorkspaceResponse before json(); expireSession bumps epoch before live-ticket checks; refresh rechecks refreshIsLive immediately after expire/ignore and before setJobs / setSignedOut(false); run rechecks mutationIsLive immediately after expire/ignore; acknowledgeSave still requires jobId + session + version, so a session-scoped lastAck cannot bless another job or A-to-B-to-A stale text; finally still clears busy. Prior GET-401 and stale-records threads are resolved. Required CI is green on this head.
This approval is for this commit only and does not merge or deploy. If #11 lands first, close this as included.
Keep the landing-branch workspace extras (history pagination, tracker import, dirty navigation, exact-acceptance UX) on top of #15's session expiry guards. Refresh tests keep the extra stubs and history-epoch cases required by that Workspace. Co-authored-by: sykosyber <sykosyber@users.noreply.github.com>
Bring in the #15 session-refresh fixes while keeping the reviewed issue 22 diagnostic commits. Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>
Tracker CSV imports let users confirm column mappings, preview exact research records and omitted fields, then explicitly import without resetting existing application status or accepted wording. Malformed, ambiguous, missing-URL and oversized batches are rejected; repeat imports preserve source history. This branch includes the merged delivery foundation and context documentation from main e0f69c9, plus the session-expiry correction from #15. CSV and workspace 401 responses clear private state before parsing, and late refresh/mutation continuations cannot restore it. The final refresh guard addresses a reproduced child-importer expiry interaction; loading or importing research never accepts a draft or sends an application. Validation: the previous combined application head passed 73 unit tests, typecheck, lint, build, five Chromium journeys and all hosted checks (compiled-production check needed one unchanged-job rerun; the recurring 503 is tracked in #22). The latest head 5beb10a adds one refresh guard and an actual-callback regression: the new test failed without the guard and passes with it across 20 timing gaps. All 17 scoped session/CSV regressions, typecheck and lint pass. Fresh full CI runs on the latest head; do not treat older results as its completed CI. Mateo's approval remains required. Protected squash auto-merge is queued. If #15 merges first, reconcile with its squash commit; if this PR lands first, close #15 as included. Real Simplify export compatibility, user adoption and production deployment remain unverified. No new database migration. Closes #17 Closes #7 --------- Signed-off-by: Seth Carlson <66243744+sdcarlson@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Problem and result Closes #8 Closes #9 Closes #19 `main` already includes protected CI/CD (#14), context playbooks (#18), session-expiry (#15 / #7), ChatGPT/Codex public-copy (#13), Apache 2.0 (#39 / #38), and tracker CSV (#11 / #17). This branch merges that tip and keeps the remaining unique trees: - Local-dev Node/port/sign-in, with a Windows-safe Node guard instead of Bash (#12 / #19) - Copy/paste draft handoffs, exact-acceptance actions, and dirty-navigation guards (#24) - Selected-job review history beyond the GET 200-event window (#8) - Assistant packets for valid jobs with `url: null` (#9) - Canonical public-copy listing for Tracker CSV (the #11 squash kept that note outside the maintained block) Head `4d8f007` merges `origin/main` (`256854b`, #11) into the previous landing. Conflict resolution kept `void test` wrappers, history/null-URL API coverage, and one Tracker CSV setup section. The changes-requested review is on superseded `9e307b9`. Independent preservation review of `8d6ba1a` retired the five original code findings. These merges do not restore them. Deferred, matching maintainer comments, and **not** in this PR: - Profile calibration loop (#26) - `shadcn` 4.20.1 (#32) - Production 503 diagnostics (#22 / draft #40) - Assistant research/next-task handoff (#37 / #41) — stacked on landed #13, not this consolidation - Unused UI-kit cut / competing review-loop draft (#42) Keep #16 open: remaining development-tool advisories. Keep #21 open until post-merge Pages verification. Keep #22 open. Cloudflare hosting (#3), two-account isolation (#4), recruiting (#5), backup rehearsal (#6), and Grok Bot VM command review (#20) still need human/environment work. ## Evidence - Local on `4d8f007`: `pnpm lint`, `pnpm typecheck`, `pnpm test` (98 passed), `pnpm public-copy:check`, `pnpm build`, `pnpm test:api`, `pnpm test:e2e` (6 passed), `pnpm test:production` passed. - GitHub CI on `4d8f007` ([run 34003847782](https://github.com/SyberLabs/relay/actions/runs/34003847782)): quality, API, browser, production, CodeQL, dependency-security, and bundled agent contracts were running or already green after this merge; required `CI` still needs the remaining jobs. - User-visible proof: copy/paste packet, Windows-safe `scripts/ensure-node.mjs`, Load earlier review history, null-URL packets. CSV import and ChatGPT/Codex prepare now come from `main`. - Security, data migration, and rollback impact: no new D1 migration. React trio stays at 19.2.8. CI Vinext still uses ephemeral ports when `RELAY_CI_STATE` is set. Production integration keeps the original request sequence. ## Review - [ ] One issue owns this scope; unrelated changes are separate. This is an explicit integration PR covering the remaining open merge train. - [x] Tests exercise the changed behavior, including failure paths (including compiled Workspace continuation and history-after-expiry regressions). - [x] No credentials, personal applications, or private research are included. - [x] Agent findings from the `9e307b9` review remain addressed. - [ ] A maintainer other than the author will approve. **@sdcarlson must approve the latest push** (`4d8f007`); prior reviews do not cover this merge commit. - [x] Public capabilities, integration limits and lead-engineer credit match `docs/public-copy.json`; run `pnpm public-copy:check` and follow `docs/PUBLIC-COPY.md` when these change. After merge, close the superseded feature PRs (#12, #24) as landed here rather than squash-merging them separately. #11, #13, #15, and #39 are already merged. #26 and #32 stay closed as deferred. #40, #41, and #42 stay on their own tracks. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-3877d527-b5e4-46d7-8c5f-573418309ece?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-3877d527-b5e4-46d7-8c5f-573418309ece&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: sykosyber <sykosyber@users.noreply.github.com>
The unused generated UI kit added dependencies and maintenance work without serving Relay screens. This PR now removes that kit, its unused helper/hook and Next configuration, and the unused Tailwind pipeline. Runtime history, session guards, CSV, assistant handoffs and copy/paste remain exactly as merged in #36. It also restores the historical PR24 evidence accidentally omitted during consolidation, with original commit/test-count limits intact. The original review-loop fixes are already on main through #15/#36; this final delta does not replace their implementations. No database migration or deployment change. Validation against main 7cfec26: typecheck, lint, frozen offline lockfile validation, all98 unit tests, release build and six browser journeys pass. The prior combined API run passed before choosing the unchanged main runtime; fresh hosted API/production/security checks are required on this pushed head. Dependencies were removed without disabling audit or CI gates. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Seth Carlson <sdcarlson@users.noreply.github.com>


Problem and result
Closes #7
A workspace GET 401 used to leave private jobs, sources, events, editor text, and import payloads in client state. Overlapping refreshes could also apply an older payload after a newer one.
A remaining race in the actual Workspace
runcontinuation:processMutationcan returnokon epoch 0, then a concurrent 401 bumps the epoch beforerunresumes. Without an immediate epoch check, that continuation wrote preview state and calledrefresh(), which issued a second GET in the new epoch and restored jobs withsignedOut=false.This revision:
json(). A plaintext gatewayUnauthorizedexpires private state instead of throwing and leavingsignedOut=false.200is ignored.mutationIsLiveimmediately after expire/ignore handling inrun, before 409 follow-up, editor/report/import writes, orrefresh. Later epoch guards stay in place. No extra helper wrappers.Evidence
Node 24 ESM from checkout.
pnpm lint,pnpm typecheck, andpnpm test(scripts/ci/run-unit.mjs): 66 passed, 0 failed.Astra's compiled-callback harness (actual
applyExpired/refresh/runfromapp/workspace.tsx,asyncfetch mock, nativeResponse, exactly fourawait Promise.resolve()yields):ee9a9526/ merged137aea8run(no immediate guard):{ gets: 2, spawnedEpoch: 1, signedOut: false }—assert.equal(gets, 1)fails2 !== 1.8faab98:{ gets: 1, spawnedEpoch: undefined, signedOut: true, jobs: [] }.Also previously run on this branch:
pnpm build. Not run on this head:pnpm test:api,pnpm test:e2e,pnpm test:production, browser 401 simulation.Fictional fixtures only. No credentials, personal applications, or private research.
Review