test(0.2): adversarial filesystem suite + 0.1.x schema migration fixture (Tracks 9.9/9.11)#150
Open
test(0.2): adversarial filesystem suite + 0.1.x schema migration fixture (Tracks 9.9/9.11)#150
Conversation
…ure (Tracks 9.9/9.11)
Two Track 9 (engineering hardening) deliverables. Both are pure
test additions — no behavior changes — and both raise the
adopter-trust posture against scenarios the existing test suite
didn't exercise.
Track 9.9 — Adversarial filesystem suite
New `internal/analysis/adversarial_fs_test.go` exercises the
analyzer against 8 deliberately weird filesystem inputs that
real repositories surface but synthetic fixtures usually don't:
- binary file with .ts extension (misnamed asset / compiled
artifact)
- oversize source file (~2MB; tests size-skip threshold)
- UTF-8 BOM at file start (Windows-edited files)
- NUL bytes mid-content (transpiler / minifier output)
- 0-byte test file (developer commits before filling in)
- nested .git directories (submodules) — load-bearing
assertion that .git contents never leak into inventory
- 50-level deep directory nesting (skipped on Windows due
to path-length limits)
- 180-char filename (long-but-legal, tests filesystem
assumptions)
Contract: every test asserts Analyze completes without panic /
hang / OOM. Some tests additionally assert that legitimate
inputs survive (binary-poisoned tree must not lose the real
test file; nested .git contents must never leak).
Skipped (out of scope, with rationale):
- Symlink loops: behavior differs across platforms; add
per-platform tests when an adopter hits one.
- Permission-denied: hard to set up portably; manual smoke
verifies the walker silently skips.
Track 9.11 — Schema migration fixture
New `internal/models/testdata/snapshot_v0_1_x_legacy.json` —
hand-crafted JSON snapshot in the shape that 0.1.x actually
wrote: schema version field absent, no SignalV2 envelope, no
UnitID on code units, simpler snapshotMeta.
New `internal/models/migrate_fixture_test.go` with 3 tests:
- LoadLegacyFixture — load via Unmarshal + migrate via
MigrateSnapshotInPlace; assert SchemaVersion stamped,
generatedAt backfilled, UnitIDs backfilled (incl. parent-
qualified case), compatibilityNotes in Metadata
- LegacyFixtureDataPreserved — every field present in fixture
(frameworks, test files, signals) survives intact through
migration
- FixtureRoundTripsViaJSON — migrated snapshot can be
re-serialized + re-loaded + re-migrated near-idempotently
(regression guard for the byte-identical determinism
contract that `terrain analyze --write-snapshot` depends
on)
Verification: 8 adversarial-FS tests + 3 fixture migration tests
pass; full Go test suite green; no regression in existing tests;
make docs-verify clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Terrain AI Risk Review
Decision: PASS — AI surfaces are covered. |
[PASS] Terrain — Safe to merge
Pre-existing issues (2)
Recommended tests2 test(s) with exact coverage of 0 impacted unit(s).
Limitations
Generated by Terrain · Targeted Test ResultsTerrain selected 2 test(s) instead of the full suite.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two Track 9 (engineering hardening) deliverables. Both are pure
test additions — no behavior changes — and both raise adopter-
trust posture against scenarios the existing suite didn't
exercise. Both are explicitly post-0.2.0-blocking per the plan
but are safe to land now since they're additive.
exercising the analyzer against deliberately weird filesystem
inputs: binary file with .ts extension, oversize source, UTF-8
BOM, NUL bytes, empty test file, nested .git directories, deep
nesting, long filename.
shape JSON fixture + 3 tests that load + migrate it through the
current code, asserting data preservation and round-trip
idempotency.
What changed
New files (additive only):
internal/analysis/adversarial_fs_test.go— 8 adversarial FStests (one skipped on Windows due to path-length)
internal/models/testdata/snapshot_v0_1_x_legacy.json—realistic 0.1.x snapshot fixture
internal/models/migrate_fixture_test.go— 3 fixture-drivenmigration tests
What's NOT covered (with rationale)
follows; macOS errors; Windows may not have symlinks). Add
per-platform tests when a real adopter hits one.
without root. Manual smoke confirms the walker silently skips.
These exclusions are documented in the test file's package
comment so future contributors know the boundary.
Test plan
go build ./...cleango test ./internal/analysis/...— 8 new adversarial-FStests pass + existing tests unaffected
go test ./internal/models/...— 3 new fixture tests +existing migrate tests all green
go test ./...— full suite greenmake docs-verifypassesPlan tracker
Closes Track 9.9 + 9.11. Track 9 remaining: 9.1-9.6, 9.7
(truth-verify), 9.8 (docs-linkcheck), 9.10 (memory bench), 9.12
(field tier docs). Per the plan, all of Track 9 is explicitly
post-0.2.0-blocking; this PR is safe to land in either the 0.2.0
or 0.2.x window.
🤖 Generated with Claude Code