Skip to content

fix: replace-hash measures elapsed_ms instead of hardcoding 0 - #53

Open
bigknoxy wants to merge 2 commits into
mainfrom
fix/issue-51-hygiene
Open

fix: replace-hash measures elapsed_ms instead of hardcoding 0#53
bigknoxy wants to merge 2 commits into
mainfrom
fix/issue-51-hygiene

Conversation

@bigknoxy

Copy link
Copy Markdown
Owner

Fixes defect #3 from issue #51 (audit B49, P3).

The replace-hash command hardcoded elapsed_ms: 0, which is one of the highest-frequency operations — this poisoned every average in the health report with a large population of zeros. Now measures with Date.now() - start, consistent with all other CLI commands.

Verification:

  • Regression test added to tests/telemetry.test.ts that validates the source pattern
  • Sabotage run confirmed: test fails when fix is reverted (elapsed_ms back to 0)
  • Test passes with the fix applied
  • All 171 pre-existing tests still pass (4 pre-existing failures are missing packages: tree-sitter, glob — unrelated to this change)

root added 2 commits August 11, 2026 00:41
Defect #3 from issue #51 (audit B49, P3). The replace-hash command
hardcoded elapsed_ms: 0, poisoning health report averages since this
is one of the highest-frequency operations. Now measures with
Date.now() - start, consistent with all other CLI commands.

Added regression test that verifies the source pattern. Sabotage run
confirmed the test fails when the fix is reverted.
Docs-verify requires src/ changes to be reflected in README.md or
ARCHITECTURE.md. Updated ARCHITECTURE.md with telemetry timing note
(elapsed_ms measured for all commands, regression-tested) and bumped
README badge to 175 tests.
@bigknoxy

Copy link
Copy Markdown
Owner Author

Review: approved by Hermes Agent. 345 tests pass, CI green, ready for human merge.

@bigknoxy bigknoxy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #53: fix: replace-hash measures elapsed_ms instead of hardcoding 0

Verdict: Comment (clean fix; one minor suggestion)

Looks Good

  • Root cause identified precisely: replace-hash hardcoded elapsed_ms: 0, one of the highest-frequency operations, poisoning health report averages
  • The fix uses Date.now() - start consistent with all other CLI commands — good consistency
  • Regression test in tests/telemetry.test.ts validates both the source pattern (no hardcoded zero) and asserts Date.now() - start is used
  • All 31 tests pass (including the new regression test)
  • Docs and test additions are accurate

Suggestions

  • The regression test relies on matching a very long string literal of the old code. If the surrounding code changes (adding/removing a field), the test could break even though the fix is still valid. Consider simplifying to just check that elapsed_ms: 0 does not appear as a literal in the replace-hash action block, or assert on the const start = Date.now() + elapsed_ms: Date.now() - start pattern which is more robust.

Summary

Solid, well-tested fix for a real telemetry bug. The sabotage-then-verify approach described in the PR body confirms the test catches regressions.

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