feat(simulation): integrate infrastructure jobs and semantic scene editing
Integrate infrastructure preparation and qualified map delivery with local scenes. Add semantic editing, object provenance, survey caching and operator scene tools.
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
# Infrastructure queue and operator progress
|
||||
|
||||
The Core owns a persistent FIFO of whole-scene analysis requests; the connected
|
||||
Worker executes one request while holding the existing simulation GPU reservation.
|
||||
Editor preparation, route preparation and simulation retain their existing
|
||||
reservation policy. FIFO here applies to infrastructure analysis requests.
|
||||
|
||||
## Admission and identity
|
||||
|
||||
`InfrastructureJobs.request` binds the Gaussian world hash, collider, local-scene
|
||||
transform and exact provider closure. Repeated requests for an active world return
|
||||
the same job. An explicit recalculation supplies a 32-character lowercase hex
|
||||
request ID and creates an immutable generation. Repeating that ID is idempotent.
|
||||
Retries after failure or cancellation get a new generation. Ready map history is
|
||||
retained; only a validated successful publication replaces the latest map.
|
||||
|
||||
At most 32 queued/running/unreleased jobs are admitted. Overflow is explicit,
|
||||
never eviction. Monotonic persisted sequence numbers determine FIFO independently
|
||||
of directory order or wall-clock precision. Terminal rows still owning resources
|
||||
precede queued rows until cleanup releases them.
|
||||
|
||||
## Dispatch and termination
|
||||
|
||||
Selection, simulation reservation and claim execute under the same job-store lock
|
||||
as cancellation. A queued cancellation therefore cannot strand a reservation
|
||||
between selection and claim. A running cancellation is a request, not a release.
|
||||
The next Worker progress call is rejected, causing the existing stage runner's
|
||||
`finally` to stop/remove its exact owned container. Worker reconciliation then
|
||||
sends the authenticated release receipt. Errors and bounded stage timeouts follow
|
||||
the same cleanup path. Late publication after cancellation is rejected before any
|
||||
map write. Queue state survives Core restart; the Worker's persisted container
|
||||
marker supports reconciliation after Worker restart. A missing Worker or unknown
|
||||
cleanup state keeps the resource reserved; absence of telemetry is not proof that
|
||||
a container stopped.
|
||||
|
||||
## Operator API
|
||||
|
||||
- `GET /api/v1/ai-polygon/infrastructure-analysis/queue`: active jobs and position.
|
||||
- `GET /api/v1/ai-polygon/worlds/{world_id}/infrastructure-analysis`: current job.
|
||||
- `POST` to that world endpoint: `{force, request_id}` (body optional for first run).
|
||||
- `POST .../infrastructure-analysis/{key}/cancel`: world-bound cancellation.
|
||||
|
||||
Progress counts actual completed stages. The 90-stage all-class definition uses 87 historical stage durations, one
|
||||
qualified shared-semantic measurement (251.484 seconds on Smolensk 6.3), and
|
||||
two explicitly estimated missing stages. The old surface/layer pair is replaced
|
||||
by one shared stage; its two former weights are not counted again. A completed-prefix speed ratio adjusts the remaining estimate. Queue wait
|
||||
and source preparation are excluded and labeled as such. A stale heartbeat (>20s)
|
||||
suppresses ETA; elapsed time never synthesizes completion percentage.
|
||||
|
||||
## Acceptance
|
||||
|
||||
The focused backend tests cover 20-job FIFO, duplicate clicks, capacity, stale
|
||||
provider, ownership, cancellation/late-publication barriers, restart, dispatch
|
||||
races and measured progress. The frontend tests exercise 20 immediate clicks,
|
||||
late polling, cancellation/unmount and idempotent retry after an unknown response.
|
||||
`evaluation/queue_worker_canary.py` runs an isolated durable store on Worker006
|
||||
with real bounded Docker containers: exit 7, running cancellation, timeout,
|
||||
waiting cancellation and reopened persistence. It uses the exact Core atomic JSON
|
||||
writer extracted from its frozen source to avoid importing the unrelated Gaussian
|
||||
reader into the native Windows coordinator. No operator maps or jobs are modified.
|
||||
|
||||
## Control-plane disconnection
|
||||
|
||||
Infrastructure computation is owned by Worker. Lost TCP responses and HTTP 5xx
|
||||
responses during progress reporting retain the same running container and local
|
||||
stage chain. Pulses coalesce to the latest local progress; they never create
|
||||
a backlog or replay dispatch. On the explicit expired-session response, Worker
|
||||
registers the same instance and immutable capabilities, then retries the rejected
|
||||
observation. Cancellation, ownership changes and invalid payloads remain terminal.
|
||||
A missing heartbeat does not release the persistent exclusive GPU reservation.
|
||||
|
||||
After local validation produces `urban-map.json`, Worker records its SHA-256 in
|
||||
`infrastructure-active.json` before sending `complete`. Reconciliation delivers
|
||||
this immutable pending result before releasing ownership or polling another job.
|
||||
A lost success response is safe because Core accepts an identical completed map
|
||||
idempotently and rejects changed content. Retry cadence remains bounded when
|
||||
registration works but receipt delivery does not. A confirmed cancellation or
|
||||
publication rejection preserves the local evidence and releases after cleanup.
|
||||
|
||||
This guarantees continuity across Core/tunnel outages while the Worker process
|
||||
and Docker remain alive. It does not claim mid-stage recovery after a Worker/host
|
||||
crash: the existing orphan-container cleanup still applies. Previously failed
|
||||
jobs are immutable history and are not silently reclassified as completed.
|
||||
|
||||
Acceptance includes reconstruction of the actual Core router and persistent GPU
|
||||
queue, plus an isolated Worker canary with real Docker execution, TCP outages,
|
||||
lost completion acknowledgement, cancellation and FIFO advancement.
|
||||
Reference in New Issue
Block a user