Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(messaging): stop the unproven-owner refusal promising a remedy that cannot work

enesb9d40b848561
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 66e12230e..73ba6b4e4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -182,6 +182,15 @@ lane unaffected.
under them — and remember that clearing a dialog is not always just nulling its state (that one
also has to release the ref its own busy-guard reads).
+- **An error must not name a remedy nobody measured — and the remedy needs its own test.** The
+ `unproven-target-owner` refusal told its caller *"Re-open the target node so its owner is
+ recorded, then try again"*, and re-opening is precisely the attach that records nothing
+ (ownership is recorded only on a genuine fresh spawn), so a caller that obeyed got the identical
+ refusal forever. It shipped because no test read the sentence. When you write a refusal, pin its
+ claim against the MECHANISM it describes — assert the remedy's precondition by calling the
+ function that decides it, so the copy goes red when the behaviour moves — and remember who reads
+ it: telling a language model to do something only a human can do is not advice.
+
- **Anything path-shaped: Windows is a delivery target.** Most of this was written on
macOS/Linux, so the recurring defect is code that is genuinely correct on POSIX —
`split('/')`, `startsWith('/')` as an is-absolute test, a bare `fs.rename`. Use
diff --git a/src/core/agents/agent-messaging.ts b/src/core/agents/agent-messaging.ts
index dcaebdc4a..d06c53e21 100644
--- a/src/core/agents/agent-messaging.ts
+++ b/src/core/agents/agent-messaging.ts
@@ -306,10 +306,24 @@ const NOT_PERMITTED_TEXT: Record<NotPermittedReason, string> = {
'that node id exists in more than one project, so the target pane cannot be attributed to a ' +
'single project\'s messaging grant. De-duplicate the id (re-add the cloned folder to mint ' +
'fresh ids) before messaging it.',
+ // The remedy sentence here USED TO SAY "Re-open the target node so its owner is recorded, then
+ // try again", and that was false in the commonest case it fires in. Ownership is recorded only
+ // on a GENUINE FRESH SPAWN (`shouldRecordOwnership`, `fresh === true`); after an app restart the
+ // tmux server has survived, so re-opening the node ATTACHES to the session that is already
+ // running and records NOTHING. A caller that followed the advice got the identical refusal, and
+ // the one thing that does fix it — respawning the session — was the one thing the text did not
+ // say. It also told a LANGUAGE MODEL to do something only a human can do.
+ //
+ // `pane-ownership.ts` explains why attaching deliberately does not record (there is no
+ // cross-restart signal a hostile pane's own shell could not also write), so this is a permanent
+ // property to describe honestly, not a gap to promise around. No retry advice is spelled out
+ // here: `renderMessageOutcome` appends it from `RETRYABLE`, where `notPermitted` is false.
'unproven-target-owner':
'the target pane\'s owning project cannot be proven at runtime (it was not freshly spawned in ' +
'this session, or its ownership is disputed), so a per-project messaging grant cannot be ' +
- 'applied to it. Re-open the target node so its owner is recorded, then try again.'
+ 'applied to it. Attaching to the running session cannot prove this — only a fresh spawn ' +
+ 'records the owner — so the USER has to end that session and start it again (an app restart ' +
+ 'leaves it unproven; a machine restart clears it). Ask them, or reach that agent another way.'
}
/**
diff --git a/src/core/agents/unproven-owner-text.test.ts b/src/core/agents/unproven-owner-text.test.ts
new file mode 100644
index 000000000..89a1b496a
--- /dev/null
+++ b/src/core/agents/unproven-owner-text.test.ts
@@ -0,0 +1,69 @@
+import { describe, expect, it } from 'vitest'
+
+import { renderMessageOutcome } from './agent-messaging'
+import { RETRYABLE } from './agent-message-decide'
+import { shouldRecordOwnership } from './pane-ownership'
+
+/**
+ * The `unproven-target-owner` refusal told its caller to do something that does not work, and
+ * nothing in a 11k-test suite noticed — because no test read the sentence.
+ *
+ * It said: "Re-open the target node so its owner is recorded, then try again." Ownership is
+ * recorded ONLY on a genuine fresh spawn (`shouldRecordOwnership`, `fresh === true`), and after an
+ * app restart the tmux server has survived, so re-opening ATTACHES to the running session and
+ * records nothing. A caller that obeyed got the identical refusal, forever.
+ *
+ * These assertions pin the sentence against the MECHANISM rather than against itself: the prose
+ * claims attaching cannot prove ownership, and the test asks `shouldRecordOwnership` whether that
+ * is true. That is the shape that would have caught the original — see the repo's rule about
+ * claims written ahead of the mechanism.
+ */
+const refusal = (): string => {
+ const r = renderMessageOutcome({
+ kind: 'notPermitted',
+ reason: 'unproven-target-owner'
+ } as Parameters<typeof renderMessageOutcome>[0])
+ return r.error ?? ''
+}
+
+describe('the unproven-target-owner refusal describes a remedy that exists', () => {
+ it('does not tell the caller to re-open the node', () => {
+ // The false remedy, in the two spellings it could come back as.
+ expect(refusal().toLowerCase()).not.toContain('re-open')
+ expect(refusal().toLowerCase()).not.toContain('reopen')
+ })
+
+ it("says attaching cannot prove ownership — and the mechanism agrees", () => {
+ expect(refusal().toLowerCase()).toContain('attaching')
+ // The claim, measured. An attach is `fresh === false`, and the gate refuses to record it; a
+ // genuine fresh spawn is what records. If this ever flips, the sentence becomes a lie again
+ // and this test is what says so.
+ expect(shouldRecordOwnership(false, 'nt-x', 'proj-1')).toBe(false)
+ expect(shouldRecordOwnership(true, 'nt-x', 'proj-1')).toBe(true)
+ })
+
+ it('names the remedy that does work, and whose job it is', () => {
+ const text = refusal().toLowerCase()
+ // Respawning the session is the only thing that records the owner…
+ expect(text).toMatch(/end that session and start it again/)
+ // …and it is a human action: the caller is a language model that cannot do it.
+ expect(text).toContain('user')
+ })
+
+ it('is honest that an app restart is what put the pane in this state', () => {
+ // The commonest way to arrive here, and the one the old text implicitly denied by offering a
+ // re-open as the cure.
+ expect(refusal().toLowerCase()).toContain('app restart')
+ })
+
+ it('spells out no retry advice of its own — that comes from RETRYABLE', () => {
+ // `renderMessageOutcome` appends "Do not retry." / "Retryable — …" from the table. A sentence
+ // carrying its own "then try again" both duplicated it and contradicted it.
+ expect(RETRYABLE.notPermitted).toBe(false)
+ expect(refusal()).toContain('Do not retry.')
+ // The refusal's OWN half (before the appended advice) must not invite a retry.
+ const own = refusal().split('Do not retry.')[0]
+ expect(own.toLowerCase()).not.toContain('try again')
+ expect(own.toLowerCase()).not.toContain('retry')
+ })
+})