Skip to content

Agent isolation enhancements (W6/W7/W8)#2

Merged
MikeSchirtzinger merged 5 commits intomainfrom
brevity/agent-isolation
Mar 13, 2026
Merged

Agent isolation enhancements (W6/W7/W8)#2
MikeSchirtzinger merged 5 commits intomainfrom
brevity/agent-isolation

Conversation

@MikeSchirtzinger
Copy link
Copy Markdown
Owner

Summary

  • W7 (--metadata-only flag on jj describe): Writes operations to op_store but skips update_op_heads, so other workspaces see zero oplog staleness from metadata-only operations. Suppresses editor and prints operation ID for orchestrator tracking.
  • W8 (Read-only op heads loading): Adds read_op_heads_non_mutating() that reads op heads without acquiring locks or triggering merges. Includes ReadOnlyOpHeadsStore wrapper and RepoLoader::load_at_head_readonly() for guaranteed non-mutating head loads.
  • W6 (ForkedOpHeadsStore per-agent isolation): New store that copies parent op_heads at agent spawn time into a private directory — all agent writes stay private. Includes fork_from() / load() lifecycle and 3 unit tests.

Files changed

  • cli/src/commands/describe.rs--metadata-only flag
  • lib/src/forked_op_heads_store.rs — New ForkedOpHeadsStore
  • lib/src/lib.rs — Module registration
  • lib/src/op_heads_store.rs — Read-only op heads support
  • lib/src/repo.rs — Readonly loader methods

Test plan

  • Unit tests pass: test_fork_copies_parent_heads, test_agent_writes_do_not_affect_parent, test_load_roundtrip
  • Verify --metadata-only flag conflicts correctly with --editor/--stdin/--author
  • Confirm read-only loader errors on write attempts

MikeSchirtzinger and others added 3 commits March 13, 2026 01:45
W7 (--metadata-only flag on jj describe):
- Add --metadata-only flag to DescribeArgs (conflicts with editor/stdin/author flags)
- When set, writes operation to op_store via Transaction::write() but calls
  leave_unpublished() instead of publish() — skipping update_op_heads entirely
- Other workspaces see zero oplog staleness from metadata-only operations
- Suppresses editor when --metadata-only is set (no description change needed)
- Prints operation ID to stdout for orchestrator tracking

W8 (read-only op heads loading):
- Add read_op_heads_non_mutating() to op_heads_store.rs: reads op heads without
  acquiring locks or triggering merge operations; picks most recent by timestamp
  when multiple heads exist
- Add ReadOnlyOpHeadsStore wrapper: delegates reads to inner store, errors on
  any write attempt, returns no-op lock
- Add RepoLoader::load_at_head_readonly() for guaranteed non-mutating head load
- Add RepoLoader::as_readonly() to clone a loader with ReadOnlyOpHeadsStore

W6 (ForkedOpHeadsStore per-agent isolation):
- New file: lib/src/forked_op_heads_store.rs
- ForkedOpHeadsStore: copies parent op_heads at agent spawn time into a
  private directory; all agent writes go to the private store only
- fork_base file records the fork point for correct merge ancestry computation
- ForkedOpHeadsStore::fork_from() / load() for lifecycle management
- Register ForkedOpHeadsStore in StoreFactories defaults
- 3 unit tests: test_fork_copies_parent_heads, test_agent_writes_do_not_affect_parent,
  test_load_roundtrip — all passing
…sory)

- Fix import ordering in repo.rs (ForkedOpHeadsStore moved alphabetically)
- Fix rustfmt line wrapping in forked_op_heads_store.rs test
- Fix comment line length in repo.rs load_at_head_readonly doc
- Add #[allow(clippy::unnecessary_literal_bound)] on ReadOnlyOpHeadsStore::name()
- Fix broken doc link merge_back in forked_op_heads_store.rs
- Fix broken doc link ReadOnlyOpHeadsStore in repo.rs using full path
- Update CLI reference snapshot for --metadata-only and --set-* hox flags
- Update time crate to v0.3.47 (security advisory fix)
- Fix clippy::cloned_ref_to_slice_refs in test_agent_writes_do_not_affect_parent
…rebase

The main branch had code (brevity/mod.rs, test_forked_op_heads.rs) using
the old ForkedOpHeadsStore API (init, init_from, load→Self). Update to
the PR's authoritative API (fork_from, load→Result) and fix formatting
(alphabetical module ordering in lib.rs and runner.rs).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MikeSchirtzinger MikeSchirtzinger force-pushed the brevity/agent-isolation branch from 3da27d0 to 717f700 Compare March 13, 2026 05:52
@MikeSchirtzinger MikeSchirtzinger merged commit 3768cb5 into main Mar 13, 2026
28 checks passed
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