feat(context): scoped context resolution + progressive disclosure of nested context files (GENAI-285) - #48
Open
obukhovaa wants to merge 7 commits into
Open
feat(context): scoped context resolution + progressive disclosure of nested context files (GENAI-285)#48obukhovaa wants to merge 7 commits into
obukhovaa wants to merge 7 commits into
Conversation
…fication Verified every design/spec/tasks claim against HEAD with a 4-agent pass: rebuilt both MODIFIED requirement blocks (validator blockers), dropped the nonexistent gitignore-library dependency from v1 discovery, corrected the patch-tool trigger (patch_text parsing via ExtractPathsFromCall), added multiedit to the trigger set, re-homed AgentContext/StepContext/DiscoveryConfig into the contextfile leaf, made disclosure state per-toolset (shared, deferSeq pattern) with DeferredWrapper kept outermost, sourced flow template tokens explicitly from f.ID/step.ID (NewAgent is context-free), fixed the budget-test claims (prompt_budget_test.go measures base prompts only), and refreshed all drifted line references. GENAI-285 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…truction (GENAI-285) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ection (GENAI-285) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n reads, close review gaps (GENAI-285) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n reads, fs-aware case folding (GENAI-285) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Applies the context-resolution and progressive-context-disclosure capability specs and the prompt-surface / flow-api deltas into openspec/specs/. GENAI-285 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Implements the
scoped-context-filesOpenSpec change (GENAI-285): workspace context becomes a function of who is running and what they are running, and nested context files become discoverable without paying for them upfront.What's in here
1. Scoped context resolution (
internal/contextfile, new leaf package).opencode.json/ markdown frontmatter) and flow steps declarecontext: { paths, mode, nested }; precedencestep > agent > globalwith compositionalreplace/appendsemantics; unknown mode WARNs (naming the agent/step) and fails safe toappend.${agent},${flow.id},${flow.step},${env.VAR}— with symlink-resolved workDir containment; escaping entries are rejected.sync.Map+singleflight) replaces the process-globalsync.Once; resolved blocks are byte-stable per session.contextfield is inheritable viainclude/extendswith zero merge-code changes (reflection-driven), and${flow.id}/${flow.step}are threaded explicitly fromrunStepthroughNewAgent(agent construction is context-free).2. Progressive disclosure of nested context files
<system-reminder>appended to the first successful tool result touching its owning directory (triggers: read/write/edit/multiedit/patch/grep/glob/ls; not bash, not delete). Outermost-first layering, once per session, per-session byte budget, subagent sessions isolated.cache_controlprefix stays intact (the load-bearing constraint of the whole design).3. Hardening (from the adversarial review rounds)
os.Root, Go 1.25) withO_NOFOLLOW|O_NONBLOCK, fstat-on-fd size checks, andio.LimitReader— a repo-committed symlink to~/.ssh/id_rsa(or/dev/zero, or a FIFO) can neither leak, OOM, nor hang, even under a check/open race (PoC-verified).</system-reminder>framing.os.SameFile) — no cross-matching of case-differing sibling dirs on Linux.Backward compatibility
With no
contextconfig and no nested files on disk the assembled prompt is byte-identical to the pre-feature build — pinned by unit tests and the e2e A/B check (including the# From:header quirks).Config surface
agents.<name>.context(also markdown frontmatter) and per-flow-stepcontextcontextDiscovery { enabled, maxFiles, maxDepth, maxFileBytes, maxSessionBytes }(default on; opt out per agent/step withcontext.nested: false)opencode-schema.jsonregenerated; viper round-trip test for the case-folding hazard per CLAUDE.md.Tests
make testgreen (fmt + race + coverage). Unit coverage across resolver/templating/discovery/manifest/wrapper/flow-inheritance, including mutation-verified seam tests for the factory→provider prompt threading.scripts/test/scoped_context.sh+ hermeticcmd/context-e2edriver (isolated mktemp sandbox config, HOME/XDG overridden): byte-identical backward-compat A/B across processes, manifest rendering, first-touch injection, second-touch dedup, and the agent-levelmode: replaceoverride that motivated the change — 15/15 checks.make test-e2e: all scripts pass except 3 live-model failures (attachments, deferred_tools_native, grep) reproduced byte-for-byte on base6d8f8c7— pre-existing, unrelated.OpenSpec
Change validated (
--strict), implemented task-by-task, and archived as2026-09-04-scoped-context-files; thecontext-resolutionandprogressive-context-disclosurecapabilities plusprompt-surface/flow-apideltas are applied toopenspec/specs/. The spec was first verified claim-by-claim against HEAD and corrected (13+ drifted/contradictory items, incl. an unimplementable ctx-key token-sourcing plan and a nonexistent gitignore-library dependency) before implementation started.Docs:
docs/context.md(new),AGENTS.md/CLAUDE.mdagent-fields entry,docs/flows.mdstep field,flow-creatorskill step schema.🤖 Generated with Claude Code