Skip to content

fix: default AI context exports to Base cache - #2615

Merged
codeforester merged 3 commits into
mainfrom
bug/2614-20261018-fix-keep-default-ai-context-exports-outside-project-director
Oct 20, 2026
Merged

codeforester merged 3 commits into
mainfrom
bug/2614-20261018-fix-keep-default-ai-context-exports-outside-project-director

Conversation

@codeforester

@codeforester codeforester commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Default AI-context exports currently use the caller's working directory, so exporting one project can leave a generated bundle in another checkout. Write default Markdown and Zip bundles under $BASE_CACHE_DIR/base/exports/<checkout-id>/<project>-ai-context.{md,zip} instead, using the shared cache resolver and canonical-root checkout ID.

Same-named checkouts and worktrees get distinct destinations. Re-exporting the same canonical checkout, including through a symlink or from a different working directory, updates its existing bundle. Explicit --output file and directory paths remain authoritative, including project destinations; --print and --list-files write no bundle.

Issue

Fixes #2614

Addresses the review finding about same-named checkout collisions.

Validation

  • The original default-destination regression failed for both formats and both caller locations before the cache change.
  • The new collision regression failed before the checkout isolation fix for both Markdown and Zip: the second export replaced the first bundle's bytes. It now preserves both bundles and verifies that a symlink alias reuses the original destination.
  • Focused Python tests: 17 passed, 13 subtests passed. Export-context BATS: 6 passed.
  • Real public CLI checks with two same-named projects preserve both formats outside both project directories.
  • Focused Pylint, ShellCheck, and git diff --check passed.
  • Full local Python suite: 1,833 passed. Runtime stable-compatibility check against origin/main passed.
  • The local bin/base-test shell run was stopped after hosted full-suite validation passed; 747 local shell cases had passed before the next case was interrupted. Full shell-suite evidence comes from CI.
  • Hosted validation on 62a60d8b: 24 successful checks; the optional hosted release-train readback was skipped. Python 3.10–3.13, Pylint, BATS, macOS smoke, integration, pinned and moving-provider Ubuntu source suites, security, compatibility, and branch policy passed.

Docs Impact

Command help and the command reference describe the checkout-specific destination, platform cache roots, and explicit output behavior.

AI Context Impact

Updated .ai-context/COMMANDS.md for the default export destination and checkout isolation.

Demo Impact

None.

@codeforester
codeforester requested a review from a team as a code owner October 18, 2026 15:47
@codeforester

Copy link
Copy Markdown
Collaborator Author

Automated review finding

cli/python/base_export_context/engine.py:142-143 (resolve_output_path): the new shared default export destination (base_cache_root()/base/exports/<project>-ai-context.{md,zip}) is keyed only on project_name, with no project-root/checkout disambiguation - confirmed directly: default_filename = f"{project_name}-ai-context.{extension}".

Two different checkouts (or worktrees) of a same-named project will silently overwrite each other's exported AI-context bundle. Running basectl export-context from checkout A writes to $BASE_CACHE_DIR/base/exports/demo-ai-context.md; running it later from checkout B (different .ai-context content) overwrites the same file with no warning, silently discarding checkout A's export. Before this PR, the default (Path.cwd()/demo-ai-context.md) was naturally isolated by directory, so this is a real regression introduced by centralizing the default path to a project-name-only cache location.

Everything else checked out clean - mkdir-parents handling, the base_cache_root() path convention, and docs/help-text/bats alignment are all correct.

Posted via Claude Code

@codeforester
codeforester merged commit 6c3808c into main Oct 20, 2026
25 checks passed
@codeforester
codeforester deleted the bug/2614-20261018-fix-keep-default-ai-context-exports-outside-project-director branch October 20, 2026 16:40
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.

fix: keep default AI context exports outside project directories

1 participant