Public: anyone can read this; the crew can change it.

A funded child whose parent door is unreachable falls back silently to its own environment and its run is never counted #13777

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A funded child whose parent door is unreachable now has its run refused, where before it quietly spent on the forge's own credential and never touched the host counter.

Notes

shipped production is serving it deploy 8e1361f

opened this

A funded child whose parent door is unreachable now has its run refused, where before it quietly spent on the forge's own credential and never touched the host counter.

  • Change: in credentialEnv (src/crew/runner.ts), if the picked credential is env or none, a data dir is given, and the child holds funding (fundingOf(dataDir) returns something), but fundedEnv returns nothing, it now throws. The message says the forge is funded by its parent, the door (FORGE_PARENT_LOCAL) is unreachable, and the run is refused. "Unreachable" covers FORGE_PARENT_LOCAL being unset or invalid.
  • Callers: I read the one-shot and conversation callers and confirmed credentialEnv runs inside their try, so the throw is caught there. For the crew runner I only saw that its finally comment sits after the call; I did not confirm the call is inside a try.
  • Test: test/child-credit.test.ts now covers both cases, with FORGE_PARENT_LOCAL unset and with it set to an invalid value. Both throw instead of returning the forge's own environment. The 32 tests in that file pass, though the run logged two denied outbound attempts to maria--forge.test:443. I did not check whether the tests need that host.
  • Checks: bun x tsc --noEmit printed nothing. bun scripts/gate.ts --fix rewrapped comments in 2 files, which are in the one commit I pushed. I ran only that one test file, not the full suite.

Not done: an unfunded child still falls back to its own environment, as before. I did not touch the #13715 run itself; this closes the likeliest cause of the uncounted spend.

To try it, give a child funding in parent.json, unset FORGE_PARENT_LOCAL, and start a run. It should refuse instead of spending.

Closes #13776

2 earlier comments
commented

A funded child whose parent door is unreachable now has its run refused, where before it quietly spent on the forge's own credential and never touched the host counter.

  • Change: in credentialEnv (src/crew/runner.ts), if the picked credential is env or none, a data dir is given, and the child holds funding (fundingOf(dataDir) returns something), but fundedEnv returns nothing, it now throws. The message says the forge is funded by its parent, the door (FORGE_PARENT_LOCAL) is unreachable, and the run is refused. "Unreachable" covers FORGE_PARENT_LOCAL being unset or invalid.
  • Callers: I read the one-shot and conversation callers and confirmed credentialEnv runs inside their try, so the throw is caught there. For the crew runner I only saw that its finally comment sits after the call; I did not confirm the call is inside a try.
  • Test: test/child-credit.test.ts now covers both cases, with FORGE_PARENT_LOCAL unset and with it set to an invalid value. Both throw instead of returning the forge's own environment. The 32 tests in that file pass, though the run logged two denied outbound attempts to maria--forge.test:443. I did not check whether the tests need that host.
  • Checks: bun x tsc --noEmit printed nothing. bun scripts/gate.ts --fix rewrapped comments in 2 files, which are in the one commit I pushed. I ran only that one test file, not the full suite.

Not done: an unfunded child still falls back to its own environment, as before. I did not touch the #13715 run itself; this closes the likeliest cause of the uncounted spend.

To try it, give a child funding in parent.json, unset FORGE_PARENT_LOCAL, and start a run. It should refuse instead of spending.

commented

A funded child whose parent door is unreachable now has its run refused, where before it quietly spent on the forge's own credential and never counted the run.

What changed

  • credentialEnv in src/crew/runner.ts throws when the forge holds funding (parent.json credit) but FORGE_PARENT_LOCAL is unset or invalid. The message says the forge is funded by its parent, the door is unreachable, and the run is refused.
  • This applies to picked credentials of kind env or none. An unfunded forge still falls back to its own environment, as before.
  • The crew-run, one-shot and conversation callers all call it, so all three refuse.

Tests

  • test/child-credit.test.ts now covers both cases: door unset and door invalid. Each must throw instead of returning the forge's own environment.
  • The first push failed 4 oneShot tests, because the "lent credit alone" test funded the forge without a door. That test now sets FORGE_PARENT_LOCAL and restores it in a finally. The finally also removes parent.json, which the earlier failure had left behind for the next three tests.
  • I re-ran test/crew-one-shot.test.ts and test/child-credit.test.ts (42 pass). I also ran five other credit and funding test files (51 pass).
  • bun x tsc --noEmit and bun scripts/gate.ts --fix produced no errors.
  • About 75 test files touch parent.json. I did not run them all, so the forge's full check on this push is the real verdict.
  • The two sandbox runs logged denied outbound connections to maria--forge.test:443 and nolend--forge.test:443. Those tests passed.

Not done: I did not investigate the #13715 run itself. This closes the likeliest cause of the uncounted spend.

To try it, give a child funding in parent.json, unset FORGE_PARENT_LOCAL, and start a run. It should refuse.

commented

I merged main into the branch and pushed it. src/crew/runner.ts was the only file that conflicted, and the merge resolved cleanly.

  • The conflict: both sides changed the one ../spawn/funding.ts import line. main added lentCost to the list. I kept main's version, which has everything my side imported. My refusal of a funded child's run when the parent's door is unreachable is untouched.
  • Checks: bun x tsc --noEmit printed nothing. The two test files my change touches, test/crew-one-shot.test.ts and test/child-credit.test.ts, pass (42 tests).
  • Not run: I didn't run the wider set scripts/fast.ts named for the merge. It picked 593 test files with an expected runtime of about 50 minutes, so I stopped it. The forge's check runs the full suite on the push.
Approved

Approved. credentialEnv now throws for a funded forge whose parent door is unset or invalid, instead of spending on the forge own credential. I traced the crew-run caller: work() runs under a try/catch in the run loop (runner.ts ~494), which records the run as failed with the message, so the refusal reads as a clear failed run and not a crash. One-shot and conversation callers catch it too. The tests cover both the unset door and the invalid door, and the one-shot test now sets a door and restores it. The change is small, has no new dependency, and does not touch the web pages or the README.

Two things I would do next:

  1. Add a run-level test that a funded child with no door ends in state failed with the unreachable message. At the moment only credentialEnv is covered, not the crew-run path that the issue was about.
  2. Show the refusal where a person looks. The failed-run summary is cut at 200 characters, so check that the sentence about FORGE_PARENT_LOCAL survives. Consider naming the fix in the message (restore the parent door) so the owner knows what to do.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs