Skip to content

feat: stories editing different regions of one file can run in parallel - #232

Open
Lotus015 wants to merge 1 commit into
mainfrom
feat/write-surface-regions
Open

Lotus015 wants to merge 1 commit into
mainfrom
feat/write-surface-regions

Conversation

@Lotus015

Copy link
Copy Markdown
Collaborator

Fixes #172

Summary

Write-surface ownership worked per file, so independent stories that edit different functions of one large module (verify.ts, orchestrate.ts, collective-board.ts) got serialized. This PR implements Option 1 (optimistic overlap) from the issue. It reuses the existing writes field, so no new PRD/story field has to be threaded through the TS planner schemas or the Rust Option<Vec<String>> round-trip:

  • Region syntax. A writes entry can be a bare path (the whole file) or path#symbol (one function, class or top-level const in that file). The new leaf module planning/domain/write-claims.ts parses entries and decides conflicts. Two stories conflict on a shared file when either one claims the whole file, or when both name the same region.
  • Path consumers see no change. writeSurfaceOf drops the region suffix, so the pre-write hooks, ownedElsewhere, trespass revert, Sentry, merge awareness, edge pruning and the Claude hook bridge still get plain paths.
  • Replan admission (runtime-replan.ts). overlapping_write_surface now uses the region-aware rule. If an added story and an active owner claim disjoint regions of a file, the story is admitted. For path-only plans the rejection reason is byte-identical to before. In the overlap facts, ownedFiles and remainingPaths now carry region entries, so a resubmitted tail keeps its regions.
  • Width evidence (disjointWidthEvidence). When the planner exceeds maxStories, siblings with disjoint regions count as disjoint.
  • Edge pruning is unchanged on purpose. A shared file still supports a declared dependsOn edge, so pruning stays as conservative as before.
  • Merge gate is unchanged. In collective mode, a real conflict goes down the existing prepareConflictRetry path: the attempt is preserved and the story is offered again from the latest integrated HEAD.
  • Agent disclosure. The spawn surface carries two new optional fields: regions (the story's own region claims) and shared (active peers that also write the file, excluding peers ordered with it by dependsOn). The write-surface gate prompt lists the story's regions and its co-writers, and tells the agent to stay inside its regions. surfaceKey includes both fields, so a running lease is told again when they change. The OpenAI in-process lane keeps them in sync across rule revisions. For path-only stories the surface shape is unchanged.
  • Planner guidance. The system prompt, the mode-contract rules and the progressive-planning instruction now explain path#symbol and the exception for one shared file. The overlap remedy section offers a 4th remedy ("claim the other regions") only when the colliding owner itself claims regions, where that remedy can actually work.

What remains (not in this PR)

  • Option 2 (symbol-level enforcement). The pre-write hook and trespass revert still check paths, not hunks. An agent that wanders outside its declared region is caught only by the merge (a conflict), not at the write.
  • Legacy mode still resolves merge conflicts with -X theirs, so there a wrong region guess is auto-resolved instead of rebuilt. That is the same as today for stories that share whole files, but it is a weaker fallback than the retry in collective mode.
  • Line ranges are not supported as regions. Lines shift between stories, so regions are named symbols only.
  • Option 3 (a planner-side foundation split of the monolith) is left for later.

Test plan

  • tsc -p packages/baro-orchestrator/tsconfig.json --noEmit is clean.
  • New test/planning/write-claims.test.ts covers parsing, normalization, a bare path absorbing its regions, the conflict matrix (disjoint regions, same region, whole file vs region), and width evidence for the three verify.ts siblings from the harness-3 run.
  • test/runtime-graph/runtime-replan-board.test.ts covers admitting a different region of an owned file; rejecting the same region, or a bare path against a region owner, with exact reason and facts; and rejecting a region against a whole-file owner.
  • test/execution/write-surface.test.ts covers the regions/shared surface and its gate prompt, excluding dependency-ordered peers from shared, path-only surfaces keeping the old keys, and surfaceKey changing with sharing.
  • test/planning/planner-prompts-repair.test.ts checks that the region remedy appears only when the owner claims regions.
  • The existing suites for write surface, replan, planner, gate registry, hook bridge, OpenAI story agent and planner adapters all pass (about 370 tests across the targeted files).
  • npm run test:fast: 1655/1659 pass. The 4 failures are timing/environment tests, unrelated to this change, and they fail or flake on origin/main on the same machine:
    • continuous-gate-runner fails deterministically on main.
    • run-architect-awake-budget flakes on main.
    • provider-ownership-manifest and command-timing pass when rerun in isolation.
  • collective-orchestrate and progressive-orchestrate: 28/29 pass. The one failure, "settles when the Surgeon decides before the Board receives a failed result", also fails deterministically on origin/main.
  • The full npm test run was not completed. On the shared machine, the slow acceptance suites (critic-evidence and similar) took more than 20 minutes per file under load.
  • No Rust changes, so cargo build / cargo test were not needed.

Generated with Devin

Write-surface ownership was per file, so independent issues touching
different functions of verify.ts were serialized by the replan gate and
the planner prompt. A writes entry may now name a region as path#symbol;
two active stories sharing a file are admitted when both name regions and
none collides, and the merge gate decides whether the guess was right.

Fixes #172

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

Write-surface ownership is per file, so independent issues that touch the same file are serialized even when they edit different functions

1 participant