Repository navigation
feat: session occupancy lock, default workspace, and shared session rating rules - #390
Merged
Merged
Conversation
Two Pythinker Code processes could open the same session and corrupt each other's wire journal and metadata. A cross-process lock under <home>/locks/sessions is now held while a session writes; a second writer reports session.occupied, and a client that sees another process's writes reloads before continuing. PYTHINKER_CODE_SESSION_LOCK=0 turns the lock off. Also gives EXPERT_TALK_RUN_NOT_FOUND its own wire code (40422); it shared 40420 with RUNTIME_NOT_FOUND.
…edged turns A rebuilt transcript numbered turns 0..N while live clients used wire turn ids, and a turn whose loop died without a terminal event came back as a fake completed turn. Rebuilt turns now keep their wire ids and start times, and an unterminated turn followed by a later prompt is marked failed and wedged. The engine also logs stalled flushes, latched storage failures, stuck dispatch, and turns with no progress for ten minutes.
|
Important Review skippedToo many files! This PR contains 228 files, which is 128 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. ⚙️ Run configuration
⛔ Files ignored due to path filters: 3
📒 Files selected for processing: 228
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Clears the follow-redirects credential-header advisories and the hono and vite advisories that fail the security audit.
A minimum of 8.1.6 keeps the advisory fix and lets normal upgrades move past 8.1. The lockfile still resolves 8.1.6.
# Conflicts: # apps/pythinker-code/dist-web/.web-bundle-manifest.json # apps/pythinker-code/dist-web/assets/DesignSystemView-BAgPEsSe.js # apps/pythinker-code/dist-web/assets/DesignSystemView-Bu-pya6S.js # apps/pythinker-code/dist-web/assets/DesignSystemView-DWx8o64m.js # apps/pythinker-code/dist-web/index.html
# Conflicts: # apps/pythinker-code/dist-web/.web-bundle-manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
Lock a session to one writer, add a default workspace, share the session rating rules, and fix three session bugs.
Bug Reproduction Steps
Root Cause
All three are fixes at the root, not workarounds.
Code Changes
Session lock. A session can have one writing process at a time. Before a turn, a manual compaction, or a print-mode run, the session run gate takes the lock and checks the session files for changes made by another process.
errorline instream-json).PYTHINKER_CODE_SESSION_LOCK=0(alsofalse/off) turns the lock and the stale checks off. Documented indocs/configuration/env-vars.md.Default workspace. The gateway now accepts a new session without a workspace or
cwd. It creates and uses~/PythinkerCode/Default;[default_workspace] pathinconfig.tomlchooses another folder.Shared session rating rules. The survey rules move from the CLI into a new private workspace package, so the TUI and the server use the same rules.
CUSTOM_API_BASE_URLis set. Without it, no request and no cache read.tui.tomltodisable_feedback_surveyinconfig.toml. An existingtui.tomlvalue is moved over on the next start.packages/productis in bothflake.nixworkspace lists.Session events. The broadcaster drops a session's event state on close and archive.
Transcript. Rebuilt turns take their ordinals from the wire ids, and a turn without an end record is marked failed.
Other fixes found on the way.
config.changed/config.sectionChangeddropped every event whosevalueorpreviousValuewas undefined; both are now optional.flushLog()did nothing; it now flushes persistence.AGENTS.md: review scope rules.40420; "Expert Talk run not found" moves to40422. The new codes are40939(default workspace unavailable),40940(session occupied) and40941(session stale).Behavior Changes and Affected Users
PYTHINKER_CODE_SESSION_LOCK=0PYTHINKER_CODE_SESSION_LOCK=0cwd(gateway REST)~/PythinkerCode/Default(folder created on first use)[default_workspace] pathsets the folderdisable_feedback_surveyintui.tomldisable_feedback_surveyinconfig.toml; old value moved on next starttui.tomlby handCUSTOM_API_BASE_URLis setPOST /api/v1/sessions/{session_id}/rating40420(shared withRUNTIME_NOT_FOUND)40422(gateway andpackages/protocol)40420to detect a missing Expert Talk run; no consumer in this repositorycodestring, or40422Contract files touched (consumers: desktop and web apps, the inspector, the VS Code extension, ACP clients, SDK users, headless-output parsers):
packages/agent-core-v2/docs/config-manifest.toml: new[default_workspace]section. Additive.apiSurface.snapshot.test.ts.snap: new rating route. Additive.packages/node-sdk/src/index.ts: exportsConfigSectionChange. Additive.packages/acp-server/src/session.ts: maps "session occupied" and "session stale" toinvalidRequestwith a client-action message.apps/pythinker-code/src/cli/v2/run-v2-print.ts: new exit code 4 for an occupied session; the reload notice goes to stderr.Test coverage
sessionLockService.test.ts,sessionRunGate.test.ts(off switch tests fail without the source change), TUI and print-mode testsdefaultWorkspace.test.ts, gatewaysessions.test.ts,workspaces.test.tspackages/product(275), gateway rating tests,pythinker-tui-startup.test.tssessionEventBroadcaster.test.ts(fails without the fix)packages/transcript(128), gateway transcript testsonConfigSectionChangedtestremote-control.test.ts(29)Local gates: build, typecheck, lint (0 errors), sherif, VS Code typecheck, flake workspace check, and
nix build .#pythinker-codepass.pnpm test(two full runs): 18619 passed, 1 timed out under full-suite load each time (fullCompaction.test.ts"names truncated compaction responses when retries are exhausted"); that file passes 96/96 alone and the full engine suite passes 6902/6902.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.