Skip to content

Commit 6080e2c

Browse files
docs(agents): record the two lessons of the live-page cycle — the destination page is a surface (re-injection destroys bare hand-edits) and browser Buffer shims must return real Buffer instances — as [C21]/[C22] in the Debugging Breakthroughs index
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent be7a2e6 commit 6080e2c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ title to jump.
6565
| C19 | `core.autocrlf=true` poisons every hash-pinned surface `.gitattributes` doesn't shield | Windows working-tree refresh rewrote DDE fixture records LF→CRLF; repair = `rm` then `git -c core.autocrlf=false checkout -- <file>`; probe with `git ls-files --eol`, never grep `$'\r'` |
6666
| C20 | Node 22+/24 auto-detect ESM syntax; Node 18/20 don't — a package-less sandbox makes `.js` demos + multi-line `node -e "import …"` CJS on the Node 18 CI leg | dev box + Node 22 stayed green while Node 18 was red; pins: sandbox `examples/package.json` `{"type":"module"}` + `\s*`-tolerant ESM transform lookahead; verify with a real Node 18 binary first on PATH |
6767

68+
| C21 | Live-fixture destination page is a SURFACE: ship path and browser path must be the same folder; re-injection destroys bare hand-edits | silent two-place divergence while the browser boot kept working; one structural fix wiped by `git checkout` and re-applied by hand |
69+
| C22 | Browser Buffer shim statics must return real Buffer instances | near-miss: a plain Uint8Array `concat` result resolves `toString` to radix semantics — comma-separated decimal bytes instead of text |
6870
- [C1] **Multi-line plain scalar with `": "` kills the whole workflow (zero jobs)**: a `run:` value written as a plain (non-block) multi-line YAML scalar containing a JS literal like `console.error('health check failed: ...')` — the `": "` inside a plain scalar is unparseable → GitHub marks the run `failure` with **zero jobs built**. That zero-jobs conclusion IS the signature of an unparseable workflow file (not a failing step). Fix: any multi-line `run:` must be a real block scalar (`run: |` on its own line). Trap within the trap: a string-matching "validator" whose `||` fallback jumped to a fake parser reported PASS — only a real YAML parser or GitHub itself building the job proves the file parses (cost a push + a red run). Now enforced mechanically: `test/ci/workflow-yaml-contract.test.js` parses every `.github/workflows` file and the composite action with the real `yaml` parser (dev dep) plus an Actions schema walk — an unparseable or schema-deviant file fails the push locally with file+line naming, before GitHub ever sees it. Runs inside `npm run prepush` too (scripts/pre-push-check.mjs), the mechanical pre-push checklist built from the YAML/workflow lessons: workflows-parse [C1] · freeze-integrity [C2] · pin-eol-cover [C3] · no-skip-ci (the skip-token vortex) · repin-reachable (the rebase rewrite trap) · remote-fresh (the bot race, with the autostash remedy named).
71+
- [C21] **The live-fixture destination page is a surface, not just an output — ship path and browser path must be the same folder**: the injected demo pages boot their embedded engine in the browser from `packages/delivery/` via an import-map; authoring/previewing a copy from a different folder worked yet silently diverged from what the repo ships (the same fix would have to live in two places, and only one of them is reviewed). Rule: inject into and boot from the canonical `docs/` path only. Two derived traps: (1) **re-injection rewrites the page — a bare hand-edit (the injector writes records + shims + payload, never script content) is destroyed by regenerating or by `git checkout`; restoring a page from git means re-run `inject-demo-data.mjs` AND re-apply the hand-fix** (this cycle: a one-line bare `@coreguard/canonical` mapping fix was wiped once by checkout and re-applied manually); (2) the injector now carries an inject-time mapping check that fails the injection when the bare mapping is missing or mis-ordered, and `test/delivery/sdk-ref-page.test.js` boots the shipped page browser-equivalently outside the repo, so the divergence class is caught mechanically.
72+
- [C22] **A browser Buffer shim's static methods must return real Buffer instances, not plain Uint8Arrays**: the `node:http` shim exists only so `Buffer.concat(chunks).toString("utf8")` drains request bodies in-page. The near-miss: `static concat` returning a plain `Uint8Array` passes `instanceof Uint8Array` and `.set()` — until `.toString()` resolves to `Uint8Array.prototype.toString`'s **radix** semantics and emits comma-separated decimal byte lists instead of text. Same bug class for `Buffer.from`. Fix: `class Buffer extends Uint8Array` whose statics return `new this(...)`; `toString(enc)` overrides via TextDecoder (utf8 is the only handler surface; anything else throws), `from` covers string(utf8)→bytes (the artifactSha256 surface) and copy-from-Uint8Array. Locked by the browser-boot contract tests (`test/delivery/api-ref-page.test.js`, `test/delivery/sdk-ref-page.test.js`) that run the shims outside the repo on every push.
6973
- [C2] **Commit-anchored verification (4.2.6+)**: `validate-freeze.mjs` hashes `git show <gitCommit>:<path>` blobs, not disk bytes. Disk mode (`--disk`) is triage-only, prints "not evidence". Records without `gitCommit` fail COMMIT-UNANCHORED (historical included — correct). Editing a file whose bytes exist only in a future commit requires a **two-phase re-anchor**: commit phase 1, then point `gitCommit`/`postCommitRePins` at that hash in phase 2. Release entries are platform-dir relative; quarantine entries repo-root relative; repo-root files outside the platform dir use `../` prefixes (stripped by `treePath`/`repoRelPath` — the honesty test must mirror this or bare-name pins hash the wrong file).
7074
- [C3] **`git show HEAD:file` ≠ disk ≠ fresh-clone disk**: a pinned file outside every `-text` rule in `.gitattributes` is silently CRLF-rewritten on ANY fresh clone when `core.autocrlf=true` is set (system default on Windows) — the main working tree can hold LF bytes while a reviewer's pristine clone drifts and fails `--disk`. Always prove "clean-clone" claims from an actual fresh clone/`git -c core.autocrlf=false clone`, not from the dev disk. Any file newly pinned in a freeze record (including `../docs/…` — root-level pins outside the three `-text` trees) must be added to `.gitattributes` **and** the RC manifest must be rebuilt from a pristine `autocrlf=false` checkout (`scripts/build-rc-manifest.mjs` reads the disk, so generating on an autocrlf machine pins CRLF hashes that blobs don't match).
7175
- [C4] **Bilingual dashboard i18n architecture (the pattern that works)**: three defects killed the first attempt — (1) swapping only the first text node left Arabic tails around inline children (`.ltr`, badges); (2) the resolver `L()` was scoped inside an IIFE that ran after the views' initial render → `L is not defined` + dead toggle; (3) attr swaps targeted markup markers that didn't exist. The working design: **hoisted global `L()` prelude** at script top reading live language from `window.cgLang` at call time; **full `innerHTML` swap** per `[data-i18n]` element (text + inline children together, no tails); **views re-render on a `cg41:lang` CustomEvent**; dynamic strings stored as `{ar,en}` pairs resolved through `L()`; attrs applied by unique selectors, not markers. Dictionary generated by structural pairing (637/637 nodes) against the EN sister — never hand-maintained.

0 commit comments

Comments
 (0)