wip(freestyle/acr): grounding & edit-tool fixes + ACR-compiler experiment

This branch's uncommitted WIP, committed together (entangled at file level).
Distinct pieces of work:

Freestyle QA fixes (this session):
- FileEditTool: pre-validate replace anchor in validateRequest — reject a
  missing/ambiguous target BEFORE the approval gate, mirroring read/write's
  file-not-found / read-before-write pre-checks. Shared not-found/ambiguous
  messages between validate and execute so they can't drift.
- PlanGrounder: add `scanned` flag; when no RepoMapComputedEvent was recorded,
  repoMapPaths is "unknown" not "empty workspace" — skip scope grounding
  (which proves a path ABSENT) so real paths (apps/server/**) aren't falsely
  rejected. Build-manifest check still runs.
- FreestyleDriver: wire scanned=(repoMap!=null); on plan rejection emit a
  session-terminal WorkflowFailedEvent so a rejected run reads FAILED, not the
  COMPLETED-lie (last verdict was the planning-phase WorkflowCompleted).
- ServerModule: resolve project-memory workspace root from the session's bound
  workspace (sessionWorkspaceRoot) instead of boot-static pm.repoRoot(), fixing
  the workspace-binding divergence (correx vs empty scratch dir). Retire tracked
  in Vikunja #266.
- LaunchRegistrationRaceTest: join registered jobs before asserting launchCount
  — computeIfAbsent returns the Job immediately but the fire-and-forget launch
  body lagged awaitAll (the 49-vs-50 flake).

ACR concept-compiler experiment (pre-existing WIP on this branch):
- ExecutionPlanCompiler/Model/PlanLinter, #264 needs-seam (sessionArtifacts),
  LSP diagnostics subsystem (LspDiagnosticEvents/Runner/Lsp4j), BootWorkspace,
  config surface, workflow prompts/schemas, orchestrator advance-don't-rerun.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-19 01:20:37 +04:00
parent 7b90944b61
commit 1b58bc325e
57 changed files with 1205 additions and 115 deletions
@@ -7,8 +7,8 @@ message; call `emit_artifact` and nothing else.
## Inputs available to you
- `analysis` artifact — structured findings from the analyst stage (goal, constraints,
risks, open questions).
- `dod` artifact — the fixed acceptance contract from the analyst. Every implementation and
review stage must consume it and must not widen it.
- Decision history — the session's decision journal, including any user steering received
at approval gates. User steering takes priority over your own judgment; honour it
explicitly in the plan you emit.
@@ -48,7 +48,7 @@ Emit a JSON object that validates against the `execution_plan` schema:
## Rules
**goal** — one sentence, derived from the analysis artifact and any user steering.
**goal** — one sentence, derived from the DoD artifact and any user steering.
**stages** — ordered list; each stage must:
- Have a unique `id` in `snake_case`.
@@ -60,6 +60,8 @@ Emit a JSON object that validates against the `execution_plan` schema:
llm-emitted kind.
- Declare `needs`: every upstream artifact id the stage's prompt references. Every id in
`needs` must be `produces`d by a strictly earlier stage.
- Every implementation and review stage must include the session-scoped `dod` artifact in
`needs`. The compiler also enforces this seam.
- Include `tools` per stage as it needs them, using only names from this set:
`file_read`, `file_write`, `file_edit`, `list_dir`, `shell`, `task_context`, `task_update`,
`task_search`. Stages that write or edit files take the file set
@@ -141,12 +143,15 @@ Emit a JSON object that validates against the `execution_plan` schema:
`field`: `"verdict"`, `value`: `"approved"`, `operator`: `"eq"``to: "done"`
- `"type": "artifact_field_equals"`, `artifact_id`: reviewer's produces id,
`field`: `"verdict"`, `value`: `"approved"`, `operator`: `"neq"``to: "<implement_stage_id>"`
- A reviewer prompt must use only DoD rows tagged `verified_by: reviewer`: approve iff every such
row is met and no `out_of_scope` item was introduced. It must cite failed criterion ids and may
not invent new requirements. Criteria tagged `gate` are already decided upstream.
- Every stage except the first must have an inbound edge from an earlier stage; every
stage must have an outbound edge. Unreachable stages fail to compile.
## Constraints
- Do not add stages, roles, or tools not justified by the analysis artifact.
- Do not add stages, roles, or tools not justified by the DoD artifact.
- Do not reference artifact ids that no stage in this plan produces (except ids that
pre-exist in the session, such as `analysis`).
- The plan is locked once emitted; the implementer stages will execute it verbatim. Be