Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

stop failing idle-out TUI runs whose work product isn't files (#3102)

[._.]/ Adam Eivy06ef4a50f827
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0b9308ee2a..25c83152b0 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -23,6 +23,7 @@
## CoS agent failure reporting
+- A reference-watch run against a GitHub/GitLab/JIRA work tracker is no longer failed for leaving a clean worktree. Those runs file issues instead of editing application code, so "no file changes" is what success looks like — a task can now declare that its work product isn't files, and only that check is relaxed (a run that never actually started still fails).
- Failed agent runs are classified far more accurately. A terminal-UI agent's transcript is a repainted *screen*, not a log — it can run to hundreds of kilobytes while containing barely any line breaks — so the analyzer's "look at the recent output" window was quietly reading the entire session. Any keyword anywhere in it, including commands the agent itself typed, decided the verdict: one run reaped for going idle was reported as "Context length exceeded", which blocked its task and auto-filed an investigation for a problem that never happened.
- When the system already knows why a run ended — the idle watchdog fired, the runtime budget ran out, the provider CLI wasn't installed — that is now what gets reported. Only a genuine provider or system error in the transcript can override it.
- Failure snippets shown on an agent's record are now short, readable excerpts centered on the actual error instead of raw terminal escape codes. One failed run had been writing an 816KB blob of control characters into its own record.
diff --git a/server/lib/README.md b/server/lib/README.md
index 7a0b451021..f1663f83f9 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -297,7 +297,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `uploadLimits.js` | Single source of truth for upload size caps — `JSON_BODY_LIMIT`/`JSON_BODY_LIMIT_BYTES` (the express.json limit applied in `index.js`), `MAX_BASE64_UPLOAD_BYTES` derived from it (base64 ×4/3, so a bigger per-route cap is unreachable), `MAX_SCREENSHOT_BYTES`. Mirrored client-side as `JSON_UPLOAD_MAX_FILE_SIZE`. |
| `uuid.js` | `v4()` thin wrapper over `crypto.randomUUID()`. |
| `versionUtils.js` | `compareSemver(a, b)` — semver ordering (-1/0/1) with pre-release precedence and build-metadata stripping. Shared by the self-update checker (`updateChecker.js`) and the local-LLM Ollama update detector (`localLlm.js`). Inputs must be `v`-stripped. |
-| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `isGithubHost` (GitHub-family host test — github.com + enterprise github.*; enterprise-aware replacement for the github.com-only `isGithub` gate), `githubRepoSpec(origin)` (host-qualified `HOST/OWNER/REPO` selector for `gh --repo`, or null for a non-GitHub origin — pairs the isGithubHost gate with the selector so prWatcher/branchReconcile/issueReconcile share one "resolvable GitHub repo" definition), `forgeCliForTracker`, `trackerToClaimTaskType`, `hostFromOriginUrl` (subgroup-tolerant host parse), pure `resolveWorkTracker({configured,host})`, async `resolveAppWorkTracker(app)` — resolves a managed app's autonomous work source (PLAN.md / GitHub / GitLab / JIRA), defaulting `'auto'` to the git origin host. Consumed by the `claim-work` router in `cosTaskGenerator.js` and `routes/apps.js`. |
+| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `isGithubHost` (GitHub-family host test — github.com + enterprise github.*; enterprise-aware replacement for the github.com-only `isGithub` gate), `githubRepoSpec(origin)` (host-qualified `HOST/OWNER/REPO` selector for `gh --repo`, or null for a non-GitHub origin — pairs the isGithubHost gate with the selector so prWatcher/branchReconcile/issueReconcile share one "resolvable GitHub repo" definition), `forgeCliForTracker`, `isFileTracker` (true when the tracker records work as repo files — PLAN.md — so an agent's proposal necessarily dirties the worktree; false for github/gitlab/jira), `trackerToClaimTaskType`, `hostFromOriginUrl` (subgroup-tolerant host parse), pure `resolveWorkTracker({configured,host})`, async `resolveAppWorkTracker(app)` — resolves a managed app's autonomous work source (PLAN.md / GitHub / GitLab / JIRA), defaulting `'auto'` to the git origin host. Consumed by the `claim-work` router in `cosTaskGenerator.js` and `routes/apps.js`. |
| `workspaceRoots.js` | Shared allow-list for routes that take a caller-supplied filesystem path. `ALLOWED_WORKSPACE_ROOTS` (defaults + `PORTOS_WORKSPACE_ROOTS`, symlink-resolved), `isWithinRoot(resolvedPath, root)` (separator-safe containment), `isWithinAllowedRoots(realPath)`, and `WORKSPACE_ROOTS_CONFIGURED` (true when the operator set the env var — lets a permissive-by-default route like `routes/detect.js` opt into confinement). Used by `routes/commands.js` (always scoped) and `routes/detect.js` (scoped only when configured). |
| `zodCompat.js` | Zod 4 compatibility helpers. `partialWithoutDefaults(objectSchema)` — like `.partial()` but strips inner field defaults first, so a PATCH/update schema doesn't inject (and clobber) the stored values of fields the caller didn't send. Use for any update schema derived from a defaulted base. |
diff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.js
index a807d9049e..a7ea1331cc 100644
--- a/server/lib/cosValidation.js
+++ b/server/lib/cosValidation.js
@@ -487,6 +487,10 @@ export const createCosJobSchema = z.object({
openPR: z.boolean().optional(),
prCompletion: z.enum(PR_COMPLETION_VALUES).optional(),
simplify: z.boolean().optional(),
+ // Absent = true (a clean worktree at idle-out is a failure). `false` opts the
+ // job out of the TUI idle-complete worktree-changes gate — see
+ // ALLOWED_TASK_METADATA_KEYS below and agentTuiSpawning.js (#3102).
+ worktreeChangesExpected: z.boolean().optional(),
}).optional(),
});
@@ -628,7 +632,14 @@ const ALLOWED_TASK_METADATA_KEYS = [
// Throwaway-worktree posture for programmatic-I/O reasoning tasks (layered-
// intelligence): the worktree is discarded without a merge or PR so a reasoning
// agent can't land code. See agentWorktreeCleanup.js.
- 'discardWorktree'
+ 'discardWorktree',
+ // Whether a successful run is EXPECTED to leave file changes in the worktree
+ // (#3102). Default (absent) = true: the TUI idle-complete gate fails a run that
+ // idled out on a clean tree. `false` opts a task type out of that gate — e.g. a
+ // reference-watch run against a GitHub/GitLab/JIRA work tracker files its
+ // proposals as issues and, per the prompt, edits no application code, so a
+ // clean worktree is the SUCCESS shape. See agentTuiSpawning.js.
+ 'worktreeChangesExpected'
];
// pr-watcher author-gate values. 'self' = PRs opened by the gh-authenticated
diff --git a/server/lib/cosValidation.test.js b/server/lib/cosValidation.test.js
index 4ca5fdbf92..cc8d4f3d93 100644
--- a/server/lib/cosValidation.test.js
+++ b/server/lib/cosValidation.test.js
@@ -48,3 +48,17 @@ describe('cosValidation autonomous-job effort field', () => {
expect(updateCosJobSchema.safeParse({ effort: 'bogus' }).success).toBe(false);
});
});
+
+describe('cosValidation job taskMetadata.worktreeChangesExpected (#3102)', () => {
+ it('accepts the flag and preserves an explicit false (schema parity with the sanitizer)', () => {
+ // Zod strips undeclared keys, so an unlisted flag would be silently dropped
+ // from a job's taskMetadata — the opt-out has to be declared here too.
+ const parsed = createCosJobSchema.parse({
+ name: 'j',
+ taskMetadata: { useWorktree: true, worktreeChangesExpected: false },
+ });
+ expect(parsed.taskMetadata).toEqual({ useWorktree: true, worktreeChangesExpected: false });
+ expect(createCosJobSchema.safeParse({ name: 'j', taskMetadata: { worktreeChangesExpected: 'nope' } }).success)
+ .toBe(false);
+ });
+});
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 49eb555f7f..d42b8ae85b 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -710,6 +710,18 @@ describe('validation.js', () => {
.toEqual({ useWorktree: true, openPR: true, simplify: true, reviewLoop: false });
});
+ it('should accept worktreeChangesExpected as an allowed boolean key (#3102)', () => {
+ // `false` is the load-bearing value: it opts a task out of the TUI
+ // idle-complete clean-worktree gate. If the sanitizer dropped it, a
+ // reference-watch run against a forge tracker would keep failing.
+ expect(sanitizeTaskMetadata({ worktreeChangesExpected: false }))
+ .toEqual({ worktreeChangesExpected: false });
+ expect(sanitizeTaskMetadata({ worktreeChangesExpected: true }))
+ .toEqual({ worktreeChangesExpected: true });
+ // Non-boolean can't smuggle a truthy string past the gate.
+ expect(sanitizeTaskMetadata({ worktreeChangesExpected: 'false' })).toBeNull();
+ });
+
it('should accept only known PR completion metadata', () => {
expect(sanitizeTaskMetadata({ prCompletion: 'review-then-merge' }))
.toEqual({ prCompletion: 'review-then-merge' });
diff --git a/server/lib/workTracker.js b/server/lib/workTracker.js
index 3dedc19538..72ac4325fa 100644
--- a/server/lib/workTracker.js
+++ b/server/lib/workTracker.js
@@ -121,6 +121,22 @@ export function forgeCliForTracker(tracker) {
return null;
}
+/**
+ * True when a concrete tracker records work as FILES in the repo (PLAN.md) —
+ * i.e. an agent that files a proposal there necessarily dirties the worktree.
+ * The forge/ticket trackers (github/gitlab/jira) take their work out-of-band via
+ * `gh`/`glab`/JIRA, so a successful run can legitimately leave a clean tree.
+ * Consumed by `triggerReferenceAnalysis` to stamp `worktreeChangesExpected` on
+ * the spawned task off the SAME resolved value that picks the prompt's
+ * {trackerInstructions} block, so the flag can't drift from the instructions the
+ * agent actually got (see agentTuiSpawning.js's idle-complete gate, #3102).
+ * An unknown/absent tracker is treated as file-based, matching
+ * formatTrackerInstructions' PLAN.md fallback.
+ */
+export function isFileTracker(tracker) {
+ return !['github', 'gitlab', 'jira'].includes(tracker);
+}
+
/**
* The CoS claim task type that ships work from a concrete tracker. The
* claim-work router (cosTaskGenerator) delegates to one of these prompt bodies
diff --git a/server/lib/workTracker.test.js b/server/lib/workTracker.test.js
index 66fd928b31..2c0417b07d 100644
--- a/server/lib/workTracker.test.js
+++ b/server/lib/workTracker.test.js
@@ -9,6 +9,7 @@ import {
githubRepoSpec,
githubApiHost,
forgeCliForTracker,
+ isFileTracker,
trackerToClaimTaskType,
resolveWorkTracker,
hostFromOriginUrl,
@@ -118,6 +119,26 @@ describe('forgeCliForTracker', () => {
});
});
+describe('isFileTracker', () => {
+ it('is true only for trackers whose work product is a repo file (#3102)', () => {
+ // PLAN.md work lands as a committed file → a run necessarily dirties the tree.
+ expect(isFileTracker('plan')).toBe(true);
+ // Forge/ticket trackers take the work out-of-band → a clean tree is success.
+ expect(isFileTracker('github')).toBe(false);
+ expect(isFileTracker('gitlab')).toBe(false);
+ expect(isFileTracker('jira')).toBe(false);
+ });
+
+ it('treats an unknown/absent tracker as file-based, matching the PLAN.md fallback', () => {
+ // formatTrackerInstructions falls back to the PLAN.md block for anything
+ // unrecognized, so the flag must agree or it drifts from the prompt.
+ expect(isFileTracker('auto')).toBe(true);
+ expect(isFileTracker('nonsense')).toBe(true);
+ expect(isFileTracker(undefined)).toBe(true);
+ expect(isFileTracker(null)).toBe(true);
+ });
+});
+
describe('trackerToClaimTaskType', () => {
it('routes each concrete tracker to its claim prompt task type', () => {
expect(trackerToClaimTaskType('plan')).toBe('plan-task');
diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.js
index 8557053bd5..65ca45fa5c 100644
--- a/server/services/agentTuiSpawning.js
+++ b/server/services/agentTuiSpawning.js
@@ -16,7 +16,7 @@ import { registerSpawnedAgent, unregisterSpawnedAgent } from './agents.js';
import { createOutputSpooler } from './agentTuiSpawning/outputSpooler.js';
import { captureWorktreeDiff, worktreeHasChanges, resolveErrorAnalysis } from './agentTuiSpawning/finalizeHelpers.js';
import { finalizeAgent, releaseAgentLane } from './agentFinalization.js';
-import { activeAgents, userTerminatedAgents, pausedAgents } from './agentState.js';
+import { activeAgents, userTerminatedAgents, pausedAgents, isFalsyMeta } from './agentState.js';
import { PATHS } from '../lib/fileUtils.js';
import { DONE_SENTINEL_NAME, parseSentinelPayload } from '../lib/agentSentinel.js';
import * as git from './git.js';
@@ -1096,10 +1096,21 @@ export async function spawnTuiAgent({
// Gate idle-complete success on evidence of work in the worktree.
// An agent that shows activity counters but makes no file changes
// (rambled, invalid tool calls, hit an error) should fail, not succeed.
+ //
+ // ...UNLESS the task declares its work product isn't files (#3102).
+ // `worktreeChangesExpected: false` marks a task type whose deliverable
+ // lands OUTSIDE the repo — a reference-watch run against a GitHub/GitLab/
+ // JIRA work tracker files issues and, per its prompt, edits no application
+ // code, so a clean tree is the SUCCESS shape and this gate would fail a run
+ // that did its whole job. Absent/`true` keeps every code-editing task type
+ // on today's behavior; the `workActivity.active` signal above still
+ // distinguishes "prompt never submitted" → idle-no-activity either way.
+ const worktreeChangesExpected = !isFalsyMeta(task?.metadata?.worktreeChangesExpected);
(async () => {
- const hasChanges = await worktreeHasChanges(cwd);
+ const hasChanges = !worktreeChangesExpected || await worktreeHasChanges(cwd);
// Capture any uncommitted changes for post-mortem analysis regardless
- // of outcome — the diff is useful even on success for debugging.
+ // of outcome — the diff is useful even on success for debugging, and is
+ // a no-op on a clean tree.
await captureWorktreeDiff(cwd, agentDir).catch(() => {});
if (!hasChanges) {
finish({
diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.js
index f2a964e74b..d341dda8d8 100644
--- a/server/services/agentTuiSpawning.test.js
+++ b/server/services/agentTuiSpawning.test.js
@@ -67,7 +67,10 @@ vi.mock('./agentFinalization.js', () => ({
vi.mock('./agentState.js', () => ({
activeAgents: new Map(),
userTerminatedAgents: new Set(),
- pausedAgents: new Map()
+ pausedAgents: new Map(),
+ // Mirrors the real predicate (covers the TASKS.md string round-trip) — the
+ // worktreeChangesExpected opt-out reads through it.
+ isFalsyMeta: (value) => value === false || value === 'false',
}));
vi.mock('./git.js', () => ({
@@ -712,6 +715,122 @@ describe('spawnTuiAgent runtime', () => {
);
});
+ // ── 1a-quater. worktreeChangesExpected:false skips the clean-tree gate (#3102) ─
+ // Issue #3102: the #2191 gate above assumes every agent's work product is a
+ // file change. A `reference-watch` run against a GitHub/GitLab/JIRA work
+ // tracker files ISSUES and — per its own prompt — edits no application code,
+ // so a run that did its whole job leaves a CLEAN worktree and was recorded as
+ // `idle-no-changes` failure. `worktreeChangesExpected: false` opts such a task
+ // out of the worktree gate, leaving `workActivity.active` as the sole signal.
+ //
+ // Drives the same PTY sequence as the idle-no-changes test: prompt echo →
+ // submit → an ADVANCING work counter → idle out, with a clean worktree.
+ async function driveIdleWithWorkOnCleanTree(overrides) {
+ vi.mocked(gitService.getStatus).mockResolvedValue({ clean: true, files: [] });
+ vi.mocked(gitService.getDiff).mockResolvedValue('');
+
+ let resolveComplete;
+ const completeDone = new Promise((r) => { resolveComplete = r; });
+ vi.mocked(agentLifecycle.finalizeAgent).mockImplementation(async () => { resolveComplete(); });
+
+ runSpawn(overrides);
+ await flushMicrotasks();
+
+ await capturedOnData(Buffer.from('Codex booting...\n'));
+ await flushMicrotasks();
+ await vi.advanceTimersByTimeAsync(2000);
+ await flushMicrotasks();
+
+ // Prompt echo so paste verification passes and the submit-Enter fires.
+ await capturedOnData(Buffer.from('do the thing\n'));
+ await flushMicrotasks();
+ await vi.advanceTimersByTimeAsync(3600);
+ await flushMicrotasks();
+
+ // An ADVANCING work counter → workActivity.active becomes true.
+ await capturedOnData(Buffer.from('(1s · thinking with high effort)\n'));
+ await vi.advanceTimersByTimeAsync(800);
+ await capturedOnData(Buffer.from('(2s · thinking with high effort)\n'));
+
+ await vi.advanceTimersByTimeAsync(21000);
+ vi.useRealTimers();
+ await completeDone;
+ }
+
+ it('idle-complete: worktreeChangesExpected:false succeeds on a clean worktree (non-file work tracker)', async () => {
+ await driveIdleWithWorkOnCleanTree({
+ task: { id: 'task-1', description: 'do the thing', metadata: { worktreeChangesExpected: false } },
+ });
+
+ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(
+ expect.objectContaining({
+ agentId: 'agent-1',
+ success: true,
+ completionReason: 'idle-complete',
+ })
+ );
+ // The gate is skipped, so git status is never consulted — but the diff
+ // capture still runs unconditionally (a no-op on a clean tree, and useful
+ // for post-mortems either way).
+ expect(gitService.getStatus).not.toHaveBeenCalled();
+ expect(gitService.getDiff).toHaveBeenCalledWith('/tmp/ws', true);
+ expect(gitService.getDiff).toHaveBeenCalledWith('/tmp/ws', false);
+ });
+
+ it("idle-no-changes: the TASKS.md string round-trip 'false' also opts out of the gate", async () => {
+ // Task metadata survives a markdown round-trip as strings, so the opt-out
+ // must read through isFalsyMeta rather than a bare `=== false`.
+ await driveIdleWithWorkOnCleanTree({
+ task: { id: 'task-1', description: 'do the thing', metadata: { worktreeChangesExpected: 'false' } },
+ });
+
+ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(
+ expect.objectContaining({ success: true, completionReason: 'idle-complete' })
+ );
+ });
+
+ it('idle-no-changes: worktreeChangesExpected:true still fails on a clean worktree (no behavior change)', async () => {
+ await driveIdleWithWorkOnCleanTree({
+ task: { id: 'task-1', description: 'do the thing', metadata: { worktreeChangesExpected: true } },
+ });
+
+ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(
+ expect.objectContaining({ success: false, completionReason: 'idle-no-changes' })
+ );
+ });
+
+ it('idle-no-activity: worktreeChangesExpected:false does NOT rescue a run with zero work-counter activity', async () => {
+ // The flag only relaxes the worktree-evidence gate. A prompt that never
+ // submitted (no working indicator ever appeared) must still fail — otherwise
+ // opting out of the file gate would silently launder a total no-op run.
+ vi.mocked(gitService.getStatus).mockResolvedValue({ clean: true, files: [] });
+ vi.mocked(gitService.getDiff).mockResolvedValue('');
+
+ let resolveComplete;
+ const completeDone = new Promise((r) => { resolveComplete = r; });
+ vi.mocked(agentLifecycle.finalizeAgent).mockImplementation(async () => { resolveComplete(); });
+
+ runSpawn({ task: { id: 'task-1', description: 'do the thing', metadata: { worktreeChangesExpected: false } } });
+ await flushMicrotasks();
+
+ await capturedOnData(Buffer.from('Codex booting...\n'));
+ await flushMicrotasks();
+ await vi.advanceTimersByTimeAsync(2000);
+ await flushMicrotasks();
+
+ // Chrome-only repaints — the working counter never advances.
+ await capturedOnData(Buffer.from('⏵⏵ bypass permissions on (shift+tab to cycle)\n'));
+ await capturedOnData(Buffer.from('● high · /effort\n'));
+
+ await vi.advanceTimersByTimeAsync(21000);
+ vi.useRealTimers();
+ await completeDone;
+
+ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(
+ expect.objectContaining({ success: false, completionReason: 'idle-no-activity' })
+ );
+ });
+
// ── 1c. Absolute wall-clock backstop reaps a busy-but-stuck agent ───────────
// The idle reaper resets on every PTY chunk, so an agent whose working counter
// keeps repainting through a stalled provider retry never idles out and would
diff --git a/server/services/referenceRepos.js b/server/services/referenceRepos.js
index 47e927ab4a..4fcd441014 100644
--- a/server/services/referenceRepos.js
+++ b/server/services/referenceRepos.js
@@ -33,7 +33,7 @@ import {
updateApp,
} from './apps.js';
import { DEFAULT_REVIEWER } from '../lib/validation.js';
-import { resolveAppWorkTracker } from '../lib/workTracker.js';
+import { resolveAppWorkTracker, isFileTracker } from '../lib/workTracker.js';
const REFERENCE_REPOS_ROOT = join(PATHS.data, 'cos', 'reference-repos');
@@ -686,6 +686,15 @@ export async function triggerReferenceAnalysis(app, ref, snapshot) {
// files" guard into the system prompt and the agent would refuse to
// write/commit/shell — defeating the whole flow. Mark writable.
readOnly: false,
+ // Whether the run is expected to dirty the worktree. Derived from the SAME
+ // `workTracker.resolved` value that selected the {trackerInstructions}
+ // block above, so the flag can never disagree with the instructions the
+ // agent actually received: the PLAN.md path commits checklist items (dirty
+ // tree), while the github/gitlab/jira paths file issues/tickets and — per
+ // the prompt's "no source-code edits" contract — leave the tree CLEAN.
+ // Without this the TUI idle reaper records a run that did its whole job as
+ // `idle-no-changes` failure (#3102).
+ worktreeChangesExpected: isFileTracker(workTracker.resolved),
context: fullPrompt,
},
autoApproved: true,
diff --git a/server/services/referenceRepos.test.js b/server/services/referenceRepos.test.js
index 35a2d027c9..807023e0cc 100644
--- a/server/services/referenceRepos.test.js
+++ b/server/services/referenceRepos.test.js
@@ -405,6 +405,9 @@ describe('triggerReferenceAnalysis', () => {
// {trackerInstructions} block reflects that.
expect(taskArg.metadata.workTracker).toBe('plan');
expect(taskArg.metadata.context).toContain('PLAN.md');
+ // The PLAN.md path COMMITS checklist items, so a successful run dirties the
+ // worktree and the TUI idle-complete gate must stay armed (#3102).
+ expect(taskArg.metadata.worktreeChangesExpected).toBe(true);
});
it('injects the GitHub-issue tracker instructions when the app is configured for github', async () => {
@@ -416,6 +419,22 @@ describe('triggerReferenceAnalysis', () => {
// The injected block drives `gh issue create`, not a PLAN.md append.
expect(taskArg.metadata.context).toContain('gh issue create');
expect(taskArg.metadata.context).toContain('GitHub Issues');
+ // The agent files ISSUES and edits no application code, so a successful run
+ // leaves a CLEAN worktree — the idle-complete gate must be opted out of, or
+ // the run is recorded as an `idle-no-changes` failure (#3102).
+ expect(taskArg.metadata.worktreeChangesExpected).toBe(false);
+ });
+
+ it.each([
+ ['gitlab', false],
+ ['jira', false],
+ ['plan', true],
+ ])('stamps worktreeChangesExpected off the same resolved tracker (%s → %s)', async (tracker, expected) => {
+ const result = await svc.triggerReferenceAnalysis({ ...app, workTracker: tracker }, ref, snapshot);
+ expect(result.queued).toBe(true);
+ const taskArg = addTaskMock.mock.calls[0][0];
+ expect(taskArg.metadata.workTracker).toBe(tracker);
+ expect(taskArg.metadata.worktreeChangesExpected).toBe(expected);
});
it('exposes formatTrackerInstructions and falls back to PLAN.md for an unknown tracker', () => {