Skip to content

Small cleanups: secret pattern lives in bugReport.ts; pruneArms is never called #406

Backlog

Description

@TMHSDigital

Summary

Two small items: the default secret pattern and the masking helper are defined in bugReport.ts but imported by six unrelated modules, and pruneArms in triggers.ts is exported but never called, so ended arms stay in the map for the life of the process.

Where

  • src/utils/bugReport.ts:31-48
  • src/utils/bugReport.ts:124-141
  • src/utils/recordingIndex.ts:26
  • src/utils/stepGuide.ts:17
  • src/utils/pipelineRun.ts:37
  • src/tools/indexRecording.ts:16
  • src/tools/stepGuide.ts:15
  • src/cli.ts:22
  • src/utils/triggers.ts:205-210
  • src/utils/triggers.ts:199

Details

DEFAULT_SECRET_PATTERN, DEFAULT_ERROR_PATTERN, MASK and maskSecrets are defined in the bug-report module, next to REPORT_FILES and resolveSource. The index (recordingIndex.ts:26, which says it is "pure except ..."), step_guide, pipeline redaction, index_recording and the CLI all import them from there. The CLI also imports MAX_ERROR_LINES. As a result, the pure search-index module pulls in bug_report's session-store and finalizer imports (bugReport.ts:17).

Also: pruneArms is never called, so ended arms stay in the map for the process lifetime

export function pruneArms(maxAgeMs = 24 * 3600_000, now = Date.now()) is documented as "Forget arms that ended long ago, so the map stays small". It has no caller in production code or tests: an export-reference scan over src/, scripts/ and evals/ found no use outside its own file. It came in with #336 (c3c4805). triggers.ts:199 also keeps an inline err instanceof Error ? err.message : String(err), the last one left after #314's errorMessage helper.

Impact

Changing the secret pattern changes masking in search_recording, step_guide, the pipeline's secret redaction and the CLI's --redact-secrets. Nothing in the module name says so, and a reviewer of a "bug_report" change will not expect that reach. Tests of the pure modules also load the session store.

Suggested fix

Incremental plan. Step 1: move the two patterns, MASK and maskSecrets to src/utils/secrets.ts, and re-export them from bugReport.ts. Step 2: point the six importers at secrets.ts. Step 3: remove the re-export. Tests first: the existing maskSecrets and secret-pattern tests stay green. Add one test asserting that the pipeline, index and step-guide defaults are the same constant, so the pattern cannot fork.

For "pruneArms is never called, so ended arms stay in the map for the process lifetime": Step 1: call pruneArms() at the start of each new arm, or in the code that lists arms. Step 2: replace line 199 with errorMessage(err). Tests first: arm, fire and fail an arm, advance now past maxAgeMs, and assert that a new arm call prunes the old one and that an armed entry survives.

Acceptance criteria

  • The secret pattern and masking helper move to their own module
  • pruneArms is called (for example when an arm ends or on a timer), or removed

Getting started

  • Relevant files: src/utils/bugReport.ts, src/utils/recordingIndex.ts, src/utils/stepGuide.ts
  • Run tests: npm test (also npm run typecheck and npm run lint); see CONTRIBUTING.md
  • If you change a tool's schema or description, run npm run docs

Filed by repo-audit/full-audit at f0e5ebd. Severity: low. Effort: S. audit-key: tech-debt|src/utils/bugReport.ts|DEFAULT_SECRET_PATTERN

Activity

  1. added
    good first issue
    priority: low
    effort: small
    tech-debt
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: smallgood first issuepriority: lowtech-debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions