Skip to content

fix(adf): adf fmt keeps the U+FE0F form of standard decorations (#351) - #383

Merged
stackbilt-admin merged 2 commits into
mainfrom
fix/351-fmt-fe0f-decorations
Oct 18, 2026
Merged

stackbilt-admin merged 2 commits into
mainfrom
fix/351-fmt-fe0f-decorations

Conversation

@stackbilt-admin

Copy link
Copy Markdown
Member

Closes #351

Problem

parseAdf drops the U+FE0F variation selector after a section decoration, and formatAdf emitted the parsed form. The standard decorations for CONSTRAINTS (⚠️), FILES (🗂️) and TOOLS (🛠️) include U+FE0F, so adf fmt --write rewrote every scaffold's ⚠️ CONSTRAINTS header to the text-style ⚠, and adf fmt --check flagged freshly scaffolded files.

Fix (formatter side; the parser and AST are unchanged)

  • New canonicalDecoration(key, decoration) in @stackbilt/adf (types/decorations.ts): it returns STANDARD_DECORATIONS[key] when the given decoration equals it apart from U+FE0F, and otherwise the decoration as given.
  • formatAdf runs every explicit decoration through it. A null decoration still gets the standard one.
  • adf-text-patch.ts (the adf populate re-adds deleted default CONSTRAINTS bullets on every bootstrap #371/fix(populate): leave an edited CONSTRAINTS section alone (#371) #378 workaround) now calls the same helper, so the headers that populate adds are byte-identical to what adf fmt emits. The re-parse guard is unaffected because both sides parse without U+FE0F. One behaviour change: a non-standard text-style decoration (e.g. ⚙ NOTES) no longer gets a U+FE0F that adf fmt would then strip.
  • This repo's .ai/*.adf ⚠ CONSTRAINTS headers are rewritten to ⚠️, and .ai/.adf.lock is refreshed (adf sync --check passes).

Preserving a non-standard U+FE0F decoration exactly as the user wrote it would mean changing the parser/AST (parser_loc is capped), and every decoration comparison downstream would see the change. I left that out of scope.

Tests

  • formatter.test.ts: round-trip over every STANDARD_DECORATIONS entry, checked byte for byte. Each entry is also tested written both with and without U+FE0F and must format to the standard form. Further cases: non-standard decorations are kept, a decoration that is standard for a different key is not rewritten, and unit tests for canonicalDecoration.
  • adf-populate.test.ts: ADD_SECTION headers written by text-patch are fixed points of formatAdf(parseAdf(...)).
  • Full suite run serially: 1797 passed. The 3 failures are the known Windows-only ones (bootstrap bootstrap: phases 6/7 collect warnings without printing them; absoluteAiDirArg misses Windows paths on POSIX #307, context-refresh, serve-context).

Checks

  • adf fmt --check on .ai/*.adf: adf-dev, analysis, core, governance and state are clean. classifier.adf and manifest.adf still differ, but only in section order. typed-data-access.adf still differs because of a non-standard multi-word key SENSITIVITY TIERS. All three were non-canonical before this change, and none of the remaining differences involves a decoration.
  • Freshly bootstrapped scaffolds (default, worker and fullstack): after the fix, adf fmt output has the same lines as the file once order is ignored, so no decoration changes remain. --check still fails because the scaffold templates are not in canonical section order (CONSTRAINTS comes after CONTEXT/GUIDE, SYNC after ON_DEMAND). That was already the case before this PR, and the templates live in files other work is touching, so I left them alone.

CHANGELOG

Under [Unreleased] / Changed, with a note that adf fmt --write output changes for files with a bare ⚠ CONSTRAINTS, 🗂 FILES or 🛠 TOOLS header.

🤖 Generated with Claude Code

kovermier and others added 2 commits October 17, 2026 20:05
parseAdf drops U+FE0F after a decoration, and formatAdf emitted the parsed
form, so adf fmt --write rewrote the scaffolds' ⚠️ CONSTRAINTS (and 🗂️ FILES,
🛠️ TOOLS) to the text-style glyph. The formatter now emits the section's
standard decoration whenever the parsed one equals it modulo U+FE0F.

The text-patch writer (#371) uses the same canonicalDecoration helper, so the
headers populate adds are byte-identical to adf fmt output. This repo's
.ai/*.adf headers are rewritten to ⚠️ CONSTRAINTS; .adf.lock refreshed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use an own-property lookup so a prototype key such as 'constructor' cannot
reach String.replace on a non-string; spell U+FE0F as an escape instead of a
literal invisible character; correct the VENDORS comment; and correct the
CHANGELOG claim about adf sync (it hashes raw bytes, not the AST).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@stackbilt-admin
stackbilt-admin merged commit 64ff57d into main Oct 18, 2026
7 checks passed
@stackbilt-admin
stackbilt-admin deleted the fix/351-fmt-fe0f-decorations branch October 18, 2026 01:44
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.

adf fmt: decorations with U+FE0F (⚠️ CONSTRAINTS, 🗂️ FILES, 🛠️ TOOLS) don't round-trip

2 participants