Skip to content

feat(native): grow socket capacity in an idle or stopped pool - #1123

Draft
roodboi wants to merge 28 commits into
nextfrom
fix/native-pool-grow-socket-capacity
Draft

roodboi wants to merge 28 commits into
nextfrom
fix/native-pool-grow-socket-capacity

Conversation

@roodboi

@roodboi roodboi commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Behavior

A development pool grows to satisfy project minimums while stopped. A running pool uses the idle stop from #1119, including the final check before the guest stops. Live projects prevent the stop. The refusal reports named projects and their verified slot counts when those records are available. Exact requests keep their current admission contract. Growth preserves each direction's current capacity and the combined limit of 32.

Recovery

The stopped-pool journal names the exact provider row and owner receipt before and after. The provider row commits first. A retry verifies that ordered prefix, reapplies the exact commit if needed, and publishes the matching owner receipt. No start boots across a pending journal. Growth from zero application slots initializes a verified empty bridge registry under the journal.

State chart · Model

Verification

The model checks coherent boot and no eviction. Its negative control boots after the provider commit but before the owner commit. The Rust regression exercises ordered replay pairs and minimum versus exact requests. The project-name tests check per-project socket counts. Live VM boot and stopped-provider database replay require Mac qualification.


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

roodboi and others added 27 commits November 22, 2026 09:42
…524)

