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: address review — pass a legacy ownsPrWorkflow boolean through untouched (#6869)

[._.]/ Adam Eivy490f3fe588a3
diff --git a/server/lib/agentRegistrationRecord.js b/server/lib/agentRegistrationRecord.js
index 3ca8dfd40a..43fe744057 100644
--- a/server/lib/agentRegistrationRecord.js
+++ b/server/lib/agentRegistrationRecord.js
@@ -128,6 +128,11 @@ export function buildAgentRegistration({
// case; `agent-inline` is the codex/grok/agy harness handed the plain
// `git`/`gh` steps, and it is the only value that owes the #5876 merge-gate
// check, because it is the only prompt carrying a Merge Gate section.
+ //
+ // Three values rather than the boolean because that is what separates them:
+ // the retired `false` conflated "a `/do:pr` run" with "a run PortOS owns",
+ // which is why `resolvePrOpenedBy` can only pass a legacy record's boolean
+ // straight through instead of correcting it.
prOpenedBy,
model: selectedModel,
// The reasoning-effort override this run was dispatched with (null when the
diff --git a/server/lib/slashdoInvocation.js b/server/lib/slashdoInvocation.js
index fcf52e359b..5e65dca1b7 100644
--- a/server/lib/slashdoInvocation.js
+++ b/server/lib/slashdoInvocation.js
@@ -551,18 +551,26 @@ const PR_OPENED_BY_VALUES = new Set(Object.values(PR_OPENED_BY));
*
* 1. `metadata.prOpenedBy` (this version) is authoritative: cleanup must act on
* what the prompt actually said, not on a fresh derivation that could
- * disagree with it.
- * 2. A slashdo-capable host resolves to `agent-slashdo` whatever else the record
- * carries. This is where #6869 lands on legacy data: the #3733 boolean
- * `metadata.ownsPrWorkflow` answered "did the prompt render the INLINE PR
- * section", which is `false` for exactly the hosts that run `/do:pr` — so
- * reading that boolean at face value for a Claude record is what had cleanup
- * re-push and re-create a PR the agent had already opened.
- * 3. Otherwise the #3733 boolean, when the record has one: a slashdo-free
- * harness stamped `true` really was told to run `gh pr create` itself.
- * 4. Otherwise `portos` — which for a record written before #3733 (no key at
- * all) is the same answer the old `canTypeSlashCommands` fallback gave, since
- * rule 2 already claimed every slashdo-capable one.
+ * disagree with it. An unrecognized value — a record from a NEWER install —
+ * is not trusted as an agent; it falls through to the legacy rules below.
+ * 2. The #3733 boolean `metadata.ownsPrWorkflow`, when the record has one,
+ * still answers exactly as it did: `true` → `agent-inline` (a slashdo-free
+ * harness told to run `gh pr create` itself), `false` → `portos`.
+ * 3. Otherwise `portos`, or `agent-slashdo` for a slashdo-capable host — the
+ * pre-#3733 fallback, unchanged, since those runs were prompted by the old
+ * builder whose gate was exactly `canTypeSlashCommands`.
+ *
+ * **The #6869 fix is deliberately NOT retro-applied to rule 2**, even though
+ * that boolean is the one this issue retires. It answered "did the prompt
+ * render the INLINE PR section", so `false` is ambiguous on a slashdo-capable
+ * host between the defect (a `/do:pr` run PortOS then re-created a PR for) and
+ * a correct exclusion (a read-only / no-code-output / discard-worktree /
+ * leave-open run PortOS really does own). Overriding it to `agent-slashdo`
+ * would fix the first and break the second — and only the task, which this
+ * leaf deliberately does not see, tells them apart. Every legacy record
+ * therefore resolves exactly as it did before this change; only records
+ * stamped by `promptOpensOwnPr` (rule 1) carry the corrected answer, and an
+ * in-flight legacy run is over within one upgrade window.
*
* @param {Object} opts
* @param {string|undefined} opts.persistedPrOpenedBy - `metadata.prOpenedBy`
@@ -581,9 +589,12 @@ export function resolvePrOpenedBy({
leanMode = false,
}) {
if (PR_OPENED_BY_VALUES.has(persistedPrOpenedBy)) return persistedPrOpenedBy;
- if (canTypeSlashCommands({ providerId, providerCommand, leanMode })) return PR_OPENED_BY.AGENT_SLASHDO;
- if (persistedOwnsPrWorkflow === true) return PR_OPENED_BY.AGENT_INLINE;
- return PR_OPENED_BY.PORTOS;
+ if (typeof persistedOwnsPrWorkflow === 'boolean') {
+ return persistedOwnsPrWorkflow ? PR_OPENED_BY.AGENT_INLINE : PR_OPENED_BY.PORTOS;
+ }
+ return canTypeSlashCommands({ providerId, providerCommand, leanMode })
+ ? PR_OPENED_BY.AGENT_SLASHDO
+ : PR_OPENED_BY.PORTOS;
}
/**
diff --git a/server/lib/slashdoInvocation.test.js b/server/lib/slashdoInvocation.test.js
index 9aae2ae41e..059a08f125 100644
--- a/server/lib/slashdoInvocation.test.js
+++ b/server/lib/slashdoInvocation.test.js
@@ -203,29 +203,28 @@ describe('resolvePrOpenedBy', () => {
// not be handed to `!== PORTOS` as if it named an agent.
expect(resolveFor({ persistedPrOpenedBy: 'agent-something-new' })).toBe(PR_OPENED_BY.PORTOS);
expect(resolveFor({ persistedPrOpenedBy: null, persistedOwnsPrWorkflow: true })).toBe(PR_OPENED_BY.AGENT_INLINE);
+ expect(resolveFor({ persistedPrOpenedBy: 'agent-something-new', providerId: 'claude-code', providerCommand: 'claude' }))
+ .toBe(PR_OPENED_BY.AGENT_SLASHDO);
});
// Legacy shapes. Other installs run older versions, so records carrying the
- // #3733 boolean — or nothing at all — keep arriving here.
- it('reads a slashdo-capable legacy record as a /do:pr run whatever boolean it carries', () => {
- // The #6869 defect on legacy data: `ownsPrWorkflow` answered "did the
- // prompt render the INLINE PR section", which is false for exactly the
- // hosts that run `/do:pr`. Trusting it re-created their PR at cleanup.
- for (const persistedOwnsPrWorkflow of [true, false, undefined]) {
- expect(resolveFor({ persistedOwnsPrWorkflow, providerId: 'claude-code', providerCommand: 'claude' }))
- .toBe(PR_OPENED_BY.AGENT_SLASHDO);
- }
- // Including the case a provider-id allowlist missed.
+ // #3733 boolean — or nothing at all — keep arriving here, and every one of
+ // them must resolve to the answer it resolved to BEFORE #6869.
+ it('keeps the #3733 boolean answering exactly as it did, on every host', () => {
+ // Deliberately NOT corrected for a slashdo-capable host. `false` there is
+ // ambiguous between the #6869 defect and a correct task-shape exclusion
+ // (read-only / no-code-output / discard-worktree / leave-open), and only
+ // the task tells them apart — which this leaf does not see. Overriding it
+ // would fix the first and break the second.
+ expect(resolveFor({ persistedOwnsPrWorkflow: false, providerId: 'claude-code', providerCommand: 'claude' }))
+ .toBe(PR_OPENED_BY.PORTOS);
expect(resolveFor({ persistedOwnsPrWorkflow: false, providerId: 'custom', providerCommand: '/opt/bin/claude' }))
- .toBe(PR_OPENED_BY.AGENT_SLASHDO);
- });
-
- it('keeps a slashdo-free legacy boolean answering exactly as it did', () => {
+ .toBe(PR_OPENED_BY.PORTOS);
expect(resolveFor({ persistedOwnsPrWorkflow: true })).toBe(PR_OPENED_BY.AGENT_INLINE);
expect(resolveFor({ persistedOwnsPrWorkflow: false })).toBe(PR_OPENED_BY.PORTOS);
expect(resolveFor({ persistedOwnsPrWorkflow: true, providerId: 'antigravity-cli', providerCommand: 'agy' }))
.toBe(PR_OPENED_BY.AGENT_INLINE);
- // A lean `--bare` session is not slashdo-capable, so its `false` stands.
+ // A lean `--bare` session is not slashdo-capable either way.
expect(resolveFor({ persistedOwnsPrWorkflow: false, providerId: 'claude-ollama', providerCommand: 'claude', leanMode: true }))
.toBe(PR_OPENED_BY.PORTOS);
});
@@ -518,6 +517,7 @@ describe('resolvePrOwnership', () => {
it('resolves a legacy record through the same fallback cleanup uses', () => {
expect(resolve().agentOpensOwnPr).toBe(false);
expect(resolve({ persistedOwnsPrWorkflow: true }).agentOpensOwnPr).toBe(true);
+ expect(resolve({ persistedOwnsPrWorkflow: false, providerId: 'claude-code', providerCommand: 'claude' }).agentOpensOwnPr).toBe(false);
expect(resolve({ providerId: 'claude-code', providerCommand: 'claude' }).agentOpensOwnPr).toBe(true);
});
});
diff --git a/server/services/agentCompletionCleanup.test.js b/server/services/agentCompletionCleanup.test.js
index 18b74d2332..0201fef20c 100644
--- a/server/services/agentCompletionCleanup.test.js
+++ b/server/services/agentCompletionCleanup.test.js
@@ -381,15 +381,16 @@ describe('runAgentCompletionCleanup — legacy records with no prOpenedBy stamp'
expect(opts.skipMerge).toBe(false);
});
- // The one legacy shape whose ANSWER changes, because it is the defect: a
- // slashdo-capable record stamped `false` really did run `/do:pr`, and cleanup
- // re-created its PR. Reading it as `agent-slashdo` applies the #6869 fix to
- // records written by an older version too.
- it('a slashdo-capable record stamped `ownsPrWorkflow: false` is read as a /do:pr run', async () => {
+ // The shape #6869 is ABOUT, and the one legacy answer deliberately left
+ // alone: `false` on a slashdo-capable host is ambiguous between the defect
+ // and a correct task-shape exclusion (read-only, no-code-output, …), and
+ // the record alone cannot tell them apart. New records carry `prOpenedBy`
+ // and get the corrected answer; a legacy one keeps exactly today's.
+ it('a slashdo-capable record stamped `ownsPrWorkflow: false` still hands the PR back', async () => {
expect(await cleanupCallFor(
{ providerId: 'claude-code', providerCommand: 'claude', leanMode: false, ownsPrWorkflow: false },
{ prClaimVerified: true },
- )).toMatchObject({ prCreation: 'never', skipMerge: true });
+ )).toMatchObject({ prCreation: 'always', skipMerge: false });
});
it.each([