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

fix: scope do-release's branch-reconcile to the released app and avoid queue deadlock

[._.]/ Adam Eivy8b5fceab53cf
diff --git a/server/services/cosTaskPreStepBlocks.js b/server/services/cosTaskPreStepBlocks.js
index e1ff510c2a..78cf3da87f 100644
--- a/server/services/cosTaskPreStepBlocks.js
+++ b/server/services/cosTaskPreStepBlocks.js
@@ -199,11 +199,14 @@ function resolveReleaseOptionsBlock(metadata = {}) {
/**
* Render the operator's release options into a do-release prompt. A customized
* stored prompt that dropped `{releaseOptions}` still gets the block PREPENDED,
- * so turning an option off is never a silent no-op on that install.
+ * so turning an option off is never a silent no-op on that install. Also
+ * resolves `{appId}` (the branch-reconcile trigger target) from the task's
+ * managed app — empty on the install-wide lane, which targets PortOS itself.
*/
export function applyReleaseOptions(promptTemplate, taskType, metadata) {
- const prompt = typeof promptTemplate === 'string' ? promptTemplate : '';
- if (taskType !== 'do-release') return prompt;
+ if (taskType !== 'do-release') return typeof promptTemplate === 'string' ? promptTemplate : '';
+ const prompt = (typeof promptTemplate === 'string' ? promptTemplate : '')
+ .replace(/\{appId\}/g, () => metadata?.app ?? '');
const block = resolveReleaseOptionsBlock(metadata);
if (prompt.includes('{releaseOptions}')) return prompt.replace(/\{releaseOptions\}/g, () => block);
return `## Release options for this run\n\n${block}\n\n---\n\n${prompt}`;
diff --git a/server/services/cosTaskPreStepBlocks.test.js b/server/services/cosTaskPreStepBlocks.test.js
index 5b9f9d0151..db8f100c44 100644
--- a/server/services/cosTaskPreStepBlocks.test.js
+++ b/server/services/cosTaskPreStepBlocks.test.js
@@ -399,6 +399,11 @@ describe('applyReleaseOptions — the do-release {releaseOptions} block', () =>
expect(out.endsWith('my custom release prompt')).toBe(true);
});
+ it('targets the branch-reconcile trigger at the released app, or PortOS on the global lane', () => {
+ expect(applyReleaseOptions('{"appId":"{appId}"}', 'do-release', { app: 'app-a' })).toContain('{"appId":"app-a"}');
+ expect(applyReleaseOptions('{"appId":"{appId}"}', 'do-release', {})).toContain('{"appId":""}');
+ });
+
it('leaves every other task type untouched', () => {
expect(applyReleaseOptions('{releaseOptions}', 'branch-reconcile', {})).toBe('{releaseOptions}');
});
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index 1b9050fe97..790708a0f2 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -678,12 +678,15 @@ describe('taskPromptDefaults integrity snapshot', () => {
// v15: in-flight work and dependency PRs land first, respecting live owners.
expect(current).toContain('Finish in-flight work first');
expect(current).toContain('/api/cos/agents?active=1');
- expect(current).toContain('"taskType":"branch-reconcile"');
+ // Scoped to the app being released, never the install's other repos.
+ expect(current).toContain('"taskType":"branch-reconcile","appId":"{appId}"');
expect(current).toContain('Merge dependency updates');
// v15: a blocker that outlasts the fix loop goes to a sub-agent; filing an
// issue and leaving the release PR open is no longer an exit (v14 stopped
// at its 10-commit bound with the release PR open).
expect(current).toContain('Delegate instead of giving up');
+ // Waiting on a queued task can deadlock on the agent slot this run holds.
+ expect(current).toContain('Do not wait for the queued task');
expect(current).toContain('Filing an issue and leaving the release PR open is NOT a resolution');
expect(current).not.toContain('Bound the loop');
expect(current).toContain('Local-only flake');
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index a0d52c824f..d158115bb2 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -23,7 +23,7 @@
"data-integrity": "5fcc4f5044101e89da5bbf4890c11a1c",
"data-safety": "eb97988dfc16d4c655f1834acc91d665",
"dependency-updates": "2d94021c979a86a349e125f5c15665d8",
- "do-release": "18db3caa14eda4892ad23cfdc6db83e2",
+ "do-release": "774a3f8872513b11843694791206bcd0",
"do-replan": "35660eb7b43e4259a6a9253ed288a1db",
"documentation": "a30e3bfba8cd13369ccaf806a3534a79",
"error-handling": "137b371f38398042c0a2c7e2279c92ce",
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index 6af263aa61..ccf407e6ca 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -3433,7 +3433,7 @@ Everything else is yours to finish, one item at a time:
- **Ready PRs** (green CI, no unresolved review): merge them with the repository's merge method.
- **Red or conflicted PRs**: rebase onto \`<TARGET_BRANCH>\`, fix the failure or conflict (keeping both sides' intent), push, wait for CI, then merge.
- **Stale or superseded PRs** whose change already landed on \`<TARGET_BRANCH>\`: close them with a comment naming the commit that superseded them.
-- **Lingering local branches and worktrees**: when this install has the PortOS \`branch-reconcile\` task, trigger it and wait for its agent to finish before continuing: \`curl -s -X POST -H "Authorization: Bearer \${PORTOS_API_TOKEN:-}" -H 'Content-Type: application/json' -d '{"taskType":"branch-reconcile"}' ${PORTOS_API_URL}/api/cos/schedule/trigger\`, then watch \`${PORTOS_API_URL}/api/cos/agents?active=1\`. If that is unavailable, do the same work yourself: delete branches already merged, ship coherent unmerged work as a PR, and report anything ambiguous.
+- **Lingering local branches and worktrees**: when this install has the PortOS \`branch-reconcile\` task, trigger it and wait for its agent to finish before continuing: \`curl -s -X POST -H "Authorization: Bearer \${PORTOS_API_TOKEN:-}" -H 'Content-Type: application/json' -d '{"taskType":"branch-reconcile","appId":"{appId}"}' ${PORTOS_API_URL}/api/cos/schedule/trigger\` (drop the \`appId\` field when it is empty — that targets PortOS itself; never point it at a different app than this release), then watch \`${PORTOS_API_URL}/api/cos/agents?active=1\`. If that is unavailable, do the same work yourself: delete branches already merged, ship coherent unmerged work as a PR, and report anything ambiguous.
Bound this step to the work that can land now. A large in-flight feature that is far from done does not hold the release — note it in the report and move on.
@@ -3490,7 +3490,9 @@ A failing test suite, a red CI run, or a bug you discover while releasing does N
Apply the same loop to a red CI run on the release PR, driving it from the failing job's logs (for example \`gh pr checks <PR_NUM>\` to find the run, then \`gh run view <RUN_ID> --log-failed\`). A CI failure that does not reproduce locally is still yours to diagnose — look for platform differences (OS, runtime version, installed dependencies) and for state the local run has that CI does not.
-**Delegate instead of giving up.** If a blocker survives three distinct fix attempts, or it is too large to fix alongside running the release, hand it to a sub-agent (your Agent/Task tool) with a self-contained brief: the failing command, the error, what you already tried, the branch to push to, and the verification to run. Wait for it, review what it did, and resume. If you have no sub-agent tool, queue the work as a PortOS task (\`POST ${PORTOS_API_URL}/api/cos/tasks\` with the same bearer header), wait for it to finish, then continue. Stop only when a fresh sub-agent has also failed on the same blocker; report exactly what was tried.
+**Delegate instead of giving up.** If a blocker survives three distinct fix attempts, or it is too large to fix alongside running the release, hand it to a sub-agent (your Agent/Task tool) with a self-contained brief: the failing command, the error, what you already tried, the branch to push to, and the verification to run. Wait for it, review what it did, and resume. Stop only when a fresh sub-agent has also failed on the same blocker; report exactly what was tried.
+
+If you have no sub-agent tool, keep working the blocker in this session. When it is still beyond this run, queue it as a PortOS task (\`POST ${PORTOS_API_URL}/api/cos/tasks\` with the same bearer header and the brief above) and then END this run with the release PR left open, naming the queued task in the report. Do not wait for the queued task: this run may be holding the only agent slot the task needs, so waiting deadlocks. The next do-release run resumes the open release PR in Step 1.
## Decisions