Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
18772ed
refactor(cli): keep acp-integration off serve internals (#8084)
yiliang114 Aug 14, 2026
99a1172
Merge remote-tracking branch 'origin/main' into HEAD
yiliang114 Aug 14, 2026
0691cb9
fix(cli): harden the acp/serve boundary guard (round 2)
yiliang114 Aug 14, 2026
ac83137
test(cli): pin serve boundary lint rules
yiliang114 Aug 15, 2026
ec63477
test(cli): close serve boundary lint gaps
yiliang114 Aug 15, 2026
78ead13
fix(lint): close serve-boundary entrances and harden the guard
yiliang114 Aug 15, 2026
17d16d5
fix(lint): correct TSImportType selector path and computed-template h…
yiliang114 Aug 15, 2026
4abaca1
fix(lint): close the remaining round-6 serve-boundary entrances
yiliang114 Aug 15, 2026
6f7a13d
fix(lint): cover vitest serve-boundary calls
yiliang114 Aug 15, 2026
0c8c334
fix(lint): close the round-7 serve-boundary entrance classes
yiliang114 Aug 15, 2026
1815694
refactor(lint): resolve the serve boundary by resolution, not text (#…
yiliang114 Aug 16, 2026
23cf025
Merge branch 'main' into fix/acp-serve-boundary-guard
yiliang114 Aug 16, 2026
02e502a
fix(lint): drop the dead serveGuardSyntaxRules helper
yiliang114 Aug 16, 2026
3d8be1f
fix(lint): close serve boundary resolver gaps
yiliang114 Aug 16, 2026
3cc4298
fix(lint): address serve boundary review suggestions
yiliang114 Aug 16, 2026
cf05dd5
fix(lint): close round-11 serve boundary gaps
yiliang114 Aug 16, 2026
34fc045
chore: merge main into serve boundary guard
yiliang114 Aug 16, 2026
2d59792
fix(cli): restore live session source import
yiliang114 Aug 16, 2026
3da80b9
fix(lint): clear the two lint errors breaking CI on the boundary rule
yiliang114 Aug 16, 2026
c4758e3
fix(lint): close bounded serve boundary gaps
yiliang114 Aug 16, 2026
7112ab4
fix(lint): complete the round-12 boundary escape closures
yiliang114 Aug 16, 2026
552bc7c
fix(lint): close the round-12 reviewer escape classes (#8084)
yiliang114 Aug 17, 2026
c11b30c
fix(lint): repair corrupted files from the git-API blob upload
yiliang114 Aug 17, 2026
8e583a8
Merge remote-tracking branch 'origin/main' into HEAD
yiliang114 Aug 17, 2026
ebe1cb5
fix(lint): close the round-13 serve-boundary escape classes (#8084)
yiliang114 Aug 17, 2026
9fbd906
fix(lint): close the round-13 binding-hop and callee-opacity escapes …
yiliang114 Aug 18, 2026
58d4398
refactor(cli): simplify ACP serve boundary guard
yiliang114 Aug 19, 2026
ff4e3b0
Merge remote-tracking branch 'origin/main' into codex/pr-9144-scope-back
yiliang114 Aug 20, 2026
210b2e1
fix(lint): close the round-21 contract pins and bare-barrel escape (#…
yiliang114 Aug 20, 2026
01475ab
fix(lint): close dynamic-import and js-file holes in the acp/serve gu…
yiliang114 Aug 22, 2026
5e7511a
fix(lint): make acp/serve dynamic-import guard case-insensitive
yiliang114 Aug 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 153 additions & 18 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,90 @@ import storybook from 'eslint-plugin-storybook';
import checkFile from 'eslint-plugin-check-file';
import { legacyFilenames } from './eslint.legacy-filenames.mjs';

// Static-import guard: relative specifiers only, enumerated by depth. The
// earlier `**/serve*` globs also matched third-party package names (`serve`,
// `@scope/serve`, `@scope/serve/subpath`), so bare/scoped specifiers must
// never reach the boundary check; imports deeper than six levels below src/
// do not occur in the guarded trees. `../serve` (bare directory) resolves to
// the serve/ barrel and stays covered.
const relativeServeImportPatterns = [];
for (let depth = 1; depth <= 6; depth++) {
const prefix = '../'.repeat(depth);
relativeServeImportPatterns.push(
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
`${prefix}serve`,
`${prefix}serve/*`,
`${prefix}serve/**`,
);
}

const restrictedServeImports = (message) => ({
patterns: [{ group: relativeServeImportPatterns, message }],
});

// Dynamic-import guard. Relative spellings are matched with linear-time
// patterns — the previous nested-quantifier shape backtracked exponentially
// (ReDoS: ~4x cost per two added `../` segments). Non-literal sources and
// type-level imports cannot be resolved statically, and rounds 2-5 each
// demonstrated a new spelling entrance, so those are rejected fail-closed.
const serveDynamicImportPatterns = [
// Canonical and duplicated-separator spellings: ../serve, ./../serve,
// ..//serve, ../../serve/x, ...
String.raw`^(?:\.\x2f+|\.\.\x2f+)+serve(?:\x2f|$)`,
// Spellings routing through intermediate or traversal segments:
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
// ../runtime/../serve/x, ../foo/../../../serve/x, ..//foo//serve, ...
String.raw`^(?:\.\x2f+|\.\.\x2f+)+(?:[^\x2f]+\x2f+)+serve(?:\x2f|$)`,
];

const restrictedServeDynamicImports = (message) => [
...serveDynamicImportPatterns.flatMap((pattern) => [
{
selector: `ImportExpression[source.value=/${pattern}/]`,
message,
},
{
selector: `ImportExpression[source.quasis.0.value.cooked=/${pattern}/]`,
message,
},
{
selector: `TSImportType[argument.value=/${pattern}/]`,
message,
},
]),
// Fail-closed: concatenation, `new URL(...)`, and other computed sources
// cannot be proven safe statically (see R4-1 entrances).
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
{
selector:
'ImportExpression:not([source.type="Literal"]):not([source.type="TemplateLiteral"])',
message,
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
},
{
selector: 'TSImportType:not([argument.type="Literal"])',
message,
},
];
Comment thread
yiliang114 marked this conversation as resolved.
Resolved

const restrictedRequire = {
selector: 'CallExpression[callee.name="require"]',
message: 'Avoid using require(). Use ES6 imports instead.',
};

const restrictedStringThrow = {
selector: 'ThrowStatement > Literal:not([value=/^\\w+Error:/])',
message:
'Do not throw string literals or non-Error objects. Throw new Error("...") instead.',
};

// The three guarded trees (runtime/, utils/, acp-integration/) share one
// no-restricted-syntax shape. Flat config replaces rule options wholesale,
// so the array is built in one place — a future selector added here reaches
// every guarded tree instead of needing hand-replication in each block.
const serveGuardSyntaxRules = (message) => [
'error',
restrictedRequire,
restrictedStringThrow,
...restrictedServeDynamicImports(message),
];

export default tseslint.config(
{
// Global ignores
Expand Down Expand Up @@ -72,6 +156,20 @@ export default tseslint.config(
'import/namespace': 'off', // Disabled due to https://github.com/import-js/eslint-plugin-import/issues/2866
},
},
{
// `runtime/` is the neutral layer acp-integration is directed to; it must
// not import `serve/` internals itself, or the #8084 boundary reforms
// transitively one hop away.
files: ['packages/cli/src/runtime/**/*.{ts,tsx}'],
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
rules: {
'no-restricted-imports': [
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
'error',
restrictedServeImports(
'packages/cli/src/runtime must not import serve/ internals (#8084).',
),
],
},
},
{
// `utils/` is the layer every other directory imports, so it must not
// import back into one. The daemon direction is clean and enforced here;
Expand All @@ -81,15 +179,9 @@ export default tseslint.config(
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/serve/*', '**/serve/**'],
message:
'packages/cli/src/utils must not import serve/. Move lifecycle-free logic down into utils/ instead (#9146).',
},
],
},
restrictedServeImports(
'packages/cli/src/utils must not import serve/. Move lifecycle-free logic down into utils/ instead (#9146).',
),
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
],
},
},
Expand Down Expand Up @@ -170,15 +262,8 @@ export default tseslint.config(
'no-duplicate-case': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.name="require"]',
message: 'Avoid using require(). Use ES6 imports instead.',
},
{
selector: 'ThrowStatement > Literal:not([value=/^\\w+Error:/])',
message:
'Do not throw string literals or non-Error objects. Throw new Error("...") instead.',
},
restrictedRequire,
restrictedStringThrow,
],
'no-unsafe-finally': 'error',
'no-console': 'error',
Expand All @@ -197,6 +282,56 @@ export default tseslint.config(
'default-case': 'error',
},
},
{
// Positioned after the general TS block so the dynamic-import guard is not
// overwritten by the shared `no-restricted-syntax` rule.
files: ['packages/cli/src/runtime/**/*.{ts,tsx}'],
rules: {
'no-restricted-syntax': serveGuardSyntaxRules(
'packages/cli/src/runtime must not dynamically import serve/ internals (#8084).',
),
},
},
{
// Positioned after the general TS block so the dynamic-import guard is not
// overwritten by the shared `no-restricted-syntax` rule.
files: ['packages/cli/src/utils/**/*.{ts,tsx}'],
rules: {
'no-restricted-syntax': serveGuardSyntaxRules(
'packages/cli/src/utils must not dynamically import serve/. Move lifecycle-free logic down into utils/ instead (#9146).',
),
},
},
{
// ACP integration and the daemon are separate runtime surfaces that happen
// to share a package directory. ACP may consume neutral contracts under
// `runtime/`, but never `serve/` implementation modules — see #8084.
// Enforcement point is `npm run lint` in CI; fixture coverage lives in
// scripts/tests/eslint-boundary-rules.test.js (serve-boundary cases plus
// a string-throw probe that pins the restated selectors below).
//
// Positioned after the general TS block on purpose: flat config lets the
// last matching block win per rule, and that block also configures
// `no-restricted-syntax` — placing this one earlier would silently lose
// the dynamic-import guard below. The shared selectors are restated via
// serveGuardSyntaxRules so this override does not drop them.
files: ['packages/cli/src/acp-integration/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
restrictedServeImports(
'acp-integration must not import serve/ internals. Put shared, lifecycle-free logic in packages/cli/src/runtime/ instead (#8084).',
),
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
],
// no-restricted-imports only visits static import/export declarations;
// the same boundary applies to dynamic `await import('../serve/…')`.
// The selector regex spells `/` as `\x2f` because esquery cannot parse
// a literal slash inside its attribute-regex syntax.
'no-restricted-syntax': serveGuardSyntaxRules(
'acp-integration must not dynamically import serve/ internals. Put shared, lifecycle-free logic in packages/cli/src/runtime/ instead (#8084).',
),
},
},
{
files: [
'packages/web-shell/client/**/*.{ts,tsx}',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/acp-integration/acpAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ import {
type PermissionRuleSet,
} from '../config/permission-settings.js';
import { createLoadedSettingsAdapter } from '../config/loadedSettingsAdapter.js';
import { isCompatibleLiveSessionSource } from '../serve/conversations/session-source.js';
import { isCompatibleLiveSessionSource } from '../runtime/live-session-source.js';
import type { ApprovalModeValue } from './session/types.js';
import { z } from 'zod';
import type { CliArgs } from '../config/config.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/acp-integration/session/Session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import * as nonInteractiveCliCommands from '../../nonInteractiveCliCommands.js';
import { CommandKind } from '../../ui/commands/types.js';
import { buildAcpModelOptions } from '../../utils/acpModelUtils.js';
import { CHANNEL_PROMPT_META_KEY } from '@qwen-code/channel-base';
import { CAPTURE_SCREEN_CONTEXT_TOOL_NAME } from '../../serve/live/capture-screen-context.js';
import { SPEAK_TO_USER_TOOL_NAME } from '../../serve/live/live-speak-to-user.js';
import { CAPTURE_SCREEN_CONTEXT_TOOL_NAME } from '../live/capture-screen-context.js';
import { SPEAK_TO_USER_TOOL_NAME } from '../live/live-speak-to-user.js';
import {
collectHistoryReplayUpdates,
createReplayCumulativeUsage,
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/acp-integration/session/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,19 @@ import { normalizeChannelDeliveryText } from '../../runtime/channel-delivery.js'
import {
CAPTURE_SCREEN_CONTEXT_TOOL_NAME,
CaptureScreenContextTool,
} from '../../serve/live/capture-screen-context.js';
} from '../live/capture-screen-context.js';
import {
createLiveTaskTools,
type LiveTaskTool,
} from '../../serve/live/live-task-tools.js';
} from '../live/live-task-tools.js';
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
import {
SPEAK_TO_USER_TOOL_NAME,
SpeakToUserTool,
} from '../../serve/live/live-speak-to-user.js';
} from '../live/live-speak-to-user.js';
import {
LIVE_BACKEND_END_INSTRUCTIONS,
LIVE_BACKEND_START_INSTRUCTIONS,
} from '../../serve/live/live-backend-instructions.js';
} from '../live/live-backend-instructions.js';
import { readVoiceModel } from '../../services/voice-settings.js';
import {
MAX_AUDIO_BYTES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { describe, expect, it } from 'vitest';
import {
isReservedLiveSessionSource,
readLoadableLiveConversationMetadata,
} from './session-source.js';
} from './live-session-source.js';

describe('readLoadableLiveConversationMetadata', () => {
const records = new Map([
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/serve/acp-http/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { restoreRetryAfterSeconds } from '@qwen-code/acp-bridge/sessionRestoreTi
import {
isReservedLiveSessionSource,
readLoadableLiveConversationMetadata,
} from '../conversations/session-source.js';
} from '../../runtime/live-session-source.js';
import {
translateAndCheckAbsoluteWorkspacePath,
canonicalizeWorkspace,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/serve/live/live-session-coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ import type { LiveProviderCredential } from './provider-credentials.js';
import {
isCompatibleLiveSessionSource,
LIVE_SESSION_SOURCE_PREFIX,
} from '../conversations/session-source.js';
} from '../../runtime/live-session-source.js';
import type { LiveProviderReadiness, LiveSessionLocator } from './types.js';

export { LIVE_SESSION_SOURCE_PREFIX } from '../conversations/session-source.js';
export { LIVE_SESSION_SOURCE_PREFIX } from '../../runtime/live-session-source.js';

const MAX_COORDINATOR_REQUEST_CHARS = 32_000;
const MAX_COORDINATOR_RESULT_CHARS = 48_000;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/serve/live/live-task-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
WorkspaceRuntime,
} from '../workspace-registry.js';
import { LiveTaskService } from './live-task-service.js';
import { LIVE_SESSION_SOURCE_PREFIX } from '../conversations/session-source.js';
import { LIVE_SESSION_SOURCE_PREFIX } from '../../runtime/live-session-source.js';

const persistedSessions = vi.hoisted(() => new Map<string, unknown>());
const persistedSessionOwners = vi.hoisted(() => new Map<string, string>());
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/serve/live/live-task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { listWorkspaceSessionsForResponse } from '../server/session-list.js';
import {
isCompatibleLiveSessionSource,
readLoadableLiveConversationMetadata,
} from '../conversations/session-source.js';
} from '../../runtime/live-session-source.js';

const DEFAULT_LIST_LIMIT = 20;
const DEFAULT_READ_TURN_LIMIT = 3;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/serve/multi-workspace-sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
} from './workspace-registry.js';
import type { WorkspaceRuntimeProvenance } from './managed-scratch-workspace.js';
import type { ConversationWorkspace } from './conversations/conversation-workspace.js';
import { LIVE_SESSION_SOURCE_PREFIX } from './conversations/session-source.js';
import { LIVE_SESSION_SOURCE_PREFIX } from '../runtime/live-session-source.js';
import { createSessionOrganizationService } from './session-organization-helpers.js';
import {
serializeWorkspaceTranscriptResponseForTesting,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/serve/routes/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { parseSessionSource } from '@qwen-code/acp-bridge';
import {
isReservedLiveSessionSource,
readLoadableLiveConversationMetadata,
} from '../conversations/session-source.js';
} from '../../runtime/live-session-source.js';
import type { Application, Request, RequestHandler, Response } from 'express';
import { writeStderrLine } from '../../utils/stdioHelpers.js';
import { parseCallerSuppliedSessionId } from '../../config/session-id.js';
Expand Down
Loading
Loading