Skip to content

fix(jobs): cancellable, time-limited analysis jobs on the host (S6) - #91

Merged
aMonteSl merged 3 commits into
v1.2.1from
claude/project-thread-kvvyg6-job-runner
Nov 25, 2026
Merged

aMonteSl merged 3 commits into
v1.2.1from
claude/project-thread-kvvyg6-job-runner

Conversation

@aMonteSl

Copy link
Copy Markdown
Collaborator

Requested by Adrián · project thread

Closes #78 (epic #72, S6). Findings: EVO-2, EVO-3, EVO-4, EVO-17, HIST-7, HIST-9, DEPGRAPH-9, LAUNCHER-11.

What changes

  • Shared JobRunner (core/analysis/launch/jobRunner.ts) replaces SingleJobGate for historical comparison, project evolution and the dependency graph. A job has:

    • an id;
    • a state (queued, running, cancelled, failed, done);
    • a deadline: 30 min for evolution, 15 for comparison, 10 for the dependency graph.

    How it behaves:

    • Cancel aborts the signal the work runs under. The Python spawner (from S5) and the Git runner (execFile with signal) kill their child on Windows, macOS and Linux alike.
    • A result that arrives after a cancel is discarded.
    • The slot is held until the work unwinds, so no new job ever runs beside orphans. If the work ignores the abort, the slot is still released after a grace period.
  • Atomic start. Bridges call reserve*() synchronously, before reconcileSession. A "busy" answer goes to the requester only. The reservation is released if the preparation fails. The historical live-refresh flag is set only after success. This covers both the room messages and the LivePanel REST compare.

  • Cancel is not Clear.

    • New messages: project-evolution-cancel and historical-comparison-cancel, answered with *-cancelled.
    • Clear runs cancelAndWait() first.
    • An evolution revision becomes current only once all its files are written and the job is still wanted; otherwise its folder is removed.
    • Leaving the evolution mode no longer clears the movie.
    • UI: while a job runs, "Clear movie" reads Cancel, and so does "Compare".
  • Watchdogs. Each revision's analysis gets 5 min: a hung revision is killed and excluded from the movie. Each Git command gets 3 min and reports git-command-timeout or git-command-cancelled. A killed analysis is never recorded as a deterministic exclusion, which used to hide the commit from both pickers.

  • Late joiners. References replies carry the job state, so a client that joins mid-job renders it as running.

  • Export worker pool (EVO-17).

    • Per-file timeout of 2 min, retried once, then recorded as a failure.
    • Ready timeout raised to 30 s.
    • A worker that cannot start reduces the pool instead of failing the export.
  • projectEvolutionArtifacts.ts is split out of the service to keep it under 500 lines.

  • Docs and changelog: CHANGELOG [1.2.1] Fixed; PROJECT_EVOLUTION_XR.md and HISTORICAL_COMPARISON_XR.md updated.

Verification

  • npm test: 1,135 of 1,135 pass, tsc clean, ESLint 0 errors and 154 warnings (budget lowered from 155 to 154). The guardrail baseline was regenerated: functions over 80 lines 35→34, complexity over 10 51→50.
  • New test/analysis/jobRunner.test.cjs (8 tests): reservation, states, release, cancel reaching the async-context signal, deadline, late result discarded, grace release, withTimeout.
  • New S6 cases in gitHistoryServices.test.cjs, run against a real Git repository with a stub analyzer that "dies" on abort like the real spawner:
    • cancel kills, discards and keeps the previous movie, and no revision-2 is written;
    • Clear during a generation waits and leaves nothing behind;
    • a hung revision is killed by its watchdog and excluded while the movie finishes;
    • synchronous reservation, then cancel of a comparison;
    • bridge Cancel broadcasts to the room, or sends "nothing to cancel" to the requester only.
  • Harnesses pass: test:project-evolution-harness, test:xr-mode-harness, test:xr-harness.

Needs a manual check: the kill path with a real Python child. In tests it is covered by the stub; with real Python it relies on the S5 executePython kill-on-abort.

Not in scope: HIST-10 (stale "Loading comparison datasets..." status) and the dependency dataset revisions piling up (second half of DEPGRAPH-9).


Generated by Claude Code

A shared JobRunner (core/analysis/launch/jobRunner.ts) replaces
SingleJobGate for historical comparison, project evolution and the
dependency graph: job id and state (queued/running/cancelled/failed/done),
a deadline, a cancel that reaches the Git and Python children through the
async-context signal, late results discarded, and the slot held until the
work unwinds (bounded by a grace period).

- bridges reserve the job synchronously before their first await; "busy"
  goes to the requester only (LAUNCHER-11, HIST-9); the historical refresh
  flag is set after success
- project-evolution-cancel / historical-comparison-cancel: Cancel is not
  Clear; Clear cancels and waits; leaving the mode no longer clears the
  movie (EVO-2, EVO-4); a revision commits only once written and wanted
- per-revision watchdog (5 min), git command timeout (3 min), job
  deadlines (30/15/10 min); a killed analysis is never recorded as a
  deterministic exclusion (EVO-3, HIST-7, DEPGRAPH-9)
- references carry the job state so late joiners see it
- export worker pool: per-file timeout with one retry, ready timeout
  30 s, a worker that cannot start degrades the pool (EVO-17)
- projectEvolutionArtifacts.ts split out of the service (file size)
- tests: jobRunner.test.cjs, S6 cases in gitHistoryServices.test.cjs;
  CHANGELOG, feature docs; ESLint budget 155 -> 154

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FkKtAtQus8TVjhG9bhytC
@aMonteSl aMonteSl added tfm Adds the issue to the TFM board automatically. Do not remove area: extension VS Code extension host (TypeScript): commands, launcher, servers, services area: xr-scene Browser runtimes of the XR scenes and LivePanel (A-Frame/BabiaXR, templates/components) area: testing Test suites, harnesses, verification and inventories stream: xr-bugfix-1.2.1 Epic #72: review and fix the XR environment, shipped in 1.2.1 labels Nov 25, 2026 — with Claude
@aMonteSl aMonteSl self-assigned this Nov 25, 2026
@aMonteSl
aMonteSl merged commit 35b11fd into v1.2.1 Nov 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: extension VS Code extension host (TypeScript): commands, launcher, servers, services area: testing Test suites, harnesses, verification and inventories area: xr-scene Browser runtimes of the XR scenes and LivePanel (A-Frame/BabiaXR, templates/components) stream: xr-bugfix-1.2.1 Epic #72: review and fix the XR environment, shipped in 1.2.1 tfm Adds the issue to the TFM board automatically. Do not remove

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants