fix(dsh): treat missing session cwd as unscoped - #1267
Conversation
Latest DeepSeek Harness leaves SessionHeader.cwd unset when a session has no workspace. Stop inventing a project scope from the Harness process directory.
The quality job's end-of-file-fixer rejects the bundled lib outputs when they omit a final newline.
Teingi
left a comment
There was a problem hiding this comment.
The cwd handling looks good. One test runner issue needs fixing before this merges.
| return `local:${createHash('sha256').update(resolve(process.cwd())).digest('hex')}` | ||
| } | ||
|
|
||
| describe('plugin runtime with header.cwd === undefined', () => { |
There was a problem hiding this comment.
This second e2e file exposes a shell glob issue in the existing test script. On Linux, vitest run --exclude tests/e2e/** expands to both e2e paths. Vitest uses the first path as the exclude value and treats this file as a positional filter, so pnpm test runs this e2e file and skips all 60 unit tests. I reproduced this at ade1124; vitest run --exclude=tests/e2e/** runs all 12 unit test files. Can we keep the glob in one argument and make sure make js-test reports 60 passing tests?
There was a problem hiding this comment.
Thanks @Teingi catching this and for the clear reproduction. Fixed in 71b0e8b by keeping the exclude glob in one argument (--exclude=tests/e2e/**). I verified pnpm --dir integrations/dsh/plugins/powercontext test (the command used by make js-test) now reports 12 test files / 60 passing tests. The separate E2E suite still reports 2 files / 4 passing tests. I really appreciate the careful review and suggested fix.
Which issue or RFC does this PR close?
Closes #1266.
Rationale for this change
Latest DeepSeek Harness(dsh-0.1.0-rc.7) made
SessionHeader.cwdoptional. Sessions created without a workspace (sessions.create()with nometa.cwd) leave the field unset. The plugin treated cwd as required, so/pccould throw, recall was swallowed by fail-open, and tools could scope Memory to the Harness process directory.What changes are included in this PR?
session.header.cwdas no workspace. Never fall back toprocess.cwd().scopeId/POWERCONTEXT_DSH_SCOPE_IDis set, recall,/pc, and tools work without cwd.scopeIdis available: recall skips withmissing_session_cwd;/pcand tools return an explicit unscoped error; capture metadata omits a fabricated cwd.cwd?: string.header.cwd === undefined.Are there any user-facing changes?
Yes, for sessions without a workspace:
/pcandpc_*tools return a clear unscoped message unlessPOWERCONTEXT_DSH_SCOPE_IDis set.scopeIdwhen the session has no workspace cwd.No Server API or storage format changes.
How was this change tested?
npx vitest run --exclude tests/e2e/**inintegrations/dsh/plugins/powercontext(60 passed)npx vitest run tests/e2e(4 passed: existing HTTP call-through plus the new unscoped-session runtime e2e)AI usage statement
Assisted by an AI coding model for the compatibility change, tests, and this write-up.