Skip to content

test(watch-triage): restore lost marker-key injectivity and cross-bash regression tests - #73

Merged
adibirzu merged 1 commit into
mainfrom
fm/fm-window-key-injective-2878-final
Sep 14, 2026
Merged

adibirzu merged 1 commit into
mainfrom
fm/fm-window-key-injective-2878-final

Conversation

@adibirzu

Copy link
Copy Markdown
Owner

Intent

Recover and finish the preserved watcher marker-key work from task fm-window-key-injective-2878: restore the two lost watch-triage marker-key regression tests - that watcher marker keys are injective and filename-safe, and that a non-ASCII endpoint yields an identical key across bash generations - since the marker-key production code is already on fork main and a prior merge silently dropped only those two tests. Fork main is now fixed, so this work is rebased onto current fork main and CI re-runs for a genuine green. Do not skip the CI gate; do not expand scope onto the inherited Herdr regression (owned by fm-main-ci-failures); do not merge. [recorded 2026-09-13, key=herdr-ci-preexisting-red]

What Changed

  • Added test_window_marker_keys_are_injective_and_ignore_legacy_state to tests/fm-watch-triage.test.sh, verifying that distinct window endpoints differing only by punctuation (., _, /, :) derive distinct, filename-safe v2-<hex> marker keys, that the watcher persists a .hash-<key> file per derived key, and that pre-existing ambiguous legacy marker state (.hash-s_a_b / .count-s_a_b) is left untouched rather than trusted or rewritten.
  • Added test_window_marker_key_is_stable_across_bash_generations plus its marker_key_under_bash helper, confirming a non-ASCII window endpoint (s:café) produces an identical marker key when derived under the current bash, /bin/bash, and /usr/bin/bash, matching the byte-oracle expectation from watch_marker_key.
  • Registered both new test functions in the file's test-execution list alongside the existing test_procevent_marker_keys_are_injective entry.

Risk Assessment

✅ Low: The change is a minimal, verbatim restoration of two previously-dropped test functions into the existing test registry, touching no production code; both tests exercise real observable behavior (spawning the watcher process, invoking fm_window_marker_key across multiple real bash binaries, checking persisted state files) rather than asserting on source text, and the commit's provenance claims (source commits, dropped-in-merge commit) were verified to exist and match.

Testing

Confirmed via git diff --stat that this change only adds the two named tests to tests/fm-watch-triage.test.sh (no production code changed, matching the stated intent that the marker-key implementation was already fixed on fork main). Both restored tests were driven live: they pass against the current bin/fm-marker-lib.sh, and an adversarial mutation of the marker-key function proved the injectivity test genuinely detects a broken implementation rather than passing vacuously. No scope was expanded onto the Herdr regression, and no CI/push/merge phases were invoked — this report covers only the assigned test phase.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Watcher marker keys are injective and filename-safe across colliding endpoint spellings ✅ pass live test_window_marker_keys_are_injective_and_ignore_legacy_state run standalone: 'ok - colliding endpoint spellings receive distinct filename-safe markers and ignore ambiguous legacy state'
A non-ASCII endpoint yields an identical marker key across different bash generations ✅ pass live test_window_marker_key_is_stable_across_bash_generations run standalone: 'ok - a non-ASCII endpoint keeps one persistent marker key across bash generations'
Adversarial: a broken (non-injective) marker-key implementation is caught by the restored test rather than passing vacuously ✅ pass live After temporarily replacing fm_window_marker_key's hex-encoding with a collision-prone tr -cd filter, re-running the same test produced 'not ok - watcher did not persist the derived marker key v2-733a…
Evidence: Restored tests passing live
ok - colliding endpoint spellings receive distinct filename-safe markers and ignore ambiguous legacy state
ok - a non-ASCII endpoint keeps one persistent marker key across bash generations
EXIT=0
Evidence: Adversarial mutation caught by the injectivity test
not ok - watcher did not persist the derived marker key v2-733a612e62
EXIT=1

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Watcher marker keys are injective and filename-safe across colliding endpoint spellings ✅ pass live test_window_marker_keys_are_injective_and_ignore_legacy_state run standalone: 'ok - colliding endpoint spellings receive distinct filename-safe markers and ignore ambiguous legacy state'
A non-ASCII endpoint yields an identical marker key across different bash generations ✅ pass live test_window_marker_key_is_stable_across_bash_generations run standalone: 'ok - a non-ASCII endpoint keeps one persistent marker key across bash generations'
Adversarial: a broken (non-injective) marker-key implementation is caught by the restored test rather than passing vacuously ✅ pass live After temporarily replacing fm_window_marker_key's hex-encoding with a collision-prone tr -cd filter, re-running the same test produced 'not ok - watcher did not persist the derived marker key v2-733a…
  • Extracted and ran test_window_marker_keys_are_injective_and_ignore_legacy_state and test_window_marker_key_is_stable_across_bash_generations from tests/fm-watch-triage.test.sh as a standalone scenario script (bash tests/fm-watch-triage-scenario.test.sh, deleted after each run) — both pass against unmodified bin/fm-marker-lib.sh.
  • Adversarial mutation of bin/fm-marker-lib.sh's fm_window_marker_key (stripped hex-encoding, causing s:a.b/s:a_b collision) then re-ran the same scenario script — the injective/filename-safe test failed as expected ('watcher did not persist the derived marker key'), confirming the test is not vacuous. Reverted the mutation immediately after.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ssions

PR #18 (commits 4621615a, 26d1b380) added
test_window_marker_keys_are_injective_and_ignore_legacy_state and
test_window_marker_key_is_stable_across_bash_generations to prove
fm_window_marker_key (bin/fm-marker-lib.sh) is injective and produces
identical keys across bash generations for a non-ASCII endpoint.

The production code from those commits (fm_window_marker_key, window_key
wrapping it, the shared owner used by fm-supervise-daemon.sh and
bin/backends/herdr.sh) is already on main. The two regression tests
themselves were silently dropped when the PR18 branch was first merged
into main at 44c296b (an unrelated docs commit whose merge diff reverted
several fixtures back to the old colliding tr encoder and never carried
the two new test functions forward), even though bin/fm-marker-lib.sh's
header comment still names them as pinning tests.

Restore both tests verbatim from 88cce04 (the PR18 merge), verified
passing in isolation against current main's fm_window_marker_key
(including its byte-masking refinement) and against tests/wake-helpers.sh's
independent od-based watch_marker_key oracle.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014crY8agKaxBLcWeGkh2NZY
@adibirzu
adibirzu merged commit 5e85c0f into main Sep 14, 2026
15 checks passed
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