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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): manage worktreeChangesExpected so a taskMetadata:null clear can't drop it
[._.]/ Adam Eivyb2b24cf46c9f
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex 21947da21a..65b246b1ef 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -422,10 +422,20 @@ export const MANAGED_AGENT_OPTIONS = {// AND could trip cleanupAgentWorktree's auto-merge), and branch-cleanup's worktree// would hold refs it is trying to delete. Locking both off also keeps the// finalize-time PR-claim check from scoring a completed run `pr-missing`.- 'branch-reconcile': ['useWorktree', 'openPR'],- 'branch-cleanup': ['useWorktree', 'openPR'],- 'issue-reconcile': ['useWorktree', 'openPR'],- 'jira-status-report': ['useWorktree', 'openPR'],+ //+ // `worktreeChangesExpected` is managed for these four as well — the one type-keyed+ // exception to it being a free per-app override. A clean tree is definitionally the+ // success shape for a branch deletion or a posted report, so setting it back to+ // `true` can only make successful runs fail; it is exactly as non-negotiable here as+ // the other two. Managing it is also what carries it through an explicit+ // `taskMetadata: null` clear — loadSchedule preserves that null (skipping the+ // defaults deep-merge), and enforceManagedAgentOptions rebuilds only the MANAGED+ // fields, so an unmanaged `worktreeChangesExpected` would silently go absent and the+ // TUI idle-complete gate would fail the run as `idle-no-changes`.+ ...Object.fromEntries(+ ['branch-reconcile', 'branch-cleanup', 'issue-reconcile', 'jira-status-report']+ .map((t) => [t, ['useWorktree', 'openPR', 'worktreeChangesExpected']])+ ),// claim-issue's prompt creates its own claim/issue-<num> worktree (same// rationale as plan-task), so CoS must not pre-create one or open the PR.'claim-issue': ['useWorktree', 'openPR'],diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex 73a94e11a9..dea738210f 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -1122,7 +1122,29 @@ describe('taskSchedule', () => {expect(meta.useWorktree).toBe(false)expect(meta.worktreeChangesExpected).toBe(false)// Locked, so a per-app override can't re-attach what the defaults cleared.- expect(MANAGED_AGENT_OPTIONS[taskType]).toEqual(['useWorktree', 'openPR'])+ // worktreeChangesExpected is managed too — see MANAGED_AGENT_OPTIONS.+ expect(MANAGED_AGENT_OPTIONS[taskType]).toEqual(['useWorktree', 'openPR', 'worktreeChangesExpected'])+ }+ )++ // An explicit `taskMetadata: null` (accepted by PUT /api/cos/schedule as "clear+ // it") makes loadSchedule SKIP the defaults deep-merge, so enforceManagedAgentOptions+ // is the only thing that rebuilds the bag — and it rebuilds MANAGED fields only.+ // Before worktreeChangesExpected was managed, it went absent here and a successful+ // clean-tree run was scored `idle-no-changes` all over again.+ it.each([...NON_COMMITTING_COORDINATOR_TASK_TYPES])(+ '%s keeps the full posture when stored taskMetadata was cleared to null',+ async (taskType) => {+ mockSchedule({+ tasks: {+ [taskType]: { type: 'cron', enabled: true, providerId: null, model: null, prompt: null, taskMetadata: null }+ }+ })++ const meta = (await loadSchedule()).tasks[taskType].taskMetadata+ expect(meta.useWorktree).toBe(false)+ expect(meta.openPR).toBe(false)+ expect(meta.worktreeChangesExpected).toBe(false)})