Skip to content

feat(runtime)!: load scoped workspace instructions - #5

Merged
lg2m merged 1 commit into
mainfrom
feat/dev-729-workspace-instructions
Aug 4, 2026
Merged

lg2m merged 1 commit into
mainfrom
feat/dev-729-workspace-instructions

Conversation

@lg2m

@lg2m lg2m commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • load bounded workspace-root AGENTS.md instructions before provider work, with CLAUDE.md as an absence-only compatibility fallback
  • teach the shared provider-neutral prompt to discover nested instructions root-to-leaf and to keep working through failures until completion is evidenced
  • persist the prompt version and deterministic selected-instruction hash before the provider starts
  • reject escaped, unreadable, non-regular, invalid UTF-8, and oversized selected instructions explicitly

Design

Workspace opening and root instruction loading share one bounded blocking hop. Instruction paths are resolved through the workspace capability, and the selected file is limited to 64 KiB. Nested scopes remain model-driven through the existing tools, so clients and adapters do not acquire competing instruction semantics.

Prompt identity is stored atomically as one validated object and exposed in run snapshots. Protocol version 6 and schema version 13 preserve legacy rows as an absent identity instead of guessing historical provenance.

Verification

  • cargo test --workspace
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo build --workspace
  • independent Task 5 specification and repository-standards reviews: clear
  • local warm-preparation benchmark, 100,000 iterations: main 29.153 us; branch 29.761 us (0.608 us / about 2%, near measurement noise and far below the 25 ms target)

Compatibility

This intentionally bumps the externally visible protocol from version 5 to 6 because run snapshots gain prompt provenance. Existing schema-v12 databases migrate to schema 13 with historical prompt identity left absent.

Linear: https://linear.app/lg2m/issue/DEV-729/runtime-load-scoped-workspace-instructions

Load AGENTS.md with an absence-only CLAUDE.md fallback before provider work, strengthen the shared completion prompt, and persist prompt provenance on each run.

Advance the wire protocol to version 6 for the new RunSnapshot prompt identity fields.

Refs DEV-729
@lg2m
lg2m merged commit f8847d2 into main Aug 4, 2026
2 checks passed
@lg2m
lg2m deleted the feat/dev-729-workspace-instructions branch August 4, 2026 18:43
lg2m added a commit that referenced this pull request Sep 9, 2026
…across store lanes (H20) (#9)

* chore(config): default the project model to xai/grok-4.6

* perf(session): wait for control admission instead of spinning on Overloaded

Run-lifecycle store calls made on behalf of already-admitted work
(cancellation reads, reserved starts, compaction load/start/commit,
reserved reloads, history search, every settlement path, the scheduler's
claim, prompt-identity, review-context and final-text reads) now use
`Priority::AwaitControl`, which waits for a `control_slots` permit. The
thirteen `sleep(1 ms)` retry loops that polled `Overloaded` from those
calls in `execution.rs`, `scheduler.rs`, and `subagents.rs` are deleted,
along with the 64-attempt history-search cap.

`Overloaded` remains the immediate answer for new client commands, feed
attachment, replay pages, snapshots, and child creation, so admission
control at the boundary is unchanged.

The scheduler's `reserve_next_run_at_depth` previously failed the whole
runtime when the control lane was full during a claim; it now waits.
Regression: `saturated_cancellation_read_and_start_wait_without_failing_
the_runtime`, `saturated_prepared_rejection_settles_and_keeps_priced_
accounting_known_zero`, and `saturated_reserved_reload_waits_after_auto_
compaction` saturate the real control lane (256 slots behind a held
worker) instead of injecting `Overloaded`; `lifecycle_store_calls_wait_
for_capacity_while_client_commands_are_rejected` pins the lane split at
the store. The injected-`Overloaded` test hooks that can no longer fire
are removed.

Part of H20 (speed-first plan, D8). No protocol, descriptor, or schema
change.

* perf(session): share the group commit with control writes and scheduler wakeups

Attribution of the eight-stream output service gap showed it is fsync
bound, not admission bound: each service round paid one group commit plus
one fsync per interleaved control write (`command`, `start_reserved_run`,
~3 ms each on ext4/NVMe), and the scheduler's claim read
(`reserve_next_run_at_depth`, issued after every settlement) closed almost
every forming group at one or two jobs.

Control-lane jobs now declare how they relate to a forming output group
(`worker::Joins`):

- `OutputGroup` (writes: commands, child creation/cancellation, run
  starts, settlements, prompt identity, recovery) join the group as
  savepoints and settle on its single commit. A control write dequeued
  when no group is open opens one, so consecutive writes share an fsync.
  The reply still waits for durability; persist-before-publish is
  unchanged.
- `Never` (client reads: snapshots, replay pages, cancellation reads)
  runs alone and closes a forming group, so it is answered right after
  that commit and never observes uncommitted state.
- `AfterGroup` (the scheduler's claim read) runs alone after the group
  commits but does not cut the group short; it is a wakeup, not a
  waiting client.

At most one read is held per group and no further control message is
dequeued once one is, so control-lane FIFO order is preserved.

Interleaved A/B, 30 pairs, eight-streams focused fixture, medians / p95:
completion 283.7/310.1 -> 209.8/228.4 ms; control latency upper bound
19.7/24.2 -> 15.9/18.4 ms; cancellation 25.9/29.8 -> 23.1/27.2 ms; output
service gap 24/28 -> 20/33 ms (27 of 30 samples 18-22 ms; three outliers
33-38 ms; a 15-pair same-binary A/A shows 20/21-23 ms). RSS unchanged.

Regression: `a_waiting_control_write_joins_the_output_group_and_a_read_
does_not`. Part of H20 (speed-first plan, D8). No protocol, descriptor, or
schema change.

* docs(plans): record H20 receipt, ADR-0011, and the fsync attribution

- ADR-0011: one commit discipline across store lanes; wakeups do not close
  groups. Supersedes D8's admission-only framing.
- architecture.md § Persistence: describe `Joins`, the two admission modes,
  and that commands, starts, and settlements share the stream's fsync.
- speed-first plan: status block, D8 collapsed to its receipt and remaining
  acceptance, task index (H20 in review, H21 next), Phase 6 acceptance
  progress, cancel polls moved to H22.
- Ledger: baseline, slice 1 A/B, the two probe attributions (fsync per
  control write; scheduler claim closing groups), and the H20 receipt with
  A/B and A/A tables. decisions-needed #5 resolved; root ADR allocation
  updated.
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