Skip to content

feat(mapgen-studio): wire the shared tuner session through the daemon — one connection, health surface, scoped shutdown#1656

Merged
mateicanavra merged 1 commit into
mainfrom
design/tuner-daemon-wiring
Jun 12, 2026
Merged

feat(mapgen-studio): wire the shared tuner session through the daemon — one connection, health surface, scoped shutdown#1656
mateicanavra merged 1 commit into
mainfrom
design/tuner-daemon-wiring

Conversation

@mateicanavra

Copy link
Copy Markdown
Owner

The daemon resolves the studio runtime's Civ7TunerSession once and injects
it into the control-oRPC mount via endpointDefaults (the field is typed
Civ7DirectControlOptions — zero control-orpc package changes), so every
polling read multiplexes over the ONE managed connection. /healthz gains
the tuner block (consecutiveResponseTimeouts, gateOpenUntil,
wedgeSuspected); SIGINT/SIGTERM dispose the runtime scope first (graceful
FIN) then stop serving.

The live soak caught a race the units missed: connect() was only
sequentially idempotent — a page-load burst of ~13 concurrent reads each
dialed its own socket and leaked all but the last (13 stable ESTABLISHED
connections observed). Fixed at the root in @civ7/direct-control with
in-flight connect dedup + a concurrent-burst pin (390 package tests).

Live evidence post-fix (Civ7 in shell): exactly 1 established tuner
connection across 30s+ of app polling, zero CLOSED fds, readiness 'shell'
chip live, and on daemon stop the game releases its descriptor entirely
(only the LISTEN remains) — the wedge signature's exact inverse. Gates:
tsc, studio 204, mod 471, build + worker bundle, OpenSpec --strict.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

mateicanavra commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@mateicanavra
mateicanavra force-pushed the design/tuner-daemon-wiring branch from 6751f10 to e79176c Compare June 12, 2026 20:44
@mateicanavra
mateicanavra force-pushed the design/tuner-effect-session branch 2 times, most recently from e9a8435 to c0d8bde Compare June 12, 2026 22:30
@mateicanavra
mateicanavra force-pushed the design/tuner-daemon-wiring branch from e79176c to 8e6cfe6 Compare June 12, 2026 22:31
@mateicanavra
mateicanavra force-pushed the design/tuner-effect-session branch from c0d8bde to f58e2f6 Compare June 12, 2026 22:44
@mateicanavra
mateicanavra force-pushed the design/tuner-daemon-wiring branch from 8e6cfe6 to b537b6d Compare June 12, 2026 22:44
This was referenced Jun 12, 2026

mateicanavra commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

Merge activity

  • Jun 12, 10:46 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 12, 10:49 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 12, 10:49 PM UTC: @mateicanavra merged this pull request with Graphite.

@mateicanavra
mateicanavra changed the base branch from design/tuner-effect-session to graphite-base/1656 June 12, 2026 22:46
@mateicanavra
mateicanavra changed the base branch from graphite-base/1656 to main June 12, 2026 22:47
… — one connection, health surface, scoped shutdown

The daemon resolves the studio runtime's Civ7TunerSession once and injects
it into the control-oRPC mount via endpointDefaults (the field is typed
Civ7DirectControlOptions — zero control-orpc package changes), so every
polling read multiplexes over the ONE managed connection. /healthz gains
the tuner block (consecutiveResponseTimeouts, gateOpenUntil,
wedgeSuspected); SIGINT/SIGTERM dispose the runtime scope first (graceful
FIN) then stop serving.

The live soak caught a race the units missed: connect() was only
sequentially idempotent — a page-load burst of ~13 concurrent reads each
dialed its own socket and leaked all but the last (13 stable ESTABLISHED
connections observed). Fixed at the root in @civ7/direct-control with
in-flight connect dedup + a concurrent-burst pin (390 package tests).

Live evidence post-fix (Civ7 in shell): exactly 1 established tuner
connection across 30s+ of app polling, zero CLOSED fds, readiness 'shell'
chip live, and on daemon stop the game releases its descriptor entirely
(only the LISTEN remains) — the wedge signature's exact inverse. Gates:
tsc, studio 204, mod 471, build + worker bundle, OpenSpec --strict.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mateicanavra
mateicanavra force-pushed the design/tuner-daemon-wiring branch from b537b6d to abcc3ee Compare June 12, 2026 22:48
@mateicanavra
mateicanavra merged commit 6555cc3 into main Jun 12, 2026
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