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(project-limit): DO_NOT_TRACK installs re-claim at the limit so an undo reaches them

review360a194d220e
diff --git a/docs/project-limit.md b/docs/project-limit.md
index cd657d6f3..e6b0acf9a 100644
--- a/docs/project-limit.md
+++ b/docs/project-limit.md
@@ -86,12 +86,16 @@ active = packaged build AND allowance key configured
no allowance, so every claim would fail and every install — legacy ones included — would be held
at FREE. It stays unlimited instead, exactly like a build from before the limit existed (no claim,
no dialog, no machine read).
-- **The latch is the server's word.** A check reply carrying `limits: { projects: { free, epoch } }`
- sets it (and stores FREE and the epoch). It is cleared by exactly two answers: a successful,
- *check-shaped* reply (a `messages` array and an `update` object) **without** `limits`, or a claim
- answering `409 not_active`. A failed check, a non-2xx, an HTML captive portal, a JSON page that is
- not a check reply, or a malformed `limits` is no answer and changes nothing — being unreachable
- never turns the limit off.
+- **The latch is the server's word.** Two answers set it: a check reply carrying
+ `limits: { projects: { free, epoch } }` (it stores FREE and the epoch), and a successful claim (a
+ `200` whose token verifies — it stores FREE, the epoch and the token). It is cleared by exactly two
+ answers: a successful, *check-shaped* reply (a `messages` array and an `update` object)
+ **without** `limits`, or a claim answering `409 not_active` (which also deletes the token). A
+ failed check or claim, a non-2xx, an HTML captive portal, a JSON page that is not a check reply,
+ or a malformed `limits` is no answer and changes nothing — being unreachable never turns the
+ limit off. The latch outranks the deadline, so a latched install whose check feed does not run
+ (DO_NOT_TRACK, `NODETERM_TELEMETRY_DISABLED`) is turned off only by a claim — which is why the
+ gate claims once more at its known allowance (The limit moment, item 5).
- **The embedded deadline** (`PROJECT_LIMIT_DEADLINE_MS`) covers a client whose check never runs
(DO_NOT_TRACK, `NODETERM_TELEMETRY_DISABLED`, a blocked host). Past it the client treats the limit
as on, which in practice only means "claim before opening beyond FREE"; a `not_active` answer
@@ -122,7 +126,9 @@ The rest of the state (`ProjectLimitState`):
One open is then decided by `decideOpen(state, openCount)`: off or Pro → allow; fewer open than
`effectiveLimit` (`max(allowance ?? free, free)` — an old allowance never undercuts a raised FREE)
→ allow; at the limit with no allowance yet → claim first; at or above a known allowance → block.
-Above it is reachable (a Pro lapse): the new open is blocked and **nothing is closed**.
+Above it is reachable (a Pro lapse): the new open is blocked and **nothing is closed**. Under
+DO_NOT_TRACK the gate turns one `block` per open into a claim first (The limit moment, item 5);
+`decideOpen` itself does not know about it.
## Where the gate sits
@@ -172,6 +178,15 @@ not above it.
`settings.licenseNetworkConsent`, shown and revocable in Settings → Privacy only while DNT is set,
never settable by an agent, and it covers license and claim calls only — never telemetry or the
check feed.
+5. DO_NOT_TRACK (or `NODETERM_TELEMETRY_DISABLED`) at a **known** allowance → one claim before the
+ dialog (`reclaimsAtBlock` in the gate), once per open, with the same 300 ms panel. Such an install
+ hears no check feed, so this claim is the only way an undo (`not_active`), an epoch bump or a
+ raised FREE reaches it. `not_active` (or a larger allowance) → the open proceeds with no dialog;
+ the same allowance → the dialog of item 2, after exactly that one claim; a claim that cannot
+ reach the server → also item 2's dialog, not "Couldn't check" (the allowance is known and
+ verified offline); no consent → item 4, exactly as on a first claim. Every other install is
+ unchanged: at a known allowance it shows the dialog without claiming. The agent checks re-claim
+ the same way but never ask for consent (`consent_required` stays a refusal).
While the limit is on, the Pro comparison (Settings) heads Core "Core — free" (not "free forever")
with "Up to N open projects", lists "Unlimited open projects" under Pro, and the upgrade dialog adds
@@ -231,7 +246,11 @@ with "Up to N open projects", lists "Unlimited open projects" under Pro, and the
3. **The flip release needs owner step O1**: a frozen release is refused while
`PROJECT_ALLOWANCE_PUBLIC_KEY` is empty (see O1 — and do it well before then).
4. **After an undo**, unfreeze: a release with `FROZEN = false` and a deadline past the new plan
- (see Undo below — without it, DO_NOT_TRACK installs stay gated).
+ (see Undo below). Without it the past deadline re-arms every DO_NOT_TRACK /
+ `NODETERM_TELEMETRY_DISABLED` install 24 h after each `not_active`. Even with it, a *latched* one
+ (it holds a token from an earlier claim) turns off only at its next limit moment, through the
+ re-claim, and one without consent stays gated until it consents — the latch outranks the
+ deadline.
5. Keep both constants in their literal one-line form —
`export const PROJECT_LIMIT_DEADLINE_MS = Date.parse('<ISO instant>')` and
`export const PROJECT_LIMIT_DEADLINE_FROZEN = true | false` — because the guard reads the source.
@@ -273,8 +292,9 @@ What enforces it:
- **The unit test** (`src/core/project-allowance-token.test.ts`) accepts exactly `''` or an
Ed25519 public-key PEM that differs from `ENTITLEMENT_PUBLIC_KEY` and is not a private key, so a
half-pasted or wrong key goes red on the PR that pastes it. It is green on `main` either way.
-- **On the server**, without the private key the claim route does not exist (404) and `/v1/check`
- never sends `limits`, whatever the cutoff says.
+- **On the server**, without the private key `POST /v1/limits/claim` answers every claim
+ `409 { error: 'not_active' }` and `/v1/check` never sends `limits`, whatever the cutoff says — so a
+ client that hears either turns the limit off.
**A build shipped with `''` is never active** — it stays unlimited, like a build from before the
limit (see How `active` is computed), even after the flip. So every release made before O1 adds to
@@ -365,15 +385,26 @@ The decision is enes's. Device check 10 below gathers the evidence.
(offline, a blocked host) is back on until a check or claim answers again. At the limit it then
uses its stored allowance token offline (an undo through the check feed keeps it); without one,
its claim fails and it is held at FREE behind "Couldn't check".
- 3. **DO_NOT_TRACK installs with consent** (no check feed) claim at their next limit moment;
- `not_active` turns them off for 24 h, and then the past deadline re-arms them. So every time
- one reaches FREE more than 24 h after its last claim it claims again — offline, that claim
- fails and it is held at FREE behind "Couldn't check".
+ 3. **DO_NOT_TRACK installs with consent** (no check feed; `NODETERM_TELEMETRY_DISABLED` behaves
+ exactly like DO_NOT_TRACK here) claim at their next limit moment — one that holds an allowance
+ token (latched by its own earlier claim) too: the gate re-claims at its known allowance (The
+ limit moment, item 5), because that claim is the only way an undo reaches it. `not_active`
+ clears the latch and the token and turns it off for 24 h, and then the past deadline re-arms
+ it. So every time one reaches FREE more than 24 h after its last claim it claims again —
+ offline, that claim fails and it is held at FREE behind "Couldn't check". Until a claim gets
+ through, one with a token stays at its allowance (an offline re-claim there just shows the limit
+ dialog).
4. **DO_NOT_TRACK installs without consent** never claim (the license network gate refuses before
- any request): they stay at FREE behind the consent dialog until the user consents.
+ any request): at the limit they see the consent dialog and stay gated until the user consents —
+ at FREE, or at the allowance of a token they still hold (latched before consent was revoked, or
+ by the check feed before DO_NOT_TRACK was set). Consenting there claims, and an undo then turns
+ them off as in 3.
5. **So a complete undo also ships a release** with `PROJECT_LIMIT_DEADLINE_FROZEN = false` and the
- deadline bumped past the new plan; the guard applies again from then on. Installs that do not
- update keep the behaviour in 2–4.
+ deadline bumped past the new plan; the guard applies again from then on. On it, an install that
+ is not latched is off at once. A latched DO_NOT_TRACK install is not — the latch outranks the
+ deadline — until its next limit moment: with consent that re-claim answers `not_active` and it
+ is off for good; without consent it stays gated until the user consents (4). Installs that do
+ not update keep the behaviour in 2–4.
6. Nothing was ever closed, so there is nothing to restore. To re-flip at a new cutoff, **bump the
epoch in the same save** (the admin card's "Bump epoch" box), so allowances issued under the old
cutoff are recomputed.
@@ -407,6 +438,8 @@ Not gaps: blocking api.nodeterm.dev leaves an install at FREE after the deadline
Rough edges a user can notice (behaviour, not bypasses):
- A second open pressed while a claim or the dialog is in flight is dropped (press again).
+- Under DO_NOT_TRACK, the limit moment at a known allowance waits for one claim before the dialog
+ (the "Checking…" panel after 300 ms; up to the 8 s claim timeout when offline).
- When the dialog was raised by an agent's refusal, a Close makes room but nothing opens — the agent
was already told no; ask it again.
- At the limit, an agent's headless start of a node in a closed project runs without bringing the
@@ -468,7 +501,11 @@ verification and reads as "Couldn't check your free allowance".
row shows the consent and revoking it works.
14. Machine move: copy userData to a second machine → its first claim rebinds; a third machine is
told the date the allowance can move.
-15. Undo: clear the cutoff → the next check removes the gate; a DO_NOT_TRACK client with consent
- clears on its next claim and, after 24 h, claims again at its next limit moment; one without
- consent stays behind the consent dialog. Then a test build with `FROZEN = false` and a future
- deadline clears both for good.
+15. Undo: clear the cutoff → the next check removes the gate. A DO_NOT_TRACK client with consent
+ that already holds an allowance token (claimed in 13, still latched): at its allowance the next
+ open makes one claim, which answers `not_active`, and the open proceeds with no dialog; after
+ 24 h it claims again at its next limit moment. One without consent stays behind the consent
+ dialog until it consents. Repeat both with `NODETERM_TELEMETRY_DISABLED=1` instead of
+ DO_NOT_TRACK. Then a test build with `FROZEN = false` and a future deadline: a non-latched DNT
+ client is clear at once; a latched one clears for good at its next limit moment (with consent),
+ or stays behind the consent dialog (without).
diff --git a/src/core/project-limit.ts b/src/core/project-limit.ts
index 76669274b..35f31cbc9 100644
--- a/src/core/project-limit.ts
+++ b/src/core/project-limit.ts
@@ -8,9 +8,13 @@
* has passed by the clock anchor, with no server "off" in the last `OFF_TRUST_MS`). Dev builds are
* never active; nor is a build without the key (before O1): it could verify no allowance, holding
* every install at FREE, so it stays unlimited like a build from before the limit.
- * - The latch is the server's word. A check answer with `limits` sets it; a successful check
- * without them, or a claim answering `not_active`, clears it. Nothing else does: a failed check
- * gives no answer at all (check.ts `onCheckAnswer`), so being unreachable never turns it off.
+ * - The latch is the server's word. A check answer with `limits` sets it, and so does a successful
+ * claim (a 200 whose token verifies — the token is stored with it); a successful check without
+ * `limits`, or a claim answering `not_active`, clears it. Nothing else does: a failed check gives
+ * no answer at all (check.ts `onCheckAnswer`), so being unreachable never turns it off. A
+ * DO_NOT_TRACK install hears no check at all, which is why the renderer's gate claims once more at
+ * its known allowance (lib/projectLimitGate.ts `reclaimsAtBlock`): that claim is how an undo
+ * reaches a latched one.
* - The deadline is compared against `clockAnchorMs()` (license.ts: the later of the wall clock and
* the largest instant this install has observed), so rolling the clock back cannot move an install
* from past the deadline to before it.
@@ -340,7 +344,8 @@ async function runClaim(): Promise<ClaimResult> {
if (status === 409 && b.error === 'machine_mismatch') {
return fail('machine_mismatch', isCount(b.retryAfter) && b.retryAfter > 0 ? b.retryAfter : undefined)
}
- // 429 (rate limited), 5xx, 400, 404 (claims disabled server-side), an unknown 409: never a final answer.
+ // 429 (rate limited), 5xx, 400, an unknown 409, any other status (a 404 included — a server with
+ // claims switched off answers 409 not_active, never 404): never a final answer.
return fail('server')
}
diff --git a/src/renderer/lib/projectLimitGate.test.ts b/src/renderer/lib/projectLimitGate.test.ts
index 0428ad4f6..48933c5c1 100644
--- a/src/renderer/lib/projectLimitGate.test.ts
+++ b/src/renderer/lib/projectLimitGate.test.ts
@@ -344,6 +344,141 @@ describe('gateProjectOpen — the human open path', () => {
})
})
+describe('DO_NOT_TRACK installs re-claim at a known allowance (the undo has no other way in)', () => {
+ // A consenting DNT install that claimed is latched and holds a token, so `decideOpen` answers
+ // 'block' at its allowance — and its check feed never runs, so without a claim at the limit it
+ // would never hear `not_active` (an undo), an epoch bump or a raised FREE.
+ const DNT_CLAIMED_5: ProjectLimitState = { ...CLAIMED_5, dnt: true }
+ const DNT_OFF: ProjectLimitState = { ...INACTIVE, dnt: true }
+ const MESSAGE = 'free plan: 5 of 5 projects are open; the user has been shown the options'
+
+ it('person: one claim at the limit, and a not_active answer opens with no dialog', async () => {
+ const t = harness(DNT_CLAIMED_5, 5)
+ t.claim.mockResolvedValue({ ok: true, state: DNT_OFF })
+ const g = createProjectOpenGate(t.deps).gateProjectOpen()
+ expect(g).toBeInstanceOf(Promise)
+ await expect(g).resolves.toBe(true)
+ expect(t.claim).toHaveBeenCalledTimes(1)
+ expect(t.showDialog).not.toHaveBeenCalled()
+ })
+
+ it('person: the same allowance back shows the limit dialog after exactly one claim, never a loop', async () => {
+ const t = harness(DNT_CLAIMED_5, 5)
+ t.claim.mockResolvedValue({ ok: true, state: DNT_CLAIMED_5 })
+ const g = createProjectOpenGate(t.deps).gateProjectOpen()
+ await settle()
+ expect(t.claim).toHaveBeenCalledTimes(1)
+ expect(t.showDialog.mock.calls).toEqual([[{ mode: 'limit' }]])
+ // A `proceed` with no room re-decides — still 'block' — and does not claim a second time.
+ t.answer('proceed')
+ await settle()
+ expect(t.claim).toHaveBeenCalledTimes(1)
+ expect(t.showDialog).toHaveBeenCalledTimes(2)
+ t.answer('cancel')
+ await expect(g).resolves.toBe(false)
+ expect(t.claim).toHaveBeenCalledTimes(1)
+ })
+
+ it('person: a re-claim that cannot reach the server is today\'s limit dialog, not "Couldn\'t check"', async () => {
+ // The allowance is already known and verified offline (Review Focus 2): failing to hear an
+ // undo is no reason to tell the user their allowance could not be checked.
+ const t = harness(DNT_CLAIMED_5, 5)
+ t.claim.mockResolvedValue({ ok: false, error: 'offline', state: DNT_CLAIMED_5 })
+ const g = createProjectOpenGate(t.deps).gateProjectOpen()
+ await settle()
+ expect(t.showDialog.mock.calls).toEqual([[{ mode: 'limit' }]])
+ t.answer('cancel')
+ await expect(g).resolves.toBe(false)
+ expect(t.claim).toHaveBeenCalledTimes(1)
+ })
+
+ it('person: without consent the re-claim asks for it, exactly like a first claim', async () => {
+ const t = harness(DNT_CLAIMED_5, 5)
+ t.claim
+ .mockResolvedValueOnce({ ok: false, error: 'consent_required', state: DNT_CLAIMED_5 })
+ .mockResolvedValueOnce({ ok: true, state: DNT_OFF })
+ const g = createProjectOpenGate(t.deps).gateProjectOpen()
+ await settle()
+ expect(t.showDialog.mock.calls).toEqual([[{ mode: 'consent' }]])
+ t.answer('consent')
+ await expect(g).resolves.toBe(true)
+ expect(t.setConsent).toHaveBeenCalledTimes(1)
+ expect(t.claim).toHaveBeenCalledTimes(2)
+ expect(t.showDialog).toHaveBeenCalledTimes(1)
+ })
+
+ it('person: declining that consent resolves false and stores nothing', async () => {
+ const t = harness(DNT_CLAIMED_5, 5)
+ t.claim.mockResolvedValue({ ok: false, error: 'consent_required', state: DNT_CLAIMED_5 })
+ const g = createProjectOpenGate(t.deps).gateProjectOpen()
+ await settle()
+ t.answer('cancel')
+ await expect(g).resolves.toBe(false)
+ expect(t.setConsent).not.toHaveBeenCalled()
+ expect(t.claim).toHaveBeenCalledTimes(1)
+ })
+
+ it('a non-DNT install at a known allowance never re-claims: it hears the undo on the check feed', async () => {
+ const t = harness(CLAIMED_5, 5)
+ const gate = createProjectOpenGate(t.deps)
+ const g = gate.gateProjectOpen()
+ await settle()
+ expect(t.showDialog.mock.calls).toEqual([[{ mode: 'limit' }]])
+ t.answer('cancel')
+ await expect(g).resolves.toBe(false)
+ await expect(gate.checkAgentProjectOpen()).resolves.toEqual({ ok: false, message: MESSAGE })
+ expect(gate.finishAgentProjectOpen(() => true, () => 'never')).toEqual({ ok: false, message: MESSAGE })
+ expect(t.claim).not.toHaveBeenCalled()
+ })
+
+ it('a DNT install under its allowance still opens synchronously, with no claim', () => {
+ const t = harness(DNT_CLAIMED_5, 4)
+ expect(createProjectOpenGate(t.deps).gateProjectOpen()).toBe(true)
+ expect(t.claim).not.toHaveBeenCalled()
+ })
+
+ it('agent check: one claim at the limit; not_active allows, the same allowance refuses, consent is never asked', async () => {
+ const t = harness(DNT_CLAIMED_5, 5)
+ t.claim.mockResolvedValueOnce({ ok: true, state: DNT_OFF })
+ const gate = createProjectOpenGate(t.deps)
+ await expect(gate.checkAgentProjectOpen()).resolves.toEqual({ ok: true })
+ expect(t.claim).toHaveBeenCalledTimes(1)
+
+ t.claim.mockResolvedValueOnce({ ok: true, state: DNT_CLAIMED_5 })
+ await expect(gate.checkAgentProjectOpen()).resolves.toEqual({ ok: false, message: MESSAGE })
+ expect(t.claim).toHaveBeenCalledTimes(2)
+ expect(t.showDialog.mock.calls).toEqual([[{ mode: 'limit' }]])
+ t.answer('cancel')
+ await settle()
+
+ t.claim.mockResolvedValueOnce({ ok: false, error: 'consent_required', state: DNT_CLAIMED_5 })
+ await expect(gate.checkAgentProjectOpen()).resolves.toEqual({ ok: false, message: MESSAGE })
+ expect(t.claim).toHaveBeenCalledTimes(3)
+ expect(t.showDialog.mock.calls.some(([r]) => r.mode === 'consent')).toBe(false)
+ expect(t.setConsent).not.toHaveBeenCalled()
+ expect(t.setChecking).not.toHaveBeenCalled()
+ })
+
+ it('agent write: one claim at the limit, registered on not_active, refused on the same allowance', async () => {
+ const t = harness(DNT_CLAIMED_5, 5)
+ const gate = createProjectOpenGate(t.deps)
+ const register = vi.fn(() => 'registered')
+ t.claim.mockResolvedValueOnce({ ok: true, state: DNT_OFF })
+ const off = gate.finishAgentProjectOpen(() => true, register)
+ expect(off).toBeInstanceOf(Promise)
+ await expect(off).resolves.toEqual({ ok: true, value: 'registered' })
+ expect(t.claim).toHaveBeenCalledTimes(1)
+
+ register.mockClear()
+ t.claim.mockResolvedValueOnce({ ok: false, error: 'consent_required', state: DNT_CLAIMED_5 })
+ await expect(gate.finishAgentProjectOpen(() => true, register)).resolves.toEqual({ ok: false, message: MESSAGE })
+ expect(t.claim).toHaveBeenCalledTimes(2)
+ expect(register).not.toHaveBeenCalled()
+ expect(t.setConsent).not.toHaveBeenCalled()
+ expect(t.showDialog.mock.calls).toEqual([[{ mode: 'limit' }]])
+ })
+})
+
describe('checkAgentProjectOpen — the agent open-project verb', () => {
const MESSAGE = 'free plan: 5 of 5 projects are open; the user has been shown the options'
diff --git a/src/renderer/lib/projectLimitGate.ts b/src/renderer/lib/projectLimitGate.ts
index 3f1a9674e..25764f167 100644
--- a/src/renderer/lib/projectLimitGate.ts
+++ b/src/renderer/lib/projectLimitGate.ts
@@ -3,6 +3,7 @@ import {
decideOpen,
effectiveLimit,
type ClaimResult,
+ type OpenDecision,
type ProjectLimitState
} from '@shared/project-limit'
import {
@@ -16,9 +17,9 @@ import { useProjects } from '../state/projects'
import { useSettings } from '../state/settings'
/**
- * The one renderer gate in front of every way a project becomes open (spec §7,
- * docs/superpowers/specs/2026-10-29-free-tier-project-limit-design.md). It ANSWERS whether one new
- * open may proceed; it never closes, deletes or detaches anything (§2).
+ * The one renderer gate in front of every way a project becomes open (docs/project-limit.md, "The
+ * limit moment"). It ANSWERS whether one new open may proceed; it never closes, deletes or detaches
+ * anything.
*
* Two invariants the callers (Canvas's open paths, Task 18; the agent verb, Task 19) depend on:
* - **Allowed is synchronous.** `gateProjectOpen()` returns the literal `true` in the same tick when
@@ -28,6 +29,15 @@ import { useSettings } from '../state/settings'
* - **One loop at a time.** A request that arrives while a person's open is being decided (claiming,
* or a dialog up — a person's or an agent's) is refused, not queued: queued, it would re-decide on
* a count the first open has not added to yet and both would open past the limit.
+ *
+ * And one rule the server's undo depends on: **a DO_NOT_TRACK install re-claims at a known
+ * allowance.** Its check feed never runs, so the claim is the only server word it can hear — and a
+ * consenting one that claimed is latched with a token, where `decideOpen` answers `'block'`, not
+ * `'claim'`. Without one more claim there it would never hear `not_active` (the limit cleared), an
+ * epoch bump or a raised FREE, and the latch outranks the deadline, so not even an unfrozen release
+ * would reach it. `reclaimsAtBlock` is that rule: once per gate pass, only under DO_NOT_TRACK (any
+ * other install hears all of it on the check feed, and stays byte-identical), and only at the limit
+ * (under it the open stays synchronous and claims nothing).
*/
/** §7's "brief spinner": raised only for a claim still in flight after this long. */
@@ -60,6 +70,11 @@ export interface ProjectOpenGate {
finishAgentProjectOpen<T>(opens: () => boolean, register: () => T): AgentOpenFinish<T> | Promise<AgentOpenFinish<T>>
}
+/** A DO_NOT_TRACK install at a known allowance claims once more before it is refused (see above). */
+function reclaimsAtBlock(state: ProjectLimitState, d: OpenDecision): boolean {
+ return d === 'block' && state.dnt
+}
+
/** The dialog that explains a failed claim. A repeated `consent_required` right after the user
* consented means core still cannot see it: asking again would loop, so it reads as an error. */
function dialogFor(r: Extract<ClaimResult, { ok: false }>, consentGiven: boolean): LimitDialogRequest {
@@ -116,17 +131,27 @@ export function createProjectOpenGate(deps: ProjectOpenGateDeps): ProjectOpenGat
try {
let claimNext = false
let consentGiven = false
+ /** A claim has been made during this gate pass, so the DNT re-claim is spent. */
+ let claimed = false
for (;;) {
- const d = decideOpen(deps.getState(), deps.openCount())
+ const state = deps.getState()
+ const d = decideOpen(state, deps.openCount())
if (d === 'allow') return true
let request: LimitDialogRequest = { mode: 'limit' }
- // At most one claim per pass: when there is no allowance yet, or after Retry / consent.
- if (d === 'claim' || claimNext) {
+ // At most one claim per pass: when there is no allowance yet, after Retry / consent, or —
+ // once per gate pass — a DO_NOT_TRACK install at its known allowance.
+ const reclaim = !claimed && reclaimsAtBlock(state, d)
+ if (d === 'claim' || claimNext || reclaim) {
claimNext = false
+ claimed = true
const r = await claimShowingCheck()
// Decided on the claim's own answer — core's state right after it — with the live count.
if (decideOpen(r.state, deps.openCount()) === 'allow') return true
- if (!r.ok) request = dialogFor(r, consentGiven)
+ // A DNT re-claim (never one the user asked for: Retry and consent follow an earlier claim,
+ // which spent it) that failed at an allowance already known and verified offline is no
+ // news: today's limit dialog, not "Couldn't check". Missing consent is still asked for,
+ // exactly as on a first claim.
+ if (!r.ok && (!reclaim || r.error === 'consent_required')) request = dialogFor(r, consentGiven)
}
const outcome = await show(request)
if (outcome === 'cancel') return false
@@ -177,7 +202,7 @@ export function createProjectOpenGate(deps: ProjectOpenGateDeps): ProjectOpenGat
let state = deps.getState()
let d = decideOpen(state, deps.openCount())
if (d === 'allow') return { ok: true }
- if (d === 'claim') {
+ if (d === 'claim' || reclaimsAtBlock(state, d)) {
// Never the consent dialog and never the spinner: nobody pressed anything. A claim that needs
// consent simply leaves the state blocking.
const r = await claim()
@@ -194,9 +219,10 @@ export function createProjectOpenGate(deps: ProjectOpenGateDeps): ProjectOpenGat
* FINAL decision and `register()` run in one tick — nothing can run between the count read here
* and the write — so two agents at the edge cannot both pass on one count (plan Review Focus 5).
*
- * Synchronous whenever the limit decides at once (allow — every call while it is off — or block).
- * Only a claim still due returns a promise, and it is due exactly when the early check did NOT
- * claim: it saw room (4 of 5, no allowance yet) and an open landed before this point. That claim
+ * Synchronous whenever the limit decides at once (allow — every call while it is off — or block,
+ * except under DO_NOT_TRACK). Only a claim still due returns a promise, and it is due exactly when
+ * the early check did NOT claim: it saw room (4 of 5) and an open landed before this point —
+ * with no allowance yet, or under DO_NOT_TRACK at a known one (`reclaimsAtBlock`). That claim
* is made here (never the consent dialog, never the spinner), and the decision is taken on its
* own answer — the store may not have heard it yet, the rule both other paths follow — with the
* live count, `register()` following in the same continuation. A legacy install whose allowance
@@ -214,7 +240,8 @@ export function createProjectOpenGate(deps: ProjectOpenGateDeps): ProjectOpenGat
return { ok: true, value: register() }
}
const state = deps.getState()
- if (!opens() || decideOpen(state, deps.openCount()) !== 'claim') return decideAndRegister(state)
+ const d = decideOpen(state, deps.openCount())
+ if (!opens() || !(d === 'claim' || reclaimsAtBlock(state, d))) return decideAndRegister(state)
return claim().then((r) => decideAndRegister(r.state))
}
diff --git a/src/renderer/lib/projectOpens.ts b/src/renderer/lib/projectOpens.ts
index 4d6bd7427..011bbda66 100644
--- a/src/renderer/lib/projectOpens.ts
+++ b/src/renderer/lib/projectOpens.ts
@@ -20,10 +20,9 @@ export type OpenAction =
const reopens = (p: Project): boolean => !!p.closed && !p.remote
/**
- * Whether `a` makes a project OPEN that was not (spec §3,
- * docs/superpowers/specs/2026-10-29-free-tier-project-limit-design.md) — that is, whether the
- * project-limit gate must be asked before it. Activating a project that is already open is not an
- * open, so it never meets the gate.
+ * Whether `a` makes a project OPEN that was not (docs/project-limit.md, "Opening a project") —
+ * that is, whether the project-limit gate must be asked before it. Activating a project that is
+ * already open is not an open, so it never meets the gate.
*
* Each branch finds the project exactly as its store action will (the same matcher, in the same
* order), so the answer is a prediction of what that action does to the open count, not a second