claude-code-session-manager 0.125.0 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +4 -3
- package/dist/assets/{AgentLibrary-CcnnJg8P.js → AgentLibrary-bzeuZN4F.js} +1 -1
- package/dist/assets/{Button-sA4lqAao.js → Button-8dWfDDuQ.js} +1 -1
- package/dist/assets/{DataModel-BSTejIBU.js → DataModel-D4ybBPZN.js} +1 -1
- package/dist/assets/{History-DuwlZsQ5.js → History-hsztE6yh.js} +1 -1
- package/dist/assets/{Hooks-DHDSoDJ_.js → Hooks-CRmZMQaW.js} +1 -1
- package/dist/assets/{Library-XA9osRfi.js → Library-Czt3Bojd.js} +1 -1
- package/dist/assets/{ListDetail-B3goE3Wc.js → ListDetail-Cr6Ct_WX.js} +1 -1
- package/dist/assets/{McpServers-cMZTsPS6.js → McpServers-CeXJ2bng.js} +1 -1
- package/dist/assets/{Memory-D6qntpZ0.js → Memory-caujO8O3.js} +1 -1
- package/dist/assets/{Panel-DIyJXHfp.js → Panel-D64i9tGz.js} +1 -1
- package/dist/assets/{Permissions-DJda4Aii.js → Permissions-DpWOIrvr.js} +1 -1
- package/dist/assets/{Plugins-DcdRVBnU.js → Plugins-Bd1ekP5P.js} +2 -2
- package/dist/assets/{ProvenanceBadge-BSI_2wAv.js → ProvenanceBadge-B96A_uZf.js} +1 -1
- package/dist/assets/{SaveBar-CeL4vXRp.js → SaveBar-D0Y2t-Ao.js} +1 -1
- package/dist/assets/{Scheduler-CTd19y5U.js → Scheduler-Y5_YbNrC.js} +1 -1
- package/dist/assets/{ScopeSwitcher-BMiHySnz.js → ScopeSwitcher-BmWA_dP9.js} +1 -1
- package/dist/assets/{Settings-D-oIEKZy.js → Settings-Bcf65bpL.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-B_7WfFjn.js → SkillReferenceGraph-BeSNXloA.js} +1 -1
- package/dist/assets/{Skills-CKpgxhSS.js → Skills-DwnQKJVc.js} +1 -1
- package/dist/assets/{SystemPrompt-BjJPTx_a.js → SystemPrompt-Dih6SCmL.js} +1 -1
- package/dist/assets/{TagLibrary-DJBB4gL0.js → TagLibrary-BZ-Kp10P.js} +1 -1
- package/dist/assets/{TiptapBody-C9Cu2GBL.js → TiptapBody-C2nEUmF7.js} +1 -1
- package/dist/assets/{Toggle-DbIRTOix.js → Toggle-Dw8-zNQo.js} +1 -1
- package/dist/assets/{ViewTabs-BDpHur6l.js → ViewTabs-CoYPKGN-.js} +1 -1
- package/dist/assets/{historyTotals-WCJHsBMq.js → historyTotals-BbKcNpV7.js} +1 -1
- package/dist/assets/{index-BD0ufZqe.js → index-DgPUERhe.js} +581 -581
- package/dist/assets/{settingsSchema-DmjBj3q7.js → settingsSchema-6doG_61l.js} +1 -1
- package/dist/assets/{skillFrontmatter-Tn_XHajE.js → skillFrontmatter-BYMYWDfb.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-Vz2iXtsQ.js → useAgentsDirWatch-Cqabjieh.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-web/{assets/app.js → app.js} +350 -350
- package/dist-web/index.html +2 -2
- package/package.json +4 -2
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +4 -3
- package/plugins/session-manager-dev/skills/develop/SKILL.md +2 -1
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +10 -2
- package/scripts/README.md +3 -1
- package/scripts/scheduler-mcp-server.cjs +17 -4
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +36 -2
- package/src/main/lib/epic/epicMint.cjs +6 -0
- package/src/main/lib/epic/epicSweepValidator.cjs +1 -1
- package/src/main/lib/epic/epicValidationHook.cjs +1 -1
- package/src/main/lib/epic/epicWorktreeMerge.cjs +9 -1
- package/src/main/lib/feedback-remote/autoStartedSession.cjs +102 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +130 -15
- package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +13 -2
- package/src/main/lib/git/gitExec.cjs +11 -1
- package/src/main/lib/git/gitWorktree.cjs +255 -9
- package/src/main/lib/git/jobWorktree.cjs +5 -0
- package/src/main/lib/mcpToolCatalog.cjs +9 -3
- package/src/main/lib/persona-macro/macroLibrary.cjs +21 -0
- package/src/main/lib/prd/prdDeclaredPaths.cjs +29 -2
- package/src/main/lib/promptSessionSchema.cjs +6 -1
- package/src/main/lib/scheduler/landedSinceRun.cjs +13 -5
- package/src/main/lib/scheduler/rcaReport.cjs +1 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +1 -0
- package/src/main/runVerify.cjs +59 -110
- package/src/main/scheduler/gitTreeGuard.cjs +51 -1
- package/src/main/scheduler/reviewLadder.cjs +11 -5
- package/src/main/scheduler.cjs +140 -22
- package/src/main/templates/PRD_AUTHORING.md +6 -2
- package/src/main/webRemote.cjs +9 -0
- package/src/preload/api.d.ts +7 -1
- /package/dist-web/{assets/app.css → app.css} +0 -0
package/src/main/scheduler.cjs
CHANGED
|
@@ -117,7 +117,7 @@ const { verifyRun, parseLog, scanSentinel, scanForeignWipPathsClaim } = require(
|
|
|
117
117
|
const { latestTerminalOutcomeForSlug, COMPLETED_EQUIVALENT_VERDICTS } = require('./lib/scheduler/terminalRunOutcome.cjs');
|
|
118
118
|
const { isFixPlanSlug, classifyDiscoveredFixPlan, resolveIsFixPlan } = require('./lib/scheduler/fixPlanSlug.cjs');
|
|
119
119
|
const { landedSinceRun, landedOnMainSince } = require('./lib/scheduler/landedSinceRun.cjs');
|
|
120
|
-
const { declaredPathsForPrd } = require('./lib/prd/prdDeclaredPaths.cjs');
|
|
120
|
+
const { declaredPathsForPrd, issuedAtForPrd } = require('./lib/prd/prdDeclaredPaths.cjs');
|
|
121
121
|
const { identity: procIdentityOf, isDifferentProcess } = require('./lib/process/procIdentity.cjs');
|
|
122
122
|
const logs = require('./logs.cjs');
|
|
123
123
|
const { schemas, validated, SCHEDULE_SLUG_RE } = require('./ipcSchemas.cjs');
|
|
@@ -3499,15 +3499,20 @@ function classifyFailureOutcome({ exitCode, networkError, durationMs, transientR
|
|
|
3499
3499
|
|
|
3500
3500
|
/**
|
|
3501
3501
|
* Evidence gathering for the commit-guard's already-satisfied-on-main
|
|
3502
|
-
* exemption (PRD 1136): does a commit reachable from
|
|
3502
|
+
* exemption (PRD 1136): does a commit reachable from the base branch, landed AFTER
|
|
3503
3503
|
* this job's `queuedAt`, touch a path this PRD itself declares? Scoped to
|
|
3504
3504
|
* the PRD's own declared paths via declaredPathsForPrd — the same
|
|
3505
3505
|
* path-extraction computeLooksDone already uses — so an unrelated commit
|
|
3506
|
-
* elsewhere in the repo is never credited to this job.
|
|
3507
|
-
*
|
|
3506
|
+
* elsewhere in the repo is never credited to this job. The window starts at the
|
|
3507
|
+
* earlier valid date of the row's `queuedAt` and the PRD's own `issuedAt` (a
|
|
3508
|
+
* re-minted row gets a new queuedAt; issuedAt survives). Returns `[]` (never
|
|
3509
|
+
* fabricates evidence) when the PRD names no paths or neither date is valid.
|
|
3508
3510
|
*
|
|
3509
|
-
*
|
|
3510
|
-
*
|
|
3511
|
+
* The PRD's `# Files` list is the declared change set; the backtick scan is
|
|
3512
|
+
* only for PRDs with no Files section.
|
|
3513
|
+
*
|
|
3514
|
+
* Requires EVERY declared path to have landed, not just one — for legacy PRDs
|
|
3515
|
+
* declaredPathsForPrd's regex matches any backtick-quoted path in the PRD's Implementation notes or
|
|
3511
3516
|
* Acceptance criteria, including a path cited only as context (e.g.
|
|
3512
3517
|
* `` `src/main/scheduler.cjs:1234` `` pointing at a call site, not a file this
|
|
3513
3518
|
* PRD's own work touches). Unlike computeLooksDone's identical path-overlap
|
|
@@ -3525,14 +3530,20 @@ function classifyFailureOutcome({ exitCode, networkError, durationMs, transientR
|
|
|
3525
3530
|
* @returns {Promise<string[]>} full commit SHAs reachable from main, newest first
|
|
3526
3531
|
*/
|
|
3527
3532
|
async function findSatisfyingCommitOnMain(job) {
|
|
3528
|
-
if (!job
|
|
3533
|
+
if (!job) return [];
|
|
3529
3534
|
const prdPath = (await resolveVerifyPrdPath(job)) ?? prdPaths.archivedPrdPathForJob(job);
|
|
3530
3535
|
const paths = declaredPathsForPrd(prdPath);
|
|
3531
3536
|
if (!paths.length) return [];
|
|
3537
|
+
const starts = [job.queuedAt, issuedAtForPrd(prdPath)]
|
|
3538
|
+
.map((d) => (d ? Date.parse(d) : NaN))
|
|
3539
|
+
.filter((t) => Number.isFinite(t));
|
|
3540
|
+
if (!starts.length) return [];
|
|
3541
|
+
const since = new Date(Math.min(...starts)).toISOString();
|
|
3532
3542
|
await gitTreeGuard.fetchAllRefs(job.cwd);
|
|
3533
|
-
const
|
|
3543
|
+
const baseBranch = job.worktreeBaseBranch || await jobWorktree.resolveDefaultBranch(job.cwd);
|
|
3544
|
+
const perPathCommits = await Promise.all(paths.map((p) => landedOnMainSince(job.cwd, since, [p], { baseBranch })));
|
|
3534
3545
|
if (perPathCommits.some((commits) => commits.length === 0)) return [];
|
|
3535
|
-
return landedOnMainSince(job.cwd,
|
|
3546
|
+
return landedOnMainSince(job.cwd, since, paths, { baseBranch });
|
|
3536
3547
|
}
|
|
3537
3548
|
|
|
3538
3549
|
/**
|
|
@@ -3894,7 +3905,7 @@ function stampIntegrationFailure(row, integration) {
|
|
|
3894
3905
|
async function resolveHeadShasForPass(jobs) {
|
|
3895
3906
|
const byCwd = new Map();
|
|
3896
3907
|
for (const j of jobs || []) {
|
|
3897
|
-
if (!j || j.status !== 'needs_review' || j.integrationFailureKind
|
|
3908
|
+
if (!j || j.status !== 'needs_review' || !reviewLadder.isHeadSensitiveFailureKind(j.integrationFailureKind)) continue;
|
|
3898
3909
|
const cwd = j.cwd || DEFAULT_PROJECT_CWD;
|
|
3899
3910
|
if (!byCwd.has(cwd)) byCwd.set(cwd, gitTreeGuard.gitHead(cwd));
|
|
3900
3911
|
}
|
|
@@ -4997,7 +5008,26 @@ The fix-plan PRD you write for this MUST instruct its executor to, in order:
|
|
|
4997
5008
|
1. Check for a salvage patch (named \`<slug>.uncommitted.patch\` in the run directory${failedJob.salvagePatch ? `, e.g. \`${failedJob.salvagePatch}\`` : ''}) and, if found, apply it to the working tree BEFORE inspecting \`git status\`/\`git diff\` in ${cwd} for uncommitted changes matching the original PRD's acceptance criteria.
|
|
4998
5009
|
2. If the work is present (via the applied patch or already in the tree) and satisfies the acceptance criteria, run the project's verify commands and COMMIT it — do not re-implement or re-plan the PRD from scratch.
|
|
4999
5010
|
3. Only fall back to re-implementing whatever acceptance criteria are genuinely missing after applying any salvage patch, not the whole PRD.` : '';
|
|
5000
|
-
|
|
5011
|
+
const runCommitNotLandedNote = failedJob.verifierVerdict === 'run_commit_not_landed' ? `
|
|
5012
|
+
|
|
5013
|
+
# Known failure class: run_commit_not_landed
|
|
5014
|
+
This job's verifier verdict is \`run_commit_not_landed\`: the run committed its work on a detached
|
|
5015
|
+
HEAD or a branch that never reached the base, and the scheduler pinned each such commit under
|
|
5016
|
+
\`refs/sm-stranded/${failedJob.slug}/\`. The finished work EXISTS; it just never landed. This is NOT
|
|
5017
|
+
evidence the work failed.
|
|
5018
|
+
|
|
5019
|
+
The job's worktree is gone, but the git object store is shared with every new worktree, so a
|
|
5020
|
+
\`git cherry-pick <sha>\` of a pinned commit works from any checkout of ${cwd}. List the pinned commits with:
|
|
5021
|
+
|
|
5022
|
+
git -C ${cwd} for-each-ref refs/sm-stranded/${failedJob.slug}/
|
|
5023
|
+
|
|
5024
|
+
If no pin exists, the failure log names the SHA instead (${failedLogPath}).
|
|
5025
|
+
|
|
5026
|
+
The fix-plan PRD you write for this MUST instruct its executor to, in order:
|
|
5027
|
+
1. Cherry-pick the pinned commits onto the base branch, oldest first.
|
|
5028
|
+
2. Run the original PRD's gate on the result.
|
|
5029
|
+
3. Then re-implement only the acceptance criteria that do not apply or are still missing after the cherry-pick — do not re-implement or re-plan the whole PRD from scratch.` : '';
|
|
5030
|
+
return `You are investigating a failed scheduled job in the session-manager queue. Your ONLY job is to write a fix-plan PRD file. Do NOT attempt the fix yourself.${deadFixChildNote}${abandonedBackgroundTaskNote}${runCommitNotLandedNote}
|
|
5001
5031
|
|
|
5002
5032
|
# Failed job
|
|
5003
5033
|
- Slug: ${failedJob.slug}
|
|
@@ -5159,7 +5189,7 @@ async function spawnInvestigation(failedJob, runDir, { deadChild = null } = {})
|
|
|
5159
5189
|
// Mechanical recovery (PRD 1130): same first-refusal treatment — a job
|
|
5160
5190
|
// eligible for a pure-git retry must never also get a cold-read fix-plan
|
|
5161
5191
|
// PRD authored in the same pass.
|
|
5162
|
-
if (reviewLadder.selectMechanicalRecoveryTarget(failedJob, failedJob.integrationFailureKind
|
|
5192
|
+
if (reviewLadder.selectMechanicalRecoveryTarget(failedJob, reviewLadder.isHeadSensitiveFailureKind(failedJob.integrationFailureKind) ? await gitTreeGuard.gitHead(failedJob.cwd || DEFAULT_PROJECT_CWD) : null)) {
|
|
5163
5193
|
console.log(`[scheduler] skip investigation: ${failedJob.slug} is mechanical-recovery eligible`);
|
|
5164
5194
|
return { deferred: false };
|
|
5165
5195
|
}
|
|
@@ -5654,6 +5684,16 @@ async function finalizeJobWorktree({ job, runId = null, runDir, worktree, guardC
|
|
|
5654
5684
|
let mergeAutoResolved = null;
|
|
5655
5685
|
let mergeAutoResolvedPaths = null;
|
|
5656
5686
|
let integratedSha = null;
|
|
5687
|
+
const worktreeHead = { action: 'unknown', finalHead: null, stranded: [] };
|
|
5688
|
+
const addStranded = (list) => {
|
|
5689
|
+
for (const c of Array.isArray(list) ? list : []) {
|
|
5690
|
+
if (c && c.sha && !worktreeHead.stranded.some((x) => x.sha === c.sha)) worktreeHead.stranded.push({ sha: c.sha, ref: c.ref || null });
|
|
5691
|
+
}
|
|
5692
|
+
};
|
|
5693
|
+
const pinUnlanded = async () => {
|
|
5694
|
+
if (typeof jw.pinUnlandedWorktreeCommits !== 'function') return;
|
|
5695
|
+
addStranded(await jw.pinUnlandedWorktreeCommits({ cwd: guardCwd, dir: worktree.dir, branch: worktree.branch, key: job.slug }));
|
|
5696
|
+
};
|
|
5657
5697
|
try {
|
|
5658
5698
|
worktreeLeftoverDirty = (await uncommitted(worktree.dir)) || [];
|
|
5659
5699
|
// Salvage the worktree's full diff (tracked + untracked) to the run
|
|
@@ -5669,11 +5709,32 @@ async function finalizeJobWorktree({ job, runId = null, runDir, worktree, guardC
|
|
|
5669
5709
|
console.log(`[scheduler] ${job.slug}: salvaged ${salvage.bytes} byte(s) of uncommitted worktree diff to ${salvagePath}`);
|
|
5670
5710
|
}
|
|
5671
5711
|
}
|
|
5712
|
+
// Carried base WIP the job left byte-identical to the base is not the job's
|
|
5713
|
+
// dirt. Filtered AFTER the salvage so the patch still holds the full diff.
|
|
5714
|
+
if (worktreeLeftoverDirty.length && Array.isArray(carriedPaths) && carriedPaths.length && typeof jw.unchangedCarriedPaths === 'function') {
|
|
5715
|
+
const same = new Set(await jw.unchangedCarriedPaths({ cwd: guardCwd, dir: worktree.dir, paths: carriedPaths }));
|
|
5716
|
+
if (same.size) worktreeLeftoverDirty = worktreeLeftoverDirty.filter((p) => !same.has(p));
|
|
5717
|
+
}
|
|
5718
|
+
// Where did HEAD end up? A commit on a detached HEAD must end on the job
|
|
5719
|
+
// branch (fast-forward) or be pinned (diverged) before the checkout goes.
|
|
5720
|
+
if (typeof jw.reconcileWorktreeHead === 'function') {
|
|
5721
|
+
const rec = await jw.reconcileWorktreeHead({ cwd: guardCwd, dir: worktree.dir, branch: worktree.branch, key: job.slug });
|
|
5722
|
+
worktreeHead.action = rec?.action || 'unknown';
|
|
5723
|
+
worktreeHead.finalHead = rec?.finalHead || null;
|
|
5724
|
+
if (rec?.pinnedRef && rec.finalHead) addStranded([{ sha: rec.finalHead, ref: rec.pinnedRef }]);
|
|
5725
|
+
}
|
|
5672
5726
|
if (await runCancelled(job.slug, runId)) {
|
|
5673
5727
|
// Cancelled mid-run: keep the commit on the job branch only.
|
|
5674
5728
|
appendAuditEvent('job_cancel_integration_skipped', { slug: job.slug, runId, branch: worktree.branch });
|
|
5729
|
+
await pinUnlanded();
|
|
5730
|
+
await jw.cleanupJobWorktree({ cwd: guardCwd, dir: worktree.dir, branch: worktree.branch, keepBranch: true });
|
|
5731
|
+
return { worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha: null, cancelled: true, worktreeHead };
|
|
5732
|
+
}
|
|
5733
|
+
if (worktreeHead.action === 'diverged') {
|
|
5734
|
+
console.error(`[scheduler] ${job.slug}: worktree HEAD diverged from ${worktree.branch} — not integrating; commit pinned`);
|
|
5735
|
+
await pinUnlanded();
|
|
5675
5736
|
await jw.cleanupJobWorktree({ cwd: guardCwd, dir: worktree.dir, branch: worktree.branch, keepBranch: true });
|
|
5676
|
-
return { worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha: null, cancelled:
|
|
5737
|
+
return { worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha: null, cancelled: false, worktreeHead };
|
|
5677
5738
|
}
|
|
5678
5739
|
const integration = await jw.integrateJobBranch({ cwd: guardCwd, branch: worktree.branch, slug: job.slug, carriedPaths, baseBranch: worktree.baseBranch });
|
|
5679
5740
|
if (integration.ok && integration.reason === 'carried-wip-only') {
|
|
@@ -5692,6 +5753,7 @@ async function finalizeJobWorktree({ job, runId = null, runDir, worktree, guardC
|
|
|
5692
5753
|
console.log(`[scheduler] ${job.slug}: merge auto-resolved (${integration.autoResolved}) — discarded ${mergeAutoResolvedPaths.length} identical working-tree duplicate(s): ${mergeAutoResolvedPaths.join(', ')}`);
|
|
5693
5754
|
}
|
|
5694
5755
|
}
|
|
5756
|
+
if (!integration.ok || !integration.integrated) await pinUnlanded();
|
|
5695
5757
|
await jw.cleanupJobWorktree({
|
|
5696
5758
|
cwd: guardCwd,
|
|
5697
5759
|
dir: worktree.dir,
|
|
@@ -5706,7 +5768,7 @@ async function finalizeJobWorktree({ job, runId = null, runDir, worktree, guardC
|
|
|
5706
5768
|
await jw.cleanupJobWorktree({ cwd: guardCwd, dir: worktree.dir, branch: worktree.branch, keepBranch: true });
|
|
5707
5769
|
} catch { /* already reported above */ }
|
|
5708
5770
|
}
|
|
5709
|
-
return { worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha, cancelled: false };
|
|
5771
|
+
return { worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha, cancelled: false, worktreeHead };
|
|
5710
5772
|
}
|
|
5711
5773
|
|
|
5712
5774
|
/**
|
|
@@ -6151,6 +6213,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6151
6213
|
let mergeAutoResolved = null;
|
|
6152
6214
|
let mergeAutoResolvedPaths = null;
|
|
6153
6215
|
let integratedSha = null;
|
|
6216
|
+
let worktreeHead = null;
|
|
6154
6217
|
// A job's uncommitted-work patch, whichever isolation mode produced it —
|
|
6155
6218
|
// set by EITHER branch below, never both (worktree.ok picks exactly one
|
|
6156
6219
|
// shape for the whole run). Named generically (not "worktree...") because
|
|
@@ -6186,7 +6249,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6186
6249
|
}, reviewInRun, worktree.ok ? worktree.setup : { ran: false, ok: false, reason: 'in-place', waitedMs: 0, ms: 0, commands: [] });
|
|
6187
6250
|
} finally {
|
|
6188
6251
|
if (worktree.ok) {
|
|
6189
|
-
({ worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha } =
|
|
6252
|
+
({ worktreeLeftoverDirty, salvagePatch, worktreeIntegrationFailure, worktreeIntegrationDetail, mergeAutoResolved, mergeAutoResolvedPaths, integratedSha, worktreeHead } =
|
|
6190
6253
|
await finalizeJobWorktree({ job, runId, runDir, worktree, guardCwd, carriedPaths }));
|
|
6191
6254
|
} else {
|
|
6192
6255
|
// In-place run (non-git cwd, cap reached, env-disabled, or a carry-over
|
|
@@ -6244,6 +6307,11 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6244
6307
|
...worktreeLeftoverDirty,
|
|
6245
6308
|
])]);
|
|
6246
6309
|
|
|
6310
|
+
// The dirt the commit guard judges: a worktree run is judged on its own
|
|
6311
|
+
// worktree's real dirt only (main-checkout changes belong to the owner or
|
|
6312
|
+
// a sibling); an in-place run on the baseline delta.
|
|
6313
|
+
const jobDirt = worktree.ok ? stripAppOwnedChurn(worktreeLeftoverDirty) : newlyDirtyAll;
|
|
6314
|
+
|
|
6247
6315
|
if (res.launchFailure) {
|
|
6248
6316
|
await handleLaunchFailure({ job, res, runId, runDir, launchKey, launchEnv, claudeVersion: claudeVersionNow });
|
|
6249
6317
|
return;
|
|
@@ -6461,16 +6529,22 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6461
6529
|
// verdict owns the needs_review reason and the pattern hit is demoted to an
|
|
6462
6530
|
// annotation, so a real "finish protocol incomplete" is distinguishable from
|
|
6463
6531
|
// transcript noise in the queue (feedback 2026-06-10 addendum).
|
|
6464
|
-
|
|
6532
|
+
// The skip decision is one pure function (gitTreeGuard.commitGuardSkipped):
|
|
6533
|
+
// re-fire, run_commit_not_landed, and completed-equivalent verdicts skip,
|
|
6534
|
+
// except a worktree pass_no_commit_* run that left newly dirty files.
|
|
6465
6535
|
const guardArtifactVerified = verifyResult?.verdict === 'pass_no_commit_artifact_verified';
|
|
6466
|
-
|
|
6467
|
-
|
|
6536
|
+
if (res.exitCode === 0 && !res.rateLimited && !gitTreeGuard.commitGuardSkipped({
|
|
6537
|
+
verifyResult,
|
|
6538
|
+
ranInWorktree: Boolean(worktree.ok),
|
|
6539
|
+
newlyDirty: jobDirt,
|
|
6540
|
+
landedCommit: jobLandedCommitThisRun,
|
|
6541
|
+
})) {
|
|
6468
6542
|
// afterGuardCwd === null means non-git cwd (or git errored) —
|
|
6469
6543
|
// best-effort skip, same as always; only a git-status result (even an
|
|
6470
6544
|
// empty one) counts as evidence for the zero-edit path. newlyDirtyAll
|
|
6471
6545
|
// was computed once, above, right after the try/finally.
|
|
6472
6546
|
if (afterGuardCwd !== null) {
|
|
6473
|
-
const newlyDirty =
|
|
6547
|
+
const newlyDirty = jobDirt || [];
|
|
6474
6548
|
const guardState = await readQueue().catch(() => ({ jobs: [] }));
|
|
6475
6549
|
const siblingRunning = (guardState.jobs || []).some(
|
|
6476
6550
|
(j) => j.slug !== job.slug && j.status === 'running' && (j.cwd || defaultCwd) === guardCwd,
|
|
@@ -6484,7 +6558,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6484
6558
|
siblingRunning,
|
|
6485
6559
|
ranInWorktree: worktree.ok,
|
|
6486
6560
|
jobSelfCommitted,
|
|
6487
|
-
legitimateNoOp:
|
|
6561
|
+
legitimateNoOp: false,
|
|
6488
6562
|
isFixPlanJob: resolveIsFixPlan(job.slug, job.isFixPlan),
|
|
6489
6563
|
artifactVerified: guardArtifactVerified,
|
|
6490
6564
|
verifyResult,
|
|
@@ -6521,6 +6595,16 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6521
6595
|
verifyResult = worktreeIntegrationVerdict({ failure: worktreeIntegrationFailure, detail: worktreeIntegrationDetail, slug: job.slug });
|
|
6522
6596
|
}
|
|
6523
6597
|
|
|
6598
|
+
// A commit that was pinned instead of landed (detached HEAD, diverged
|
|
6599
|
+
// branch, cancelled) is never a success, even over already_satisfied_on_main.
|
|
6600
|
+
if (res.exitCode === 0 && !res.rateLimited && !worktreeIntegrationFailure) {
|
|
6601
|
+
const stranded = gitTreeGuard.strandedCommitVerdict({ worktreeHead, landedCommit: jobLandedCommitThisRun });
|
|
6602
|
+
if (stranded) {
|
|
6603
|
+
verifyResult = stranded;
|
|
6604
|
+
console.log(`[scheduler] ${job.slug}: ${stranded.reason} → needs_review`);
|
|
6605
|
+
}
|
|
6606
|
+
}
|
|
6607
|
+
|
|
6524
6608
|
// Shared-tree stash guard (incident 2026-09-01): only meaningful for an
|
|
6525
6609
|
// IN-PLACE run — worktree.ok isolates the job's git state into its own
|
|
6526
6610
|
// checkout, so nothing there can leak into guardCwd. Best-effort and run
|
|
@@ -6632,7 +6716,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6632
6716
|
let terminalNotifySnapshot = null;
|
|
6633
6717
|
const newlyCompletedPrds = [];
|
|
6634
6718
|
// Base HEAD for the mechanical-recovery futility check — read here, never inside mutate() (no I/O).
|
|
6635
|
-
const finalizeHeadSha = worktreeIntegrationDetail && worktreeIntegrationDetail.failureKind
|
|
6719
|
+
const finalizeHeadSha = worktreeIntegrationDetail && reviewLadder.isHeadSensitiveFailureKind(worktreeIntegrationDetail.failureKind)
|
|
6636
6720
|
? await gitTreeGuard.gitHead(guardCwd) : null;
|
|
6637
6721
|
await mutate((s) => {
|
|
6638
6722
|
const i2 = s.jobs.findIndex((x) => x.slug === job.slug);
|
|
@@ -7065,6 +7149,9 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
7065
7149
|
launchEnvApplied: launchEnv ? Object.keys(launchEnv) : [],
|
|
7066
7150
|
filesChanged: Array.isArray(newlyDirtyAll) ? newlyDirtyAll.length : null,
|
|
7067
7151
|
landedCommit: jobLandedCommitThisRun ?? null,
|
|
7152
|
+
worktreeFinalHead: worktreeHead?.finalHead ?? null,
|
|
7153
|
+
worktreeHeadAction: worktreeHead?.action ?? null,
|
|
7154
|
+
strandedCommits: (worktreeHead?.stranded || []).map((c) => c.sha),
|
|
7068
7155
|
});
|
|
7069
7156
|
|
|
7070
7157
|
if (terminalNotifySnapshot) {
|
|
@@ -8153,13 +8240,44 @@ async function reapDeadRunningJobs() {
|
|
|
8153
8240
|
const rowCwd = row.cwd || state.config?.defaultCwd || DEFAULT_PROJECT_CWD;
|
|
8154
8241
|
if (!gitTreeGuard.isGitRepoSync(rowCwd)) continue;
|
|
8155
8242
|
const branch = jobWorktree.branchNameFor(d.slug);
|
|
8243
|
+
// Reconcile the worktree's real HEAD into the branch first: a detached
|
|
8244
|
+
// commit would otherwise leave the branch unmoved and read as integrated.
|
|
8245
|
+
let headReconcile = null;
|
|
8246
|
+
const wtDir = row.runtime?.cwd;
|
|
8247
|
+
if (typeof wtDir === 'string' && wtDir && wtDir !== rowCwd && fs.existsSync(wtDir)) {
|
|
8248
|
+
try {
|
|
8249
|
+
headReconcile = await jobWorktree.reconcileWorktreeHead({ cwd: rowCwd, dir: wtDir, branch, key: d.slug });
|
|
8250
|
+
} catch { headReconcile = null; }
|
|
8251
|
+
}
|
|
8156
8252
|
const integrated = await gitTreeGuard.isBranchAlreadyIntegrated(rowCwd, branch);
|
|
8157
8253
|
const headNow = await gitTreeGuard.gitHead(rowCwd);
|
|
8158
8254
|
const guardHeadBeforeVal = row.guardHeadBefore || null;
|
|
8159
8255
|
let landedCommit = null;
|
|
8160
8256
|
let notLandedInfo = null;
|
|
8161
8257
|
let effectiveSuccess = true;
|
|
8162
|
-
|
|
8258
|
+
// The boot sweep runs before this reaper and removes the worktree, pinning
|
|
8259
|
+
// its unique commits; the branch then sits at the fork point and reads as
|
|
8260
|
+
// integrated. Consult the job's own pins so that case parks instead.
|
|
8261
|
+
const startedMs = Date.parse(row.startedAt);
|
|
8262
|
+
let strandedPins = [];
|
|
8263
|
+
try {
|
|
8264
|
+
strandedPins = await jobWorktree.listStrandedPins({
|
|
8265
|
+
cwd: rowCwd, key: d.slug, sinceMs: Number.isFinite(startedMs) ? startedMs : 0,
|
|
8266
|
+
});
|
|
8267
|
+
} catch { strandedPins = []; }
|
|
8268
|
+
const pinVerdict = headReconcile?.action === 'diverged'
|
|
8269
|
+
? null
|
|
8270
|
+
: gitTreeGuard.strandedCommitVerdict({ worktreeHead: { stranded: strandedPins }, landedCommit: null });
|
|
8271
|
+
if (headReconcile?.action === 'diverged') {
|
|
8272
|
+
effectiveSuccess = false;
|
|
8273
|
+
notLandedInfo = {
|
|
8274
|
+
verdict: 'run_commit_not_landed',
|
|
8275
|
+
reason: `worktree HEAD ${headReconcile.finalHead} diverged from ${branch}; commit pinned at ${headReconcile.pinnedRef || 'no ref'} — never landed`,
|
|
8276
|
+
};
|
|
8277
|
+
} else if (pinVerdict) {
|
|
8278
|
+
effectiveSuccess = false;
|
|
8279
|
+
notLandedInfo = { verdict: pinVerdict.verdict, reason: pinVerdict.reason };
|
|
8280
|
+
} else if (integrated === null) {
|
|
8163
8281
|
// No sm-job/<slug> branch — an in-place run (or worktree isolation
|
|
8164
8282
|
// disabled). Prove landing via the exact same HEAD-advance evidence
|
|
8165
8283
|
// the live commit-guard already uses — reused, not re-derived.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- PRD_AUTHORING.md
|
|
1
|
+
<!-- PRD_AUTHORING.md v16 -->
|
|
2
2
|
# PRD Authoring Guide — Scheduler Safety Rules
|
|
3
3
|
|
|
4
4
|
Rule: every PRD you queue follows the rules below.
|
|
@@ -81,6 +81,9 @@ Artifact-only PRDs (`deliverable: artifact` + `artifactPaths: [...]`) — use th
|
|
|
81
81
|
3. The tree must still end clean. A declared artifact excuses the missing commit, not a stray tracked edit.
|
|
82
82
|
4. Both fields are required together — passing one without the other is refused.
|
|
83
83
|
|
|
84
|
+
Rule: a PRD whose truthful outcome is no commit (publish, live migration, probe) must declare `deliverable: artifact` with `artifactPaths` naming a git-excluded output it writes during the run, such as a built file in a gitignored folder. A PRD that lands no commit and makes no declaration parks in `needs_review`.
|
|
85
|
+
Why: burrow PRD 1897 ended completed with its commit dropped, because a tracked path counted as proof the work had shipped.
|
|
86
|
+
|
|
84
87
|
Why: PRD `816-prepare-157-copy-citation-extras-patch` wrote its patch into a git-excluded folder with no way to declare that, and parked `needs_review` twice.
|
|
85
88
|
|
|
86
89
|
---
|
|
@@ -204,7 +207,8 @@ Why: those verdicts mean the run ended without a clean verdict line, not that th
|
|
|
204
207
|
|
|
205
208
|
Rule: a park caused by a DIFFERENT actor already finishing the same objective (a sibling PRD, a human) does not self-heal this way. Why: the job has no landed commit of its own. Confirm in the tree that the work is really done, then call `scheduler_archive_prd` with the slug. Archiving marks the job completed and frees the PRDs that depend on it. Never hand-edit `queue.json`: the scheduler and the watchdog both write it. Archiving clears a stale label; it does not fix a real bug.
|
|
206
209
|
|
|
207
|
-
|
|
210
|
+
Rule: a no-commit PASS (`pass_no_commit`) completes only with a prior landed commit of the same slug, or when every path in the Files list landed on the base branch since the PRD was written. Otherwise it parks.
|
|
211
|
+
Why: a tracked path existing is not proof this PRD's work shipped.
|
|
208
212
|
|
|
209
213
|
---
|
|
210
214
|
|
package/src/main/webRemote.cjs
CHANGED
|
@@ -844,6 +844,12 @@ async function handleMessage(raw, device) {
|
|
|
844
844
|
const live = ((await loadConfig()).devices || []).find((d) => d.deviceId === device.deviceId) || device;
|
|
845
845
|
if (isPinnedPeerKey(live, browserPubKey)) {
|
|
846
846
|
client.e2e = makeState('authenticated', sessionKey, null);
|
|
847
|
+
// ORDER IS A CONTRACT: the boxed event:remote:ready (sent inside
|
|
848
|
+
// finalizeE2eAuthenticated) deliberately goes out BEFORE the plaintext e2e:ready
|
|
849
|
+
// below. web/remote-app/src/ws.ts holds boxes that arrive before e2e:ready and
|
|
850
|
+
// decides on sas:pending only after draining them, so the early remote:ready
|
|
851
|
+
// skips the SAS prompt. Reordering brings back a flash of "confirm the 6-digit
|
|
852
|
+
// code". Pinned by src/main/__tests__/web-remote-pinned-ready-order.test.cjs.
|
|
847
853
|
finalizeE2eAuthenticated('E2E session auto-authenticated — pinned browser key matched', client);
|
|
848
854
|
respond(id, undefined, 'e2e:ready', client);
|
|
849
855
|
return;
|
|
@@ -1310,6 +1316,7 @@ function getDispatchMap() {
|
|
|
1310
1316
|
const personas = await agentLibrary.listPersonas();
|
|
1311
1317
|
if (!personas.some((a) => a.name === parsed.agentName)) throw new Error('unknown agent');
|
|
1312
1318
|
let prompt = parsed.prompt;
|
|
1319
|
+
let macroId;
|
|
1313
1320
|
if (parsed.macroId) {
|
|
1314
1321
|
const macroLibrary = require('./lib/persona-macro/macroLibrary.cjs');
|
|
1315
1322
|
const macros = await macroLibrary.listMacros();
|
|
@@ -1318,6 +1325,7 @@ function getDispatchMap() {
|
|
|
1318
1325
|
const result = macroLibrary.renderMacroPrompt(parsed.prompt, macro.inputs, parsed.inputs ?? {});
|
|
1319
1326
|
if (!result.ok) throw new Error(result.error);
|
|
1320
1327
|
prompt = result.prompt;
|
|
1328
|
+
macroId = macro.id;
|
|
1321
1329
|
}
|
|
1322
1330
|
chatRunner.requestExternalNewSession({
|
|
1323
1331
|
cwd: parsed.cwd,
|
|
@@ -1325,6 +1333,7 @@ function getDispatchMap() {
|
|
|
1325
1333
|
tag: parsed.tag,
|
|
1326
1334
|
title: parsed.title,
|
|
1327
1335
|
prompt,
|
|
1336
|
+
...(macroId ? { macroId } : {}),
|
|
1328
1337
|
});
|
|
1329
1338
|
return { ok: true };
|
|
1330
1339
|
},
|
package/src/preload/api.d.ts
CHANGED
|
@@ -303,6 +303,8 @@ export interface Macro {
|
|
|
303
303
|
createdAt: string;
|
|
304
304
|
updatedAt: string;
|
|
305
305
|
inputs?: MacroInput[];
|
|
306
|
+
/** Projects ('*' or absolute cwds) this macro's session may start work in without approval. */
|
|
307
|
+
autoStartTargets?: string[];
|
|
306
308
|
}
|
|
307
309
|
|
|
308
310
|
/** Omit `id` to create; set it to update an existing macro. */
|
|
@@ -316,6 +318,8 @@ export interface MacroSaveInput {
|
|
|
316
318
|
surface?: 'sessions' | 'project-home';
|
|
317
319
|
/** Omitted keeps the stored list on update; `[]` clears it. */
|
|
318
320
|
inputs?: MacroInput[];
|
|
321
|
+
/** Same omit/clear semantics as `inputs`. */
|
|
322
|
+
autoStartTargets?: string[];
|
|
319
323
|
}
|
|
320
324
|
|
|
321
325
|
/** One global `~/.claude/agents/<name>.md` persona, per the Agent Library nav page. */
|
|
@@ -2265,7 +2269,7 @@ export interface SessionManagerAPI {
|
|
|
2265
2269
|
reportExternalSendResult: (result: ChatExternalSendResult) => Promise<void>;
|
|
2266
2270
|
/** Fires when a paired phone asks main to start a new Session (payload pre-validated in main). */
|
|
2267
2271
|
onExternalNewSession: (
|
|
2268
|
-
handler: (e: { cwd: string; agentName: string; tag: AgentPersonaTag; title: string; prompt: string }) => void,
|
|
2272
|
+
handler: (e: { cwd: string; agentName: string; tag: AgentPersonaTag; title: string; prompt: string; macroId?: string }) => void,
|
|
2269
2273
|
) => () => void;
|
|
2270
2274
|
/** Classify a queued PromptTicket's text as 'inline' (run through
|
|
2271
2275
|
* chatRunner) or 'develop' (dispatch to /develop for PRD decomposition).
|
|
@@ -2358,6 +2362,8 @@ export interface PromptSessionsCreateEpicPayload {
|
|
|
2358
2362
|
prdSlug?: string;
|
|
2359
2363
|
runId?: string;
|
|
2360
2364
|
sourceTabId?: string;
|
|
2365
|
+
/** The macro that launched this Epic. */
|
|
2366
|
+
macroId?: string;
|
|
2361
2367
|
};
|
|
2362
2368
|
/** Full first-prompt body + its labeled sections (epicIntake.ts's
|
|
2363
2369
|
* composeEpicIntake) — carried alongside goalText so the Epic's first
|
|
File without changes
|