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 a description line in a legacy TASKS.md from minting a runnable task (#7300)

[._.]/ Adam Eivya83dba2668dd
diff --git a/server/lib/taskParser.js b/server/lib/taskParser.js
index e11dba670c..a2c2f76cd5 100644
--- a/server/lib/taskParser.js
+++ b/server/lib/taskParser.js
@@ -139,7 +139,10 @@ export function toRepresentableTask(task) {
* Recovery accepts ANY non-pipe priority field, because the boundary that wrote
* these rows accepted any string — `VERY HIGH`, `123` and `URGENT!` were all
* reachable through the route before this issue, and a narrower pattern would
- * leave exactly those rows to be deleted by the next write.
+ * leave exactly those rows to be deleted by the next write. The cost of that
+ * width is that a `- [ ] #id | text | text` SENTENCE inside a legacy multi-line
+ * description also matches, so no recovered row is ever auto-approved (#7300) —
+ * see the approval flags in `matchTaskLine`.
*/
const TASK_LINE_PATTERNS = [
{ withFlag: true, re: /^-\s*\[([ x~!?])\]\s*#([\w-]+)\s*\|\s*(CRITICAL|HIGH|MEDIUM|LOW)\s*\|\s*(AUTO|APPROVAL)\s*\|\s*(.+)$/i },
@@ -170,21 +173,29 @@ function matchTaskLine(line) {
status: STATUS_MAP[statusKey] ?? statusKey,
priority: priority.trim().toUpperCase(),
priorityValue: PRIORITY_VALUES[priority.trim().toUpperCase()] || 2,
- // A recovered row is an ambiguous split — the priority field could itself
- // have held a pipe ('UR|GENT', 'UR|AUTO' were both reachable through the old
- // free-string boundary), so which segment was the approval flag is a guess.
- // Recovery must never make a row MORE permissive than it was, so a recovered
- // INTERNAL task lands in the approval queue rather than the dequeue: those
- // are the rows where the flag gates an agent spawn, and the flag is written
- // back (includeApprovalFlags), so the hold survives the next read.
+ // NO recovered row is auto-approved (#7300). The recovery patterns accept any
+ // non-pipe priority field, which is right for a row the old free-string
+ // boundary really wrote — but it also matches a `- [ ] #id | text | text`
+ // SENTENCE sitting at column 0 inside a legacy multi-line description body,
+ // and a match there mints a task nobody wrote. Handing that to the dequeue is
+ // an agent spawn from prose, so a recovered row is preserved for a human and
+ // withheld from `getAutoApprovedTasks` regardless of its id. This is the same
+ // hold the unknown-checkbox path takes, from the other side of the row.
//
- // A user task carries no flag in the format at all — every one is
- // auto-approved by construction — so holding one here would be a claim the
- // next write erases. Its row is restored to the ordinary user queue, which
- // is exactly what it was before the corruption. A strict match on either
- // kind keeps its exact prior semantics.
+ // An INTERNAL recovered row additionally lands in the approval queue, because
+ // its split is ambiguous in a second way — the priority field could itself have
+ // held a pipe ('UR|GENT', 'UR|AUTO' were both reachable), so which segment was
+ // the approval flag is a guess, and that flag gates an agent spawn.
+ //
+ // A user-prefixed row claims no approval: the user file writes no flags, so the
+ // claim would be erased by the next write and only strand the row in the
+ // meantime (`approveTask` reads the internal file, and TaskItem hides Approve
+ // for a user task). Its `autoApproved: false` is what the internal file's
+ // write turns into an APPROVAL flag, so the hold survives there and evaporates
+ // in the user file — which is exactly where it is not needed, since user tasks
+ // are never dequeued autonomously. A strict match on either kind is untouched.
approvalRequired: (recovery && isInternalTaskId(taskId)) || approvalFlag === 'APPROVAL',
- autoApproved: !(recovery && isInternalTaskId(taskId)) && (withFlag ? approvalFlag === 'AUTO' : true),
+ autoApproved: !recovery && (withFlag ? approvalFlag === 'AUTO' : true),
description: description.trim(),
metadata: {}
};
@@ -434,8 +445,14 @@ export function generateTasksMarkdown(tasks, includeApprovalFlags = false) {
for (const task of sortByPriority(sectionTasks)) {
const checkbox = statusToCheckbox[task.status];
- const approvalFlag = includeApprovalFlags && (task.approvalRequired || task.autoApproved !== undefined)
- ? ` | ${task.approvalRequired ? 'APPROVAL' : 'AUTO'}`
+ // `autoApproved === false` writes APPROVAL, not AUTO (#7300). A task that says
+ // it is not auto-approved must not be healed into a row the next read dequeues:
+ // APPROVAL is the only flag this format has that survives the round trip as a
+ // hold. An `undefined` autoApproved is NOT that claim — it stays on the old
+ // path so a task that never carried the field keeps its flagless row.
+ const heldBack = task.approvalRequired || task.autoApproved === false;
+ const approvalFlag = includeApprovalFlags && (heldBack || task.autoApproved !== undefined)
+ ? ` | ${heldBack ? 'APPROVAL' : 'AUTO'}`
: '';
lines.push(`- ${checkbox} #${task.id} | ${task.priority}${approvalFlag} | ${flattenDescription(task)}`);
diff --git a/server/lib/taskParser.test.js b/server/lib/taskParser.test.js
index 676f46c3ed..d2abd1e0d9 100644
--- a/server/lib/taskParser.test.js
+++ b/server/lib/taskParser.test.js
@@ -942,17 +942,65 @@ describe('unrepresentable status/priority never drops a task (#7239)', () => {
expect(getAutoApprovedTasks(reread)).toEqual([]);
});
- it('restores a recovered USER row to the ordinary queue', () => {
- // A user task carries no approval flag in the format at all — every one is
- // auto-approved by construction — so holding one would be a claim the next
- // write erases. The row goes back to being exactly what it was.
+ it('withholds a recovered USER row from the dequeue without claiming approval', () => {
+ // The payload survives, but the row is not handed to the spawn engine: the
+ // recovery patterns cannot tell a genuine legacy row from a sentence inside a
+ // legacy description body (#7300). It claims no APPROVAL, because the user file
+ // writes no flags — that claim would only strand the row until the next write.
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
const [recovered] = parseTasksMarkdown('# Tasks\n\n## Pending\n- [ ] #task-C | URGENT | plain user row\n - prompt: payload\n');
warn.mockRestore();
- expect(recovered.autoApproved).toBe(true);
+ expect(recovered.autoApproved).toBe(false);
expect(recovered.approvalRequired).toBe(false);
+ expect(getAutoApprovedTasks([recovered])).toEqual([]);
expect(recovered.metadata.prompt).toBe('payload');
+
+ // The user file writes no approval flags, so the healed row is an ordinary
+ // strict row again — exactly what it was before the corruption.
+ const reread = parseTasksMarkdown(generateTasksMarkdown([recovered], false));
+ expect(reread[0].autoApproved).toBe(true);
+ expect(reread[0].approvalRequired).toBe(false);
+ expect(reread[0].priority).toBe('MEDIUM');
+ });
+
+ it('does not mint a runnable task from a task-shaped line inside a description body', () => {
+ // The reported defect: a pre-#7240 file can hold a multi-line description whose
+ // continuation sits at column 0. 'note' is not an internal id, so before #7300
+ // the widened priority field made this sentence an auto-approved pending task
+ // the spawn engine would run.
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ const parsed = parseTasksMarkdown([
+ '# Tasks', '', '## Pending',
+ '- [ ] #sys-9 | HIGH | AUTO | Real internal task',
+ ' - prompt: real payload',
+ '- [ ] #note | see this | do the thing',
+ ''
+ ].join('\n'));
+ warn.mockRestore();
+
+ expect(getAutoApprovedTasks(parsed).map(t => t.id)).toEqual(['sys-9']);
+
+ const phantom = parsed.find(t => t.id === 'task-note');
+ expect(phantom.status).toBe('pending');
+ expect(phantom.autoApproved).toBe(false);
+
+ // The internal file DOES write approval flags, so healing the file must not
+ // release the phantom into the dequeue on the next read.
+ const reread = parseTasksMarkdown(generateTasksMarkdown(parsed, true));
+ expect(getAutoApprovedTasks(reread).map(t => t.id)).toEqual(['sys-9']);
+ expect(reread.find(t => t.id === 'task-note').approvalRequired).toBe(true);
+ });
+
+ it('keeps a flagless internal task flagless when it never carried autoApproved', () => {
+ // Only an explicit `autoApproved: false` is a hold. A task that never carried
+ // the field (investigation producers construct several) must keep its flagless
+ // row, or every write would newly claim APPROVAL on it.
+ const markdown = generateTasksMarkdown([
+ { id: 'sys-8', status: 'pending', priority: 'HIGH', priorityValue: 3, description: 'no flags', metadata: {} }
+ ], true);
+ expect(markdown).toContain('- [ ] #sys-8 | HIGH | no flags');
+ expect(parseTasksMarkdown(markdown)[0].autoApproved).toBe(true);
});
it("leaves a STRICT row's approval semantics exactly as they were", () => {