fix(agent-context): recurse for nested plans in Python mtime fallback - #3757
Open
Quratulain-bilal wants to merge 1 commit into
Open
fix(agent-context): recurse for nested plans in Python mtime fallback#3757Quratulain-bilal wants to merge 1 commit into
Quratulain-bilal wants to merge 1 commit into
Conversation
The Python port's mtime fallback discovered plans with a one-level specs/*/plan.md glob, so a scoped layout created via SPECIFY_FEATURE_DIRECTORY (specs/<scope>/<feature>/plan.md) was missed when feature.json is absent — the fallback returned no plan and the managed context section omitted the 'at <plan>' line. The bash and PowerShell twins were already fixed to recurse (github#3024); the Python twin was left behind. Switch to specs.rglob('plan.md') with the same symlink-safe containment check the bash twin uses (resolve each candidate and confirm it stays within the project root before ranking by mtime), so a plan reached through a specs/ symlink pointing outside the project is not selected. Adds parity regression tests (vs bash and vs PowerShell) covering a nested specs/<scope>/<feature>/plan.md; both fail on the pre-fix one-level glob. Fixes github#3733
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes nested plan discovery parity in the agent-context Python port.
Changes:
- Recursively discovers
plan.mdfiles with symlink-safe containment. - Adds Bash and PowerShell parity tests for nested plans.
Show a summary per file
| File | Description |
|---|---|
extensions/agent-context/scripts/python/update_agent_context.py |
Implements recursive plan discovery. |
tests/extensions/test_update_agent_context_python_parity.py |
Adds nested-layout parity coverage. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Medium
Comment on lines
+184
to
+185
| return p.resolve().relative_to(root) | ||
| except (OSError, ValueError): |
Comment on lines
+188
to
+191
| # Recurse (rather than the old one-level specs/*/plan.md glob) so scoped | ||
| # layouts created via SPECIFY_FEATURE_DIRECTORY, e.g. | ||
| # specs/<scope>/<feature>/plan.md, are still discovered when | ||
| # feature.json is absent (#3024). Mirrors the bash and PowerShell twins. |
mnriem
requested changes
Jul 27, 2026
mnriem
left a comment
Collaborator
There was a problem hiding this comment.
Please address Copilot feedback and fix test & lint errors
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.
Fixes #3733
Problem
The agent-context Python port's mtime fallback discovered plans with a one-level glob:
So a scoped layout created via
SPECIFY_FEATURE_DIRECTORY—specs/<scope>/<feature>/plan.md, which sits two levels belowspecs/— was missed wheneverfeature.jsonis absent. The fallback returned no plan, and the managed context section omitted itsat <plan>line.The bash and PowerShell twins were already fixed to recurse in #3024 (their comments explicitly call out "rather than the old one-level
specs/*/plan.mdscan"); the Python twin was left behind, so the three drifted out of parity.Fix
Switch to
specs.rglob("plan.md")with the same symlink-safe containment check the bash twin uses: resolve each candidate and confirm it stays within the project root before ranking by mtime. This keeps a plan reached through aspecs/symlink pointing outside the project from being selected (the lexicalrelative_toalone would accept it).Tests
Adds two parity regression tests covering a nested
specs/<scope>/<feature>/plan.mdwith nofeature.json:@requires_posix_bash, runs in CI)Both fail on the pre-fix one-level glob and pass after. Verified locally on Windows: the PowerShell-parity test fails without the fix (Python omits the nested plan, diverging from PowerShell) and passes with it.