Skip to content

docs: tidy up documentation and fix scan behavior bugs#533

Merged
wizzomafizzo merged 8 commits intomainfrom
docs/agents-md-tuneup
Feb 9, 2026
Merged

docs: tidy up documentation and fix scan behavior bugs#533
wizzomafizzo merged 8 commits intomainfrom
docs/agents-md-tuneup

Conversation

@wizzomafizzo
Copy link
Member

Summary

  • Consolidate and fix inaccuracies across AGENTS.md, TESTING.md, developer guide, API docs, and media-titles.md
  • Fix 4 production bugs in pkg/service/readers.go discovered while writing scan behavior tests
  • Add 17 end-to-end scan behavior tests automating the full docs/scan-behavior.md manual checklist
  • Add thread-safe tracking to MockPlatform via syncutil.Mutex

Scan behavior fixes (readers.go)

  • Timer duration truncation: float32 exit_delay now preserves sub-second values via float64 multiplication instead of truncating through time.Duration cast
  • Reinsert detection: was comparing scanned token against active card instead of software token — reinsert after command card failed to cancel the exit timer
  • Timer goroutine leak: timedExit goroutine now exits via context cancellation instead of blocking forever on a stopped timer channel
  • Log typo: software token log was printing the state object instead of the token

Scan behavior tests (scan_behavior_test.go)

Runs the real pipeline (readerManager + processTokenQueue) end-to-end with only the platform boundary mocked. Uses clockwork.FakeClock for deterministic timer testing.

Tap mode (7 tests): removal doesn't close game, duplicate suppression, different card launches directly (no stop between), same card reloads after removal, command doesn't interrupt, manual exit resets state, manual exit with card doesn't relaunch

Hold immediate (3 tests): removal closes game, manual exit no relaunch, manual exit then remove no reload

Hold delayed (7 tests): removal closes after delay, reinsert cancels exit, different card launches immediately, command cards repeatedly reset countdown, manual exit no relaunch, manual exit then remove no reload, manual exit during countdown cancels

Cut ~35% (500 → 324 lines) by eliminating duplicate guidance stated in
multiple places, removing prose that restates linter rules, and merging
fragmented sections. Promotes Safety & Permissions to position 2, folds
Good Examples and Testing Quick Reference into their parent sections,
and trims commit guidelines. All high-value content preserved.
- Add zapScript field to media search and active media objects
- Fix media.active to return single object or null, not array
- Fix media.generate to document background indexing behavior
- Add readerId to token object and tokens.added notification
- Add readerId param to readers.write and readers.write.cancel
- Add readerId and driver fields to reader info object
- Fix mappings.new result from {id} to empty object {}
- Fix settings example readersScanMode from "insert" to "tap"
- Add health, inbox, inbox.delete, inbox.clear to method table
- Update launch endpoint to document /run/ (preferred) and /l/ (deprecated)
- Remove unused "running" notification, add inbox.added
- Update method count from 26 to 33
- Fix import paths to include /v2 module prefix
- Fix matcher functions attributed to fixtures instead of helpers
- Remove reference to non-existent fixtures.SampleSystems()
- Remove reference to non-existent ProcessTokenWorkflow function
- Update directory tree to match actual file layout
- Expand fuzz test file list from 5 to all 7 files
- Expand property test file list from 5 to all 11 files
- Replace overstated clockwork claim with specific file references
- Remove non-existent TDD Guard section from pkg/testing/README.md
- Replace pass-through description for Movie/Music parsers with actual
  step-by-step summaries matching current implementations
- Fix title extraction pipeline from 10 steps to 8 (year
  extract/re-append never existed in code)
- Fix complete example: SplitAndStripArticles preserves "Legend of",
  only strips leading "The"
- Align ParseGame with code: width normalization as pre-step, 9 numbered
  steps
- Expand TV show section from 2 bullets to 9 steps covering all
  supported episode formats
- List all 8 media types including pass-through types
- Add 2 undocumented special patterns (bracketless versions,
  edition/version word detection)
- Expand variant exclusion list to match code (all unfinished,
  unlicensed, and dump categories)
- Fix tag output values to match code (leading zeros stripped, periods
  normalized to dashes)
- Fix system ID examples to use canonical casing (SNES, Genesis, PSX)
- Remove unnecessary "ask before" items (task test, task build, govulncheck)
- Update Go version requirement from 1.23 to 1.25
- Fix Dockerfile path from scripts/linux_amd64/ to scripts/zigcc/
- Clarify deploy tasks are platform-specific
Automate the manual scan-behavior.md checklist as integration tests that
run the real pipeline (readerManager + processTokenQueue) with only the
platform boundary mocked.

Production fixes in readers.go:
- Fix timer duration truncation (float32 exit_delay now preserves
  sub-second values via float64 multiplication)
- Fix reinsert detection comparing against software token instead of
  active card (was checking wrong state)
- Fix timedExit goroutine leak (now exits via context cancellation)
- Fix log message printing state object instead of software token

Test infrastructure:
- Add clock injection (clockwork.FakeClock) to readerManager for
  deterministic timer testing
- Add syncutil.Mutex to MockPlatform for thread-safe tracking slices
@sentry
Copy link

sentry bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/service/service.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ests

filepath.IsAbs("/mock/roms/...") returns false on Windows because
there's no drive letter. Use filepath.Join(t.TempDir(), ...) to
construct paths that are absolute on all platforms.
@wizzomafizzo wizzomafizzo merged commit 2f8fd00 into main Feb 9, 2026
10 checks passed
@wizzomafizzo wizzomafizzo deleted the docs/agents-md-tuneup branch February 9, 2026 10:26
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