Skip to content

fix(gate): keep each PID namespace's admissions in a ledger of its own - #703

Merged
kixelated merged 3 commits into
mainfrom
quest/m0/gate-ledger-compat
Nov 13, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m0/gate-ledger-compat

Conversation

@kixelated

@kixelated kixelated commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/gate-ledger-compat.md.

Cause (reproduced)

On Linux, a gate checks whether another gate is still running by looking up its process ID. A gate in its own PID namespace that shares the home directory (here, bwrap --dev-bind / / --unshare-pid --proc /proc quest gate true) can't see the host's processes. So it treats every admission older than a minute as finished and drops it. It also records itself as pid 3, and gates on the host drop that entry the same way. I reproduced this on the live ledger: the outer gate had been running sleep 130 for 70 s, and its admission disappeared once the sandboxed gate ran. The outer gate kept running without any error, because its measured cores stayed at 0. That's the silent case the quest describes. The quest build didn't matter: two unsandboxed gates, and the pinned build next to a current one, each running 80 s commands, never lost an admission.

Changes

  • The ledger path is now ~/.cache/quest/admissions-v2/<host>[-pid<ns inode>], which adds a format version (LEDGER_VERSION) and the PID namespace. Gates that can't check each other's processes no longer share a ledger, and neither do builds with different ledger formats.
  • measure checks for its admission on every sample, not only when the cores change. If the admission is missing, it records it again (same at, pid, and start) and warns on stderr. It no longer fails the command.
  • quest agent's ledger is versioned too, as agents-v2/<host>[-pid<ns inode>], so one LEDGER_VERSION bump separates both ledgers.
  • README and tests updated. There is a new test for re-recording while the cores stay the same.

Choices made without asking

  • Gates in a sandbox's PID namespace no longer count the host's gated commands, and gates on the host don't count theirs. I chose this over sharing one ledger across namespaces because sharing would need a liveness heartbeat that doesn't depend on process IDs. That's a bigger format change, and I'd only do it if sandboxed gates turn out to overload the host.
  • The ledger's PID-namespace ID is the inode number from /proc/self/ns/pid. Other platforms keep the plain <host> name.

Models

  • claude-opus-5-5 low (implementation)
  • Implementer: Claude Code, claude-opus-5-5, low effort (iterate, S)

Suggested follow-ups

  • None recommended. A heartbeat-based ledger shared across namespaces is worth planning only if sandboxed and host gates together overload a host. Drop it for now.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with low)

Review

Rewritten by quest review after each round.

  • Head: c102457

  • Base: origin/main at 1ac7193

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1d6e0-0921-7520-9f36-65b33bdd8c99, round 2

  • Score: 9/10, The incremental changes correctly version the agents ledger alongside the gate ledger, with no actionable bugs found; builds and tests were not run as instructed.

  • Rounds: 2; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

  • Reviewer: Codex, gpt-6.1-sol, low effort, shadow

  • Session: 01a1d6e0-0922-7151-9cca-e9a34e2e5044

  • Rounds: 1; findings 0: fixed 0, refuted 0, open 0

kixelated and others added 2 commits November 13, 2026 13:24
A gate in its own PID namespace, such as a bwrap --unshare-pid sandbox
sharing the home directory, could not see other gates' processes and dropped
their admissions a minute after admission. The ledger path now names the
namespace and a format version, and a running gate re-records a dropped
admission on every sample with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A gate never loses a running command's admission from the ledger fix(gate): keep each PID namespace's admissions in a ledger of its own Nov 13, 2026
@kixelated
kixelated marked this pull request as ready for review November 13, 2026 21:46
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f15baa64-c6aa-4bca-82fe-1740c190b2a3
Commits

Reviewing files that changed from the base of the PR and between cd70476 and c102457.

Files selected for processing: 5

  • README.md
  • quest/m0/gate-ledger-compat.md
  • src/cli/admission.ts
  • src/cli/gate.ts
  • test/gate.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — two minor suggestions inline.

Reviewed changes

I reviewed the ledger path split by PID namespace and format version, and the per-sample admission check in measure. The claimDirectory and measure tests pass locally (vitest -t "records|ledger|account without a home", plus test/admission.test.ts).

  • Versioned, per-namespace ledger path — claimDirectory() now returns admissions-v2/<host>[-pid<inode>], and pidNamespace() reads /proc/self/ns/pid on Linux.
  • Admission re-recorded instead of failing — measure reads its admission on every sample. If another gate dropped it, measure adds the last known entry back and reports this through the new lost callback, which gated() turns into a stderr warning.
  • Docs and tests — the README ledger paragraph is updated, there is a new test for re-recording while the cores stay the same, and the claimDirectory tests pin the namespace explicitly.

I checked one more thing: once the command ends, measure cannot add an admission back. stop.abort() runs synchronously while measure is waiting in sleep, and every fileHost ledger operation is synchronous.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread src/cli/gate.ts Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
…EADME

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the two commits since the prior pullfrog review. All three prior threads are already resolved.

  • Versioned agents ledger — agentsDirectory in src/cli/admission.ts now uses agents-v${LEDGER_VERSION}, and the LEDGER_VERSION doc comment covers both ledgers. The path still resolves to a sibling of the gate ledger directory.
  • README rewrap — the ledger paragraph wraps at 80 columns and mentions agents-v2/<hostname>.
  • Quest file removal — quest/m0/gate-ledger-compat.md is deleted as the quest finishes.

The other "agents" paths in src/cli/agent.ts are separate spawn records, so they are unaffected.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit b30e26f Nov 13, 2026
21 checks passed
@kixelated
kixelated deleted the quest/m0/gate-ledger-compat branch November 13, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant