GeezerVison is showing github.com — server: fork service layers in one fork file (server.ts fork lines down); handoff contract files are fork files by scuttletoby · Pull Request #384 · scuttletoby/t3code
Conversation
What
The fork's own layers and wrappers that were wired inline in upstream's apps/server/src/server.ts move into one fork file, apps/server/src/fork/forkLayers.ts. server.ts now names each with one line, at the place the inline code was:
| server.ts line |
Was inline |
import * as ForkLayers from "./fork/forkLayers.ts"; |
7 fork imports (UsagePacer, UsageReadingsHistory, SlotGate, HeadlessUsageRefresher, ServerAutoUpdate, WorkAdmission, HoldWorkConnect) |
ForkLayers.layerRuntimeServices, |
usage pacer (with its history), slot gate, headless usage refresher in the runtime's core dependencies |
ForkLayers.layerRoutes, |
the /mcp requirement reads of the usage pacer and slot gate, and automatic updates |
Layer.effectDiscard(ForkLayers.startRemoteDelegation), |
the --hold-work hold around upstream's remote delegation follower start |
const layerWorkAdmission = yield* ForkLayers.makeWorkAdmissionLayer(config); |
the work admission gate and its held-boot warning |
ForkLayers.holdWorkAgentActivity(AgentAwarenessRelay.layer), |
the agent activity hold wrapper (+ its comment) |
Layer.provide(ForkLayers.holdWorkCloudLink(CloudLink.layer, ConnectReachability.layer)), |
the Connect hold wrapper (+ comment, 4 lines) |
Left in server.ts: the waits pr judge's layerPullRequestService provide (it uses server.ts's own local layer) and Layer.merge(layerActivation, layerWorkAdmission).
Also:
.github/fork-seams.json: server.ts's "pending" ceiling goes 39 → 10 (lower, never higher). packages/contracts/src/handoff.ts and handoff.test.ts join "forkFiles": they are fork-only (upstream has neither), so a pull request that changes them (handoff: HandoffService, size and idle triggers (HO2) #320) is no longer judged as touching an upstream file.
docs/fork/updates.md: a refused server layer line moves into apps/server/src/fork/forkLayers.ts.
Why
The seam check (#277) gives server.ts a fork-line ceiling a pull request may not grow; draft #320 needs two more wiring lines there and goes red. This fixes the shape instead of raising the ceiling, and makes each future fork layer a line in the fork file, not in server.ts. Upstream fit: thin add-on, smaller upstream diff, upstream's own lines and order unchanged.
After this merges, #320 wires HandoffService.layer in apps/server/src/fork/forkLayers.ts (e.g. in layerRuntimeServices) instead of server.ts. #320's branch is not changed here.
Behaviour: identical
- Same layers, same places:
layerRuntimeServices sits where the three services were in Layer.mergeAll (consecutive there), so the order is the same. Layer.mergeAll builds concurrently (effect 4.1.3 mergeAllEffect), and a nested mergeAll is concurrent too.
layerRoutes sits where ServerAutoUpdate.layer was, after upstream's follower; the two requirement reads move from just before the follower to just after it. They are pure service reads (Effect.asVoid), start nothing, and still put UsagePacer and SlotGate in the routes' requirements, so a server wired without them stays a type error.
makeWorkAdmissionLayer is called at the same point of layerMakeServer and is Effect.fnUntraced, so no new span; same store, gate, heldFromBoot and warning.
startRemoteDelegation and the two hold wrappers are the same code, moved.
Seam check
Run as fork-tests.yml runs it, on a merge of this branch into origin/main: node .github/scripts/fork-seam-check.cjs HEAD^1 HEAD → pass ("Fork lines in upstream files: only the pinned seams", exit 0; judged by main's list). server.ts fork lines counted from upstream (merge-base 820f620): 46 before, 10 after (main's file was already above its 39 ceiling from upstream; this PR sets the ceiling to the exact 10). Upstream mode with this branch's list reports nothing for server.ts or the handoff files.
Note (not this PR): upstream mode on main already reports other files over their ceilings or unlisted (cli/connect.ts, cloud/CloudLink.ts, process/agentScope.ts, settings panels, scopedSettings, packages/shared/package.json and others); fork-follow will refuse those.
Tests
effect-tsgo tsrs --noEmit (apps/server): no errors.
vp lint, vp fmt --check on touched files: clean. Commit hook: fmt, lint, knip:check passed.
vp test run (7 files, 48 tests, all pass): holdWork.boot.test.ts (boots the real t3 serve held, then normally, on a temp home: the full server layer graph with every moved layer), cli/server.holdWork.test.ts, cli/deferredImports.test.ts, cloud/holdWorkConnect.test.ts, serverRuntimeStartup.updateHold.test.ts, cliCompileCache.test.ts, packages/shared/src/forkDocs.test.ts.
node --test .github/scripts/fork-seam-check.test.cjs: 29 pass.
- No new test: the boot test already builds the whole server with these layers, and the usage pacer / slot gate wiring is a compile-time requirement.
State questions
- Restart / runs again: nothing new is stored. The work admission gate reads the same update-hold marker file under the T3 home as before, made at the same point of startup.
- A fork layer fails to build (stops half-way): same failure as before. The layers are the same values in the same
mergeAll/provide positions, so a failing UsagePacer, SlotGate, refresher or auto-update layer fails the server's layer build the same way; a failing update-hold store fails layerMakeServer at the same point (before activation, nothing else started).
- Old settings file, fork features off: unchanged; the layers read settings exactly as before (pacing, slots, waits, automatic updates off by default; the read-only usage refresh on at its default interval).
General vs project
General: a fork-only file for server wiring and two fork-file list entries. No project facts, paths, hosts or names.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…are fork files
The fork's layers and wrappers wired into upstream's server.ts (usage pacer and its history, slot
gate, headless usage refresher, automatic updates, the /mcp requirement reads, the --hold-work
work gate, remote delegation hold, agent activity and Connect hold wrappers) move into
apps/server/src/fork/forkLayers.ts. server.ts names each with one line, at the same place, so the
same layers build in the same order with the same provide/merge semantics. Its fork lines from
upstream go from 46 to 10; its "pending" ceiling in .github/fork-seams.json goes from 39 to 10.
packages/contracts/src/handoff.ts and handoff.test.ts are fork-only, so they join "forkFiles".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
lens: state verdict: SAFE (head 88fb398)
read at: 88fb398
State + correctness lens. No blocker or major finding. The move keeps the same layer values in the same mergeAll/provide positions. Effect 4.1.3 mergeAllEffect builds concurrently with one shared memo map, so putting layerRuntimeServices inside its own mergeAll changes neither build order, memoization nor which instance is shared. SlotGate.layer, which orchestration-v2/runtimeLayer.ts also provides, is still the same object, so there is still only one instance.
State question
- Restart with the update-hold marker present or stale:
makeWorkAdmissionLayer (forkLayers.ts:66) uses the same store (makeFileUpdateHoldStore(config.baseDir)), the same gate and the same heldFromBoot, and runs at the same point of layerMakeServer, before activation. serverRuntimeStartup.updateHold.test.ts and workAdmission.startPaths.test.ts are green.
- A fork layer fails or is missing: boot fails. It never runs without the gate. Mutations: drop
layerRuntimeServices → Service not found: t3/usage/UsagePacer, the server exits. Drop layerWorkAdmission from the Layer.merge (even though WorkAdmission is a Context.Reference with a pass-through default) → "--hold-work cannot hold this server, so it does not start". heldFromBoot: false → the same refusal.
- Old settings with fork features off: unchanged. The layers read settings exactly as before.
- Usage pacer history and slot gate across a restart: same store and same read point. The expression
UsagePacer.layer.pipe(Layer.provideMerge(UsageReadingsHistory.layer)) is unchanged; it only moved into a module-level constant, as before.
Seams
- Counted myself from the upstream merge-base
820f620e3d (= merge-base(upstream/main, origin/main) today): server.ts has 46 fork lines on main and 10 at this head. A ceiling of 10 is exact.
- On a local merge with current origin/main,
fork-seam-check.cjs HEAD^1 HEAD passes (exit 0). node --test fork-seam-check.test.cjs: 29/29.
- fork-follow: seam check from upstream refuses on main (11 files now, 37 more after #380) #385: upstream mode on main refuses 9 files today, not 11 (main has moved on). After this merge it refuses 8: only server.ts drops out. The handoff files are not counted in upstream mode either way, because upstream does not have them, and they raise no hidden-upstream-file hit.
- handoff: HandoffService, size and idle triggers (HO2) #320, simulated:
Merge this before #320's rewire. The forkFiles entries are read from the base, so they take effect only once this is on main.
Mutations
Run against holdWork.boot.test.ts and cli/server.holdWork.test.ts, plus the updateHold and startPaths tests for M7–M9.
| # |
Mutation |
Result |
| M1 |
drop ForkLayers.layerRuntimeServices |
RED: boot dies, UsagePacer not found |
| M2 |
drop ForkLayers.layerRoutes |
GREEN (gap, see minor 1) |
| M3 |
reorder: layerRoutes before the follower, layerRuntimeServices to the top of the mergeAll |
GREEN, as it should be (concurrent build) |
| M4 |
drop the --hold-work hold in startRemoteDelegation |
RED: followOnce ran held |
| M5 |
drop the HoldWorkConnect.layer wrapper |
RED: relay DELETE while held |
| M6 |
drop layerWorkAdmission from the provide |
RED: boot refuses |
| M7 |
holdWorkAgentActivity set to identity |
RED: the publisher started while held |
| M8 |
drop the HOLD_WORK_BOOT_MESSAGE warning |
GREEN (gap, see minor 2) |
| M9 |
heldFromBoot: false |
RED: boot refuses |
Baseline of the touched tests: 9 files, 68 tests, all green.
Findings (all minor; none blocks)
- minor,
apps/server/src/server.ts:850. Deleting ForkLayers.layerRoutes, (for example, in a sync-conflict resolution) passes the type check and every test here, and automatic updates are silently no longer wired. This gap already existed for the inline ServerAutoUpdate.layer, but that one line now also carries the /mcp requirement reads. Suggestion: the boot test's normal boot asserts something only ServerAutoUpdate.layer does (a log line or span), or a small test checks that layerRoutes provides it.
- minor,
apps/server/src/fork/forkLayers.ts:78. No test checks the held-boot warning; M8 stays green. This was already true before the move. Suggestion: the held boot in holdWork.boot.test.ts asserts that HOLD_WORK_BOOT_MESSAGE appears in the output.
- minor, naming.
ForkLayers.layerRuntimeServices (forkLayers.ts:32) and server.ts's own local layerRuntimeServices (server.ts:1305, ServerRuntimeStartup.layerWithOptions) are different layers with the same name in one file. The PR body tells handoff: HandoffService, size and idle triggers (HO2) #320 to wire "in layerRuntimeServices", which can be read as the wrong one. Suggestion: rename the fork export (for example layerCoreServices), or have the body say ForkLayers.layerRuntimeServices.
- minor/nit,
.github/scripts/fork-seam-check.cjs:393. The refusal hint names only forkSettings.ts. Adding "a server layer goes in apps/server/src/fork/forkLayers.ts" would point the next handoff: HandoffService, size and idle triggers (HO2) #320-style author there; the docs line in docs/fork/updates.md is right but sits only in the fork-follow step.
Docs: the rule added to docs/fork/updates.md is right, and the FORK_CHANGES row is accurate ("always", no change in behaviour).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
lens: equivalence verdict: SAFE (head 88fb398)
read at: 88fb398
Behaviour-equivalence + safety review. Read only. The head did not move. main is 3 commits ahead of this branch's base; none of them touch server.ts, and .github/fork-seams.json merges cleanly.
No blocker, no major. Two minor findings, both test gaps that existed before this PR.
1. Layer graph (server.ts before vs after, effect 4.1.3)
| Moved piece |
Provides / requires |
Position |
Verdict |
holdWorkAgentActivity |
It is HoldWorkConnect.agentActivityLayer itself (same function) |
First entry of layerRuntimeCoreDependenciesBase |
same |
layerRuntimeServices |
UsagePacer (+ provideMerge UsageReadingsHistory), SlotGate, HeadlessUsageRefresher |
The same consecutive slot. A nested mergeAll is still concurrent (mergeAllEffect: parallel scope, concurrency: layers.length). Same layer objects, so memoisation is unchanged. |
same |
startRemoteDelegation |
Same body: requires RemoteDelegation and WorkAdmission; returns early when heldFromBoot |
Same slot. Builds a lazy Effect.gen, so nothing runs at module load. |
same |
layerRoutes |
The two requirement reads plus ServerAutoUpdate.layer; same outer Layer.provide chain (ServerSelfUpdate etc.) |
Reads now come after the follower instead of before it |
equivalent (see below) |
makeWorkAdmissionLayer |
Same store, then gate, then Layer.succeed, then warning, in the same order; fnUntraced |
Same point in layerMakeServer, before activation |
same |
holdWorkCloudLink |
HoldWorkConnect.layer(CloudLink.layer).pipe(provideMerge(ConnectReachability.layer)), unchanged |
Same Layer.provide |
same |
The one shift is harmless. Both reads are Effect.asVoid service reads with no finalizer, and they sit in a concurrent mergeAll, so their order relative to the follower has no effect. AutoUpdate still comes after the follower. Mutation M9 (layerRoutes before the follower) passes the held phase unchanged. Nothing changed scope: no merge became a provide, and nothing provided to one part is now provided to all. The new module-load order (forkLayers pulls in autoUpdate, holdWorkConnect, RemoteDelegation and workAdmission earlier) causes no TDZ or cycle. The boot test runs from source (green in CI, Test Server 6), and deferredImports.test.ts passes.
2. Fail-closed
--hold-work from the first request on: the held boot logs all five held lines, has no RemoteDelegation.followOnce span, sends no relay request and no agent-activity publish, and leaves the seeded state untouched.
- A fork layer that fails to build also fails boot. M7 (admission build dies) and M8 (a dying layer inside
layerRuntimeServices) each make the server exit before it writes server-runtime.json. No server ever runs without the gate.
- A gate that is not held under
--hold-work refuses to start (M4).
- State: nothing new is stored. On restart the marker store is the same code at the same point. An old settings file with fork features off reads exactly as before. A server stopped during layer build has written nothing from these layers.
3. Seam list
- I recounted the fork lines in
server.ts against the upstream merge-base 820f620 myself: 46 on main, 10 on this head.
- Upstream mode with this branch's list reports nothing for server.ts or the handoff files. A ceiling of 9 is refused ("more than its ceiling"); 11 gets "lower it to 10". So 10 is exact.
packages/contracts/src/handoff.ts and handoff.test.ts are absent both at the upstream merge-base and on upstream main today.
- No other entry changes.
fork-seam-check.cjs HEAD^1 HEAD on a local merge with main passes. One extra fork line in server.ts is refused ("adds 1 more line than it removes").
node --test fork-seam-check.test.cjs: 29/29 pass.
Mutations (each against holdWork.boot.test.ts)
| # |
Mutation |
Result |
| M1 |
startRemoteDelegation ignores heldFromBoot |
red (RemoteDelegation.followOnce span in the held run) |
| M2 |
AgentAwarenessRelay.layer unwrapped in server.ts |
red (publisher started) |
| M3 |
holdWorkCloudLink without HoldWorkConnect.layer |
red (3 Connect spans in the held run) |
| M4 |
heldFromBoot: false |
red, fail-closed: server refuses to start ("--hold-work cannot hold this server") |
| M5 |
ForkLayers.layerRuntimeServices dropped from server.ts |
red: boot fails, Service not found: t3/usage/UsagePacer |
| M7 |
Work admission layer build dies |
red, server exits before ready |
| M8 |
Failing layer inside layerRuntimeServices |
red, server exits before ready |
| M5+M6 |
Services and the two /mcp reads dropped |
green (no guard, see minor 1) |
| M9 |
layerRoutes before the follower |
green in the held phase (expected: equivalent) |
Minor
- minor (test gap, existed before):
apps/server/src/fork/forkLayers.ts:39-46 and apps/server/src/server.ts:713,850. The /mcp reads guard only against dropping the services alone (M5 fails at type and runtime). If a sync resolution drops both ForkLayers.layerRuntimeServices, and ForkLayers.layerRoutes, from server.ts, the server boots and the held boot test stays green (shown by M5+M6). The /mcp pacing gate and slot gate are then silently off, and automatic updates are gone. The seam check only notes dropped lines under --after-rebase. Now that the reads, auto-update and the services are two lines in one file, a boot-test assertion would close this, e.g. that the slot gate and pacer are present or that automatic updates log their state.
- minor (test hermeticity, existed before, not this PR):
apps/server/src/holdWork.boot.test.ts:162-180. The spawned server reads the host's managed policy (/etc/t3code/policy.json). On a host whose policy turns Connect off, the held phase waits for HoldWorkConnect.* spans that never come and times out. Setting T3CODE_DEV_MANAGED_POLICY_PATH to a missing file in the child env would make it hermetic.
What I ran
holdWork.boot.test.ts: the held phase is green locally. The normal-boot phase did not finish on this host for reasons unrelated to the PR; it is green in CI on this head.
cli/server.holdWork.test.ts, cloud/holdWorkConnect.test.ts, serverRuntimeStartup.updateHold.test.ts, cli/deferredImports.test.ts: pass.
packages/shared/src/forkDocs.test.ts: 26/26 pass.
- Seam check and its unit tests as above.
- I did not run a typecheck locally; the CI typecheck on this head is green.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 17, 2026
This was referenced Nov 17, 2026
scuttletoby
added a commit
that referenced
this pull request
Nov 18, 2026
…wn); handoff contract files are fork files (#384)
* server: fork service layers in one fork file; handoff contract files are fork files
The fork's layers and wrappers wired into upstream's server.ts (usage pacer and its history, slot
gate, headless usage refresher, automatic updates, the /mcp requirement reads, the --hold-work
work gate, remote delegation hold, agent activity and Connect hold wrappers) move into
apps/server/src/fork/forkLayers.ts. server.ts names each with one line, at the same place, so the
same layers build in the same order with the same provide/merge semantics. Its fork lines from
upstream go from 46 to 10; its "pending" ceiling in .github/fork-seams.json goes from 39 to 10.
packages/contracts/src/handoff.ts and handoff.test.ts are fork-only, so they join "forkFiles".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* FORK_CHANGES: the server's fork layers in one fork file (#384)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby
added a commit
that referenced
this pull request
Nov 18, 2026
…wn); handoff contract files are fork files (#384)
* server: fork service layers in one fork file; handoff contract files are fork files
The fork's layers and wrappers wired into upstream's server.ts (usage pacer and its history, slot
gate, headless usage refresher, automatic updates, the /mcp requirement reads, the --hold-work
work gate, remote delegation hold, agent activity and Connect hold wrappers) move into
apps/server/src/fork/forkLayers.ts. server.ts names each with one line, at the same place, so the
same layers build in the same order with the same provide/merge semantics. Its fork lines from
upstream go from 46 to 10; its "pending" ceiling in .github/fork-seams.json goes from 39 to 10.
packages/contracts/src/handoff.ts and handoff.test.ts are fork-only, so they join "forkFiles".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* FORK_CHANGES: the server's fork layers in one fork file (#384)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Nov 20, 2026
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
…wn); handoff contract files are fork files (#384)
* server: fork service layers in one fork file; handoff contract files are fork files
The fork's layers and wrappers wired into upstream's server.ts (usage pacer and its history, slot
gate, headless usage refresher, automatic updates, the /mcp requirement reads, the --hold-work
work gate, remote delegation hold, agent activity and Connect hold wrappers) move into
apps/server/src/fork/forkLayers.ts. server.ts names each with one line, at the same place, so the
same layers build in the same order with the same provide/merge semantics. Its fork lines from
upstream go from 46 to 10; its "pending" ceiling in .github/fork-seams.json goes from 39 to 10.
packages/contracts/src/handoff.ts and handoff.test.ts are fork-only, so they join "forkFiles".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* FORK_CHANGES: the server's fork layers in one fork file (#384)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby
added a commit
that referenced
this pull request
Nov 28, 2026
…wn); handoff contract files are fork files (#384)
* server: fork service layers in one fork file; handoff contract files are fork files
The fork's layers and wrappers wired into upstream's server.ts (usage pacer and its history, slot
gate, headless usage refresher, automatic updates, the /mcp requirement reads, the --hold-work
work gate, remote delegation hold, agent activity and Connect hold wrappers) move into
apps/server/src/fork/forkLayers.ts. server.ts names each with one line, at the same place, so the
same layers build in the same order with the same provide/merge semantics. Its fork lines from
upstream go from 46 to 10; its "pending" ceiling in .github/fork-seams.json goes from 39 to 10.
packages/contracts/src/handoff.ts and handoff.test.ts are fork-only, so they join "forkFiles".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* FORK_CHANGES: the server's fork layers in one fork file (#384)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|