Repository navigation
refactor(serve): default project memory to workspace scope #8856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wenshao
merged 9 commits into
QwenLM:main
from
qqqys:codex/issue-8854-daemon-workspace-memory-default
Aug 12, 2026
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
31e3061
refactor(serve): default project memory to workspace scope
qqqys 9a41641
fix(serve): preserve launch env access guard
qqqys 71a7171
fix(serve): harden project memory scope resolution
qqqys 7a1946c
chore: merge upstream main into issue 8854 branch
qqqys 6513906
fix(serve): harden project memory scope diagnostics
qqqys eb69b13
chore(serve): resolve main conflict for memory scope
qqqys c6ed41c
fix(serve): keep memory scope operator-owned
qqqys a520f35
Merge branch 'main' into codex/issue-8854-daemon-workspace-memory-def…
qqqys 4490b33
Merge branch 'main' into codex/issue-8854-daemon-workspace-memory-def…
qqqys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1237,7 +1237,9 @@ describe('runQwenServe daemon logger wiring', () => { | |
|
|
||
| // Point daemon logger at our temp debug dir | ||
| const origEnv = process.env['QWEN_RUNTIME_DIR']; | ||
| const originalScope = process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']; | ||
| process.env['QWEN_RUNTIME_DIR'] = tmpDir; | ||
| delete process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']; | ||
|
|
||
| try { | ||
| const handle = await runQwenServe( | ||
|
|
@@ -1271,6 +1273,10 @@ describe('runQwenServe daemon logger wiring', () => { | |
| expect(logContent).toContain( | ||
| `workspace=${fs.realpathSync.native(workspace)}`, | ||
| ); | ||
| expect(logContent).toContain('project memory scope resolved'); | ||
| expect(logContent).toContain('projectMemoryScope=workspace'); | ||
| expect(logContent).toContain('projectMemoryScopeSource=default'); | ||
|
Comment on lines
+1276
to
+1278
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修复 + 验证证据:65139068f8;在外部导出 QWEN_CODE_MEMORY_PROJECT_SCOPE=git-root 时,定向日志测试 1/1 通过;完整 run-qwen-serve.test.ts 246/246 通过。 |
||
| expect(logContent).toContain('projectMemoryScopeRaw=workspace'); | ||
|
|
||
| await Promise.all( | ||
| Array.from({ length: 70 }, (_, index) => | ||
|
|
@@ -1303,6 +1309,11 @@ describe('runQwenServe daemon logger wiring', () => { | |
| if (origEnv !== undefined) { | ||
| process.env['QWEN_RUNTIME_DIR'] = origEnv; | ||
| } | ||
| if (originalScope === undefined) { | ||
| delete process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']; | ||
| } else { | ||
| process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE'] = originalScope; | ||
| } | ||
| } | ||
| }, 10_000); | ||
| }); | ||
|
|
@@ -3868,7 +3879,44 @@ describe('runQwenServe runtime startup failures', () => { | |
| } | ||
| }); | ||
|
|
||
| it('applies memoryProjectScope to every runtime without mutating process.env', async () => { | ||
| it.each([ | ||
| [ | ||
| 'defaults every runtime to workspace project-memory scope', | ||
| undefined, | ||
| undefined, | ||
| 'workspace', | ||
| ], | ||
| [ | ||
| 'applies memoryProjectScope to every runtime without mutating process.env', | ||
| 'workspace', | ||
| 'git-root', | ||
| 'git-root', | ||
| ], | ||
| [ | ||
| 'preserves the launch environment scope when the option is omitted', | ||
| 'git-root', | ||
| undefined, | ||
| 'git-root', | ||
| ], | ||
|
qqqys marked this conversation as resolved.
Resolved
|
||
| [ | ||
| 'treats a blank launch environment scope as unset', | ||
| '', | ||
| undefined, | ||
| 'workspace', | ||
| ], | ||
| [ | ||
| 'treats a whitespace-only launch environment scope as unset', | ||
| ' ', | ||
| undefined, | ||
| 'workspace', | ||
| ], | ||
| [ | ||
| 'passes an unrecognized launch environment scope through unchanged', | ||
| 'workspce', | ||
| undefined, | ||
| 'workspce', | ||
| ], | ||
| ] as const)('%s', async (_name, launchScope, optionScope, expectedScope) => { | ||
| tmpDir = fs.realpathSync( | ||
| fs.mkdtempSync(path.join(os.tmpdir(), 'qws-memory-project-scope-')), | ||
| ); | ||
|
|
@@ -3877,7 +3925,11 @@ describe('runQwenServe runtime startup failures', () => { | |
| fs.mkdirSync(primary); | ||
| fs.mkdirSync(secondary); | ||
| const originalScope = process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']; | ||
| process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE'] = 'workspace'; | ||
| if (launchScope === undefined) { | ||
| delete process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']; | ||
| } else { | ||
| process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE'] = launchScope; | ||
| } | ||
| vi.spyOn(qwenCore, 'resolveTelemetrySettings').mockResolvedValue({ | ||
| enabled: false, | ||
| sensitiveSpanAttributeMaxLength: 1024 * 1024, | ||
|
|
@@ -3915,7 +3967,9 @@ describe('runQwenServe runtime startup failures', () => { | |
| hostname: '127.0.0.1', | ||
| mode: 'http-bridge', | ||
| workspace: [primary, secondary], | ||
| memoryProjectScope: 'git-root', | ||
| ...(optionScope === undefined | ||
| ? {} | ||
| : { memoryProjectScope: optionScope }), | ||
| maxSessions: 1, | ||
| serveWebShell: false, | ||
| }, | ||
|
|
@@ -3928,9 +3982,9 @@ describe('runQwenServe runtime startup failures', () => { | |
| for (const runtime of workspaceRegistry?.list() ?? []) { | ||
| expect( | ||
| runtime.env.effectiveEnv?.['QWEN_CODE_MEMORY_PROJECT_SCOPE'], | ||
| ).toBe('git-root'); | ||
| ).toBe(expectedScope); | ||
| } | ||
| expect(process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']).toBe('workspace'); | ||
| expect(process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']).toBe(launchScope); | ||
| } finally { | ||
| if (originalScope === undefined) { | ||
| delete process.env['QWEN_CODE_MEMORY_PROJECT_SCOPE']; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.