`native-run-mapping-release/MappingRelease.tla`: a checkout's run mapping names
the home that owns its run, and a deleted home takes its clean-stop records
with it. `positive` releases when the recorded path no longer holds the home
(absent, not a directory, or another identity) and no process names the path:
`NoStrandedMapping` and `NeverReleaseLive` hold (21 states). `negative` is today
(the clean-stop release from the home's records only), which strands a deleted
home; `path-only` drops the process scan and releases while the home's run is
alive. The residual is a home moved and restarted from its new path.

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

# Conflicts:
#	docs/reference/v5-model-coverage.md
Deleting a native home that ran a shared project stranded its checkout: the
mapping's clean-stop proof lived in the deleted home, so the foreign-home
refusal pointed at a command that could not work.

A recorded path that no longer holds that home (absent, not a directory, or a
directory of another identity) is now `owner: "gone"` with its own selection
digest, and the refusal names the existing release command. The release scans
this user's processes (`ps` command lines, `lsof` working directories) and
refuses, naming each PID, while any names the old home's path or works inside
it. Otherwise it keeps the mapping, its restart intent and its down-hook journal
in `<scope>.gone-home-release-<sha>.json` (owed hooks are skipped) and removes
them. An unreadable listing refuses.

Residual, said in the refusal and the docs: a home moved and started again from
its new path names only the new path; release again from the moved home.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot a deleted home (HACK-2524)

Lead review of #1104:
- lsof exits 1 both for "some process unreadable" and for a failed run with no
  output, so an empty listing could read as "no process". Each listing must now
  show this very process (its pid in ps, its working directory in lsof), or the
  scan refuses.
- An absent home path may be a disk that is not mounted. The refusal no longer
  says the data went with the home: it says the home is not at that path any
  more, and to mount the disk and stop the run there instead. When the topmost
  missing directory sits directly under /Volumes, /mnt, /media or
  /run/media/<user>, inspection adds `missingVolume` and the text names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efusal (HACK-2524)

Mac review of #1104: `doctor --native-run-mapping release` on an instance with no
mapping printed a raw ENOENT and a stack (readRecoveryFile in the selection). Both
release paths (stopped home and gone home) now select through one helper that
refuses: no mapping to release for this instance, nothing changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er a listener (HACK-2550)

`native-pool-stop` adds the shared HTTPS port: the retired owner's Caddy leaves
it in TIME_WAIT until `TimeWaitEnds`, and another process may `Listen` on it
(a bounded fault) and later exit. The archive claims the port only when
`PortClaimable`: with `ReuseBind` a reuse bind passes over TIME_WAIT, and
`ListenerCheck` refuses any other listener. `https` now passes in 608 states,
including the new `NoArchiveOverListener`. The new control `reuse-no-check`
(reuse bind without the listener check) archives over a live listener.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er check (HACK-2550)

After a pool stop, the previous-boot archive waited up to about 30 s for the
retired Caddy's connections to leave TIME_WAIT: its wildcard guard bind had no
address reuse. On macOS the guards now bind with SO_REUSEADDR (never
SO_REUSEPORT), which passes over TIME_WAIT but not over a live wildcard or
loopback listener. Then `/usr/sbin/netstat -an -p tcp` (fixed path, clean
environment, 5 s bound) must list exactly this process's four guard listeners
on the port; any other listener, a missing guard, or a list that cannot be
read or parsed falls back to the strict claim and its 35 s retry. Other hosts
keep the strict claim.

Tests: the netstat parser (TIME_WAIT and other ports ignored, a specific or
dual-stack listener reported, torn output unreadable) runs everywhere; a macOS
test leaves the port in TIME_WAIT, checks the strict claim refuses, and claims
it at once, and a live loopback listener still refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to fix/native-https-port-time-wait

# Conflicts:
#	docs/reference/v5-model-coverage.md
… TCP listener list (HACK-2550)

macOS 27 returns an empty TCP table, with a success status, to netstat
started by a program that is not part of the system, so the listener
list always fell back to the strict claim and the 30 s TIME_WAIT wait
stayed. The reuse claim now binds, with SO_REUSEADDR and never
SO_REUSEPORT, the wildcard, the loopback and every interface address
from getifaddrs exactly (IPv6 link-local with its scope id). Another
listener on any of them refuses that bind; TIME_WAIT does not. The
addresses are listed again after binding and must match; an address the
kernel will not bind now (EADDRNOTAVAIL) is skipped. Any other failure
falls back to the strict claim.

Tests (macOS): listeners on an interface address with SO_REUSEADDR,
SO_REUSEPORT, both or neither refuse; a wildcard SO_REUSEPORT listener
refuses; an address change between the listings refuses; the first
refusal of each claim is named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rds included (HACK-2550)

The descriptor count compares with the guards returned, which now hold one
per bindable interface address. The claim's comment states that its socket
count is bounded by the host's interface addresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… into feat/native-idle-pool-share-restart

# Conflicts:
#	tests/models/tla/native-pool-stop/PoolStop.tla
…folder (HACK-2535)

A running pool's mounts never change, so `up` in a project root the pool
does not share refused until every project was stopped and the pool was
stopped by hand. When nothing uses the running pool live, `up` now stops
it, adds the root through the journaled stopped-pool share update, prints
one line ("Restarting the native runtime to add this project's folder,
about 30 s.") and boots it as part of its own start.

Idle (`pool_users::require_idle`): no graph run whose receipt is live, no
pending dead-owner recovery, no open interactive session, and no image
build. `lifecycle::stop_idle_pool` checks it under the provider lease and
again right before the guest stops; every graph start needs that lease
before it creates a container, so a start that turns live meanwhile makes
the stop refuse (`project_share_pool_in_use`) instead of being stopped. A
full or conflicting share set refuses before anything stops. A pool in
use, or one starting or stopping, refuses as before with the down-then-up
steps (no hand `runtime down` any more). The same rule applies to a pool
started by hand.

Model: native-pool-stop gains `idle-restart` (302 states, invariant
`NoRestartOverLiveRun`) and the failing control `idle-restart-one-check`
without the second check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… name the projects that keep it in use (HACK-2535)

Review of #1119:
- In idle mode the host-side releases of a stop (the managed hostname
  authority and the pool's publishers) now follow the second idle check,
  right before the guest stops. The first check runs under the lease
  before any effect, so a refusal at either check changes nothing. Plain
  `runtime down` keeps its order.
- `runtime status` reports `live_runs`, the live graph run ids. The
  in-use refusal maps them through the run mappings of registered
  projects and their worktrees, names up to three, then "and N more", and
  says so when no registered checkout maps a live run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…native-authored runs are named (HACK-2535)

Independent review of #1119:
- A dead-owner recovery intent stays in its run directory as history once
  complete. Only an intent without `complete_sha256`, or its staging
  file, is pending; an unreadable intent still refuses.
- The in-use names read native-authored run mappings too
  (`.internal/native-authored-runs`).
- An image build (`provider_busy`) refuses with its own reason; an open
  session names `hack exec-sessions --reconcile`; a running record whose
  provider exited is no longer called "starting or stopping" only.
- Wording: the lease is held from the first idle check to the stop, so a
  start in between waits for it. The model stays deliberately more
  permissive (a start may turn live between the checks), which is what
  `idle-restart-one-check` shows the second check guards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CK-2535)

Re-review of #1119: native-authored mappings are `{ scope, record }`; the
ready record names its run at `record.receipt.review.provenance.run`, the
start record at `record.review.provenance.run`. Only those two file kinds
are read in that store, so host-process records are no longer matched by
accident. The fixture now uses the real shapes. The model README row says
the failing control needs a start that took no lease.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut a time figure (HACK-2535)

Real-VM run of #1119: in `up -d` the source preflight runs in the
detached owner, whose standard error does not reach the person, so the
restart line was never shown. It now goes through the owner's validated
notice channel (`reportNativeImageTagOffline`, the image notice's
channel), which the launcher prints on standard error, so `--json`
stdout stays clean; a foreground start still prints it directly. The
whole second `up` took 6 s there, so the line no longer names a time.

Test: the detached-owner fixture's `pool-restart-notice` mode runs the
real preflight in the owner; the launcher shows exactly the line on
stderr and its JSON envelope on stdout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	tests/fixtures/native-detached-owner.ts
@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hack-docs Ready Ready Preview Nov 22, 2026 10:40pm UTC

Request Review

@roodboi

roodboi commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T22:42:41.293113Z 3614377 Manual request
🔒 Security Review ✅ Completed 2026-11-22T22:44:23.034349Z 3614377 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3614377714

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +190 to +193
let _lease = lifecycle::startup_lease(&pool, lifecycle::STARTUP_LEASE_WAIT)?;
network_update::require_complete(candidate)?;
share_update::require_complete(candidate)?;
let owner = Owner::load(candidate)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the stopped pool's HOME alias before staging resize writes

If host cleanup removed a cleanly stopped pool's temporary HOME alias, the initial owner read still succeeds, but this transaction never restores the alias before writing owner.pending. An interruption during after.save(candidate) then leaves an unrecoverable retry: Owner::load rejects a missing alias whenever owner.pending exists, so startup fails before reaching the staging-file recovery below, while the socket journal also blocks other pool updates. Restore the missing alias under the lease before beginning the resize transaction, as the network-update path does, so retrying the same startup request can actually finish the journal.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3614377714

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Parked as a draft while we qualify a higher pool limit and default capacity. Before this returns: (M1) rebind the retained-start guard to the owner receipt returned by resize, since the update changes the digest the guard verifies. (M2) replay a valid pending resize journal for any start, then recompute the new request against the resulting owner. Recovery must work without repeating an exact prior request.

Base automatically changed from feat/native-idle-pool-share-restart to next November 23, 2026 15:49
@roodboi

roodboi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Lead triage: PARTLY COVERED. 20 of 22 commits are on next through other PRs. Recommend closing and re-cutting the two remaining commits after #1122 lands. This can wait for 5.1.

Checked against next at c87c566.

Commits in this PR Where they landed
8757134, cc4d231, 1992cbd, 4b05b76, 79634ca, 011e97e (image batching) #1082 (2092a11)
c521b32, 18ae28b, 1123684, b6e731c (gone native home) #1104 (a26274d)
f9aa67d, 8b76b0c, 40ddb8b, 241e65d (HTTPS port over TIME_WAIT) #1111 (c0976cc)
0e90025, 353378e, 2497dce, cb83820, 5823c93, 89329ee (idle pool restart for a second share) #1119 (876a90f)
18e77cd, 3614377 (grow socket capacity in an idle or stopped pool: provider/socket_update.rs, the capacity journal, the native-pool-capacity model) Not on next

Next step: close this PR. After #1122 merges, open a clean branch from next with only 18e77cd and 3614377, add the budget check, and fix the P2 thread. Track it as a 5.1 item.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
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