feat(omp-leaf-context): deliver leaf AGENTS.md on first tool result - #185
Open
systemfsoftware-maker wants to merge 7 commits into
Open
feat(omp-leaf-context): deliver leaf AGENTS.md on first tool result#185systemfsoftware-maker wants to merge 7 commits into
systemfsoftware-maker wants to merge 7 commits into
Conversation
Replaces the .claude deliver-leaf-agents-md PreToolUse hook with a non-blocking OMP extension: the governing leaf's AGENTS.md is appended to the first tool result touching that leaf, once per leaf per session
Cut the toolCallId record to the target only, consolidate error→string mapping into the executor, gate eligibility before the leaf read (repeat touches skip I/O), break the walk at the first existing leaf, harden the repos/ skip to the exact node, measure the inline threshold in bytes, and single-decode the ACL input
Single-source the dedupe/eligibility decision in the workflow cell (decide returns Select | Skip; content materialized only after a Select), collapse run-safe into one honest module, key pending targets by session:toolCallId, reject .. traversal in absolute targets, skip injection when the touched file IS the leaf, and add boundary/traversal/self-touch/append-contract tests
Capture the tool-result injection delivery shape, its invariants (emission not gate, regulate before read, append-never-replace, session-keyed state) and the effect-v4 API surface it required
…writes # Conflicts: # AGENTS.md
Restructure off the cell-role suffixes (acl/executor/handler/workflow/ run-safe) onto the clanka/effect-torch module shape: Target (decode + relativeToRoot), LeafContext (the eligibility decision as a Workflow.make from @systemfsoftware/effect-cell-types, one exhaustive dispatch over a closed classify), LeafContextExtension (the I/O sandwich: walk, decide, then read-and-append kept in the shell), and internal/ for the fs seam and runSafe. The decision gains a real error channel: an invalid governing-leaf path (absolute, ascending, repos/, or mis-suffixed) is refused as LeafContextError instead of a silent skip. Tests: 14 integration scenarios including the host-facing entry factory, plus workflow property laws over the closed classification
Re-key every gate onto the Workflow.make boundary and import edges: the sandwich plus workflow shape, the TaggedError channel rule audited per make site, the ACL1 decode rule audited across all source, and a failure-mode row that names the rename hazard. The plugins leaf PLG2 check now scans all source instead of the handler suffix glob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the deleted blocking Claude-format hook (
deliver-leaf-agents-md.ts) with a non-blocking, in-process OMP extension:@systemfsoftware/omp-leaf-context.For every tool call touching a path under a leaf (a
packages/*/AGENTS.md-governed directory), the first matchingtool_resultis appended with the governing leaf's content — once per leaf per session,repos/excluded, leaves up to 6144 UTF-8 bytes inlined and larger ones delivered as a pointer. The tool result's original content is preserved; the block is appended, never substituted. Handlers never block or revise tool calls; faults log and no-op, I/O failures during the walk or read surface asLeafContextErroron the error channel.Cells follow the repo's impure/pure/impure sandwich: the ACL decodes the target, the workflow cell (
decide) owns every skip reason (no governing leaf, self-injection when the touched file IS the leaf, already delivered this session) before any file I/O, and the executor reads the leaf only after aSelectverdict — a repeat touch costs one walk, zero reads.Changes
omp/plugins/omp-leaf-contextplugin (7 source cells, 13 Gherkin integration scenarios overeffect-memfs, oxlint + tsdown build, changesetminor)AGENTS.md: governance cell foromp/packages now names the plugin-delivered leaf and its gate.claude/hooks/deliver-leaf-agents-md.tsdeleted; settings entry removeddocs/solutions/architecture-patterns/omp-leaf-context-delivery-pattern.md: the delivery pattern, its invariants, and the Effect v4 API surface it requiredReview
Three review passes ran before this PR: ce-simplify-code (3 reviewers), ce-code-review (7 reviewers, 35 raw findings -> 17 merged), and ce-compound (learning captured). All mechanical findings are applied in the two fix commits: append-vs-replace contract test, traversal-escape hardening for absolute
..targets, single-sourcedecidewith content materialization afterSelect, run-safe collapse, session-scoped pending-call keys, threshold boundary tests (6144/6145 bytes, multibyte), and self-injection guard.One decision gate for the reviewer: Claude-format sessions no longer receive leaf governance (the hook was Claude-only); root
AGENTS.mddocuments the OMP gate. The OMP-only delivery is the approved plan's intent.ctx.cwd-rooted resolution and process-lifetime dedupe are documented deltas (residual risks in the review report).Verification
omp plugin link+ doctor,pnpm check:localall green on the final commitpackages/effect-atominjected the leaf; second touch under the same leaf clean; read underpackages/effect-memfsinjected its leaf;repos/oh-my-piread cleanReview artifacts:
/tmp/compound-engineering-0/ce-code-review/20260816-225852-26b3b0f0/(report.md, per-reviewer JSON).