Skip to content

Freeze the install-ID file loader's behaviour in fixtures - #48

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/install-id-fixtures
Nov 21, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/install-id-fixtures

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

What was added

  • tests/install-id-fixtures/: 20 install-ID files (the shared corpus the other trace clients use, minus an empty directory, which git cannot hold) and expected.txt, which records what TraceClient.installIdFromFile does with each one. .gitattributes marks the directory binary so CRLF, BOM and non-UTF-8 bytes are stored exactly.
  • tests/install-id-fixtures.test.ts: fails if the *.id files differ from those expected.txt names; for every line, copies the fixture into a fresh temp directory, calls the loader, and asserts the outcome (loaded: that ID returned and the file untouched; replaced: a lowercase uuid4 returned and the file now exactly that plus \n; kept: file byte-identical and a uuid4 not in the file returned).
  • tests/version-consistency.test.ts: package.json's version must appear, exactly once each, in both root entries of package-lock.json, the trace-client X -- header and TRACE_CLIENT_VERSION = "X" in trace-client.ts, and the README's trace-client-js/X ( line. The API-shape test now compares TRACE_CLIENT_VERSION with package.json instead of the literal "0.5.0", so a version bump needs no test edit.
  • README: a short note that the fixtures are frozen once released.

No change to trace-client.ts or to the version.

Why

The fleet's release automation will check, before every future release, that each released fixture stays byte-identical, that each released loaded/kept line of expected.txt stays unchanged, and that this CI is green on the tagged commit. An ID a previous release stored must keep loading as the same ID, and a file the loader cannot read must never be overwritten.

Measured classification

Every line was measured with a throwaway harness against the 0.5.0 tag and then again at main (07f6660); both agree.

  • loaded: created, plain, trailing-newline, crlf, padded, tabs, uppercase-uuid, max-length, leading-blank-lines, first-of-two, invalid-lines-first (third.is-valid), comment-first (real-id), bom (bom-id), id-then-not-utf8 (good-id)
  • replaced: empty, whitespace-only, too-long, bad-chars, non-ascii, not-utf8
  • kept: none

Differences from trace-client-python (bold above):

  • bom.id is loaded as bom-id (Python: replaced): String.prototype.trim strips U+FEFF.
  • not-utf8.id is replaced (Python: kept): readFileSync(path, "utf8") decodes invalid bytes to U+FFFD instead of failing, so the file reads as holding no ID and is overwritten.
  • id-then-not-utf8.id is loaded as good-id (Python: kept), for the same reason.

So this client has no kept case in the corpus; the test still supports one.

Testing

npm ci && npm run typecheck && npm test passes locally on Node 22 (117 tests). Corrupting a fixture was checked to make the fixture test fail. The committed bytes were checked with xxd (crlf.id ends 0d0a, bom.id starts efbbbf).

drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

Adds tests/install-id-fixtures (20 ID files plus expected.txt, measured
against the 0.5.0 release) and a test that checks installIdFromFile
against every line, plus a version-consistency test. The API-shape test
now compares TRACE_CLIENT_VERSION with package.json instead of a literal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dmccoystephenson
dmccoystephenson merged commit 754f8d3 into main Nov 21, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the test/install-id-fixtures branch November 21, 2026 05:06
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.

1 participant