Skip to content

fix(context): render rule and chain-segment source labels repo-relative - #6739

Draft
asto18089 wants to merge 2 commits into
codewhale-hq:mainfrom
Pinvou:upstream/context-repo-relative-labels
Draft

asto18089 wants to merge 2 commits into
codewhale-hq:mainfrom
Pinvou:upstream/context-repo-relative-labels

Conversation

@asto18089

@asto18089 asto18089 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

Draft / depends on #6737 — stacked on the file-name-labels PR; I will rebase and un-draft once it lands.

Summary

Chain-segment (<!-- scoped instructions: ... -->) and <project_rule source=...> labels carried absolute paths into the pinned system prompt, so a checkout move or recase changed the prompt prefix and could emit a spurious <context_update> history append (same root cause as the file-name-labels PR underneath, different label family).

Both labels are now rendered repo-relative (git-root-relative, forward slashes):

  • workspace-relative fallback for rules outside any checkout,
  • absolute spelling only for paths outside the label root (unreachable by construction),
  • context_chain_dirs gains a repo_root parameter so the chain bounds and the chain-segment labels derive from one and the same git walk.

Root-relative spelling (rather than bare file names) is deliberate: chain segments and rule files legitimately share the AGENTS.md basename across scopes, and the label exists to disambiguate them.

Adapted from the Pinvou fork (Pinvou/CodeWhale 7f04c907d).

Testing

  • cargo fmt --all -- --check
  • cargo clippy (touched crate, clean)
  • cargo test -p codewhale-tui --lib project_context:: — 76 passed; new tests pin repo-relative chain and rule labels, the workspace-relative fallback without a git root, the absolute escape hatch, and byte-identity of the whole system block for the same tree checked out at two different locations

Checklist

  • Updated docs or comments as needed
  • Added or updated tests where relevant
  • No CHANGELOG.md changes

No-Issue: Stable rule and chain-segment prompt labels across checkout moves (same family as #6737, which is merged).

qiuYliangM and others added 2 commits September 29, 2026 14:36
…labels

The <project_instructions source="..."> label carried the absolute path
of the loaded AGENTS.md. The label sits inside the pinned system prompt,
so loading an unchanged file from a moved or recased directory rewrote
the label and emitted a spurious <context_update> history append, and it
leaked the absolute project path into a provider-bound prompt label.

The label now reports the file name only, via a shared
project_instructions_source_label helper used by both
ProjectContext::as_system_block and the /context report's rendered
block (the report entry keeps the absolute path for operators). The
repo-constitution block, which sits in the same pinned region and always
resolves a fixed relative path, gets the same file-name convention; its
locator stays available via constitution_source_path and /constitution.

Directory identity is discoverable at runtime via the shell; the label
is an origin tag, not a locator. Regression tests pin byte-identity of
the instructions block for identical content loaded from two different
directories and forbid absolute paths in both provider-bound labels.

Adapted from the Pinvou fork (Pinvou/CodeWhale 102da17, PR #59) onto
the current project_context layout.

Co-authored-by: qiuYliangM <185303122+qiuYliangM@users.noreply.github.com>
Signed-off-by: asto18089 <asto18089@126.com>
Chain-segment ("<!-- scoped instructions: ... -->") and
<project_rule source=...> labels carried absolute paths into the pinned
system prompt, so a checkout move or recase changed the prompt prefix
and could emit a spurious <context_update> history append.

Render both labels repo-relative (git-root-relative, forward slashes),
falling back to workspace-relative for rules outside any checkout and
to the absolute spelling only for paths outside the label root
(unreachable by construction). The label root is computed once and
threaded through context_chain_dirs, so the chain bounds and the
chain-segment labels derive from one and the same git walk.

Regression tests pin repo-relative chain and rule labels, the
workspace-relative fallback without a git root, the absolute escape
hatch for unplaceable paths, and byte-identity of the whole system
block for the same tree checked out at two different locations.

Adapted from the Pinvou fork (Pinvou/CodeWhale 7f04c90, PR #70);
builds on the file-name labels from the previous commit.

Signed-off-by: asto18089 <asto18089@126.com>
@github-actions github-actions Bot added the contribution-gate Author not yet in .github/APPROVED_CONTRIBUTORS; a maintainer grants access with /lgtm label Sep 29, 2026
Hmbown pushed a commit that referenced this pull request Oct 2, 2026
… segments

Merges the head of #6739 (38e04c5, by asto18089) unmodified, so the
original commit keeps its author. The contributor's fork refuses
maintainer pushes (HTTP 403), so the merge with main that resolves the
import-block conflict in crates/tui/src/project_context.rs is carried here
instead of on their branch. No change to the contributor's code.

cargo test -p codewhale-tui --lib project_context: 88 passed; 0 failed
(run on the merge with main, before this merge with the wave; the wave's
two extra commits do not touch project_context). rustfmt clean on the
touched files; CI-policy clippy on codewhale-tui printed no warnings.

Refs #6739

Signed-off-by: CodeWhale Bot <bot@codewhale.net>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Hmbown pushed a commit that referenced this pull request Oct 2, 2026
Adds entries for what landed after 9626357: the experimental TypeScript
extension host (new in this release, off by default) with slash commands,
input validation, multi-entry plugins, plugin config and context, the
--enable/--disable passthrough and third-party notices; the Rust 1.89
floor; the deferred-tool first call; the Git 2.31 floor; idle task
workers; the task-store lock holder; the web search fallback and its time
budget; cancelled turns releasing input; /edit restoring the revision; the
oversized-paste notice; repo-relative labels (#6739); linked .codewhale
and owner-only log and lock files. The DeepSeek Harness version bullet
moves from Unreleased into 0.10.1.

Four existing bullets change wording: the PowerShell bullet gains the
inherit opt-out, the stall-watchdog bullet loses the sentence that the
dispatch wait still blocks input, the audit-log sentence is qualified as
Unix-only, and the Bun bullet's opening is reworded.

The 0.10.1 section's repeated headings (Security seven times, Fixed three)
are merged into one each; a byte-level compare shows every other original
bullet present verbatim and in its original order (187 bullets before,
207 after: 19 new, 1 moved).

scripts/sync-changelog.sh --check, check-contributor-credit.py,
check-versions.sh --range-audit-advisory and the release-body test pass.
No Rust change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: CodeWhale Bot <bot@codewhale.net>
Hmbown pushed a commit that referenced this pull request Oct 2, 2026
Preserve existing release bullets and add source-backed receipts for extension core/call and startup tier checks, the Rust MCP rollout boundary, partial terminal-kit workflow/working/verification/translation adoption, settled-frame and idle polling fixes, account selection, Windows sharing fixes, test-home isolation and public security changes. Correct the execpolicy pre-prompt limitation, point script readers to the JSON breaking note, and credit asto18089 for #6739. Fifteen credits include issue reporters; git-derived contribution history finds fourteen external contributors.

Verification: sync-changelog --check passed; contributor-credit found 14 contributors and all three credit surfaces present; check-versions --range-audit-advisory passed with workspace/npm/binary 0.10.1, lockfile synchronized and 38 linked issue receipts. Release parser verified unique 0.10.1 sections, 15 contributor/reporter credits and core/call + kit notes. Derived ignored website content shared by EN/ZH routes; only root and packaged changelog tracked. git diff --check passed. No Rust compilation, broad tests, deployment or publication.

Signed-off-by: CodeWhale Bot <bot@codewhale.net>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution-gate Author not yet in .github/APPROVED_CONTRIBUTORS; a maintainer grants access with /lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants