Repository navigation
fix(memory): bind serve-host session identity from the session row (#90) - #91
Merged
Merged
Conversation
On `opencode serve --service` the plugin loads AFTER the session exists, so
session.created (the only location-bearing event) is never delivered,
execution.started carries only {sessionID}, and context messages carry no
location — all three binding paths missed and writes fell back to the module
scope, silently partitioning recall (issue #90, reproduced with recorded
2.1.4/2.0.26 payloads).
- bindSessionFromApi: resolve location.directory from the host's session get,
once per session (bounded LRU); wired into the identity-event branch and a
bindSessionIdentity chain (messages -> session row) at every write/read site.
- test/repo-scope-serve-host.test.ts: replays the RECORDED serve-mode payloads
(execution.started without location, locationless messages); 2 of 4 fail on
the pre-fix code.
- e2e/stamp.test.ts: service-shaped BDD guard — global-config plugin, service
launched away from the project, stamp asserted (contract guard: green on
both pins, HTTP host boots locations on demand).
- test/harness.ts: fake session.get backing the replay.
|
🎉 This PR is included in version 0.8.12 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
What
Closes #90 — recall silently partitioned every service-hosted (Desktop /
serve --service) session.Data, not guesses
Root cause was confirmed with a probe plugin recording the plugin-side view on both host versions (2.1.4 and 2.0.26):
opencode run)serve --service)session.createddelivered?location.directorypresentsession.execution.started{sessionID}location(legacy)session.get)location.directorypresent ← the fix's sourcerepo=sha1(origin))Production corroboration: this session's
session_v2.directoryis the project, yet its rows carryrepo=/Users/Alex/.config/opencode; the host log shows the location service for the project was never booted in the service run.Why the harness missed it
test/repo-scope-session.test.tsfed the fake event bus andsession.contextthe payload shapes the plugin hopes for — the fake encoded the same wrong assumption as the production code.e2e/only ranopencode run --standalone— the mode where the bug cannot exist — and no scenario ever asserted therepo=stamp.Tests (red first)
test/repo-scope-serve-host.test.ts— replays the recorded serve-mode payloads at the plugin boundary. On the pre-fix code (git stashof thesrc/change): 2 of 4 fail (identity-from-row, consult-once). Post-fix: 4/4.e2e/stamp.test.ts— service-shaped BDD scenario: plugin via global config, service launched from a directory that is NOT the project, session created in a git repo with a known origin, stamp asserted. Honest classification: green-on-both pins (the HTTP host boots locations on demand, so it self-heals what the Desktop attach path does not) — it is the end-to-end contract guard, not the red proof.Fix
bindSessionFromApi: resolvelocation.directoryfrom the host's session get, once per session (bounded LRU, same cap as the scope cache); wired into (a) the identity-event branch when an event carries no directory, and (b)bindSessionIdentity(messages → session row) at every write/read binding site. A host withoutsession.getdegrades to today's module-scope fallback (pinned by a test).Verification
bun run gate: typecheck, lint, 356 unit tests, e2e BDD — all green.session.getunavailable → write lands in module scope, never throws.Follow-up (separate issue): non-git session dirs stamp
repo="<raw path>"quoted with spaces — parser-safe but unmatchable by hash; worth normalizing.