Skip to content

[code-simplifier] refactor: dedupe mention-alias normalization and JSONL iteration helpers in safe-output scripts - #49462

Merged
pelikhan merged 2 commits into
mainfrom
code-simplifier/js-safe-outputs-dedup-20260801-918df80d3b22b9c8
Aug 1, 2026
Merged

[code-simplifier] refactor: dedupe mention-alias normalization and JSONL iteration helpers in safe-output scripts#49462
pelikhan merged 2 commits into
mainfrom
code-simplifier/js-safe-outputs-dedup-20260801-918df80d3b22b9c8

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Low-risk readability simplifications in three actions/setup/js/*.cjs safe-output scripts identified as recently-changed (via .github/aw deterministic candidate list) and validated by scope/scout sub-agents. No behavior changes.

Files simplified

  • actions/setup/js/add_comment.cjs: extracted a shared normalizeMentionAliases() helper to remove an identical alias-trimming/filtering pipeline that was duplicated between preResolvedMentionAliases and configuredMentionAliases in main().
  • actions/setup/js/add_reaction.cjs: replaced Object.prototype.hasOwnProperty.call(REACTION_MAP, reaction) with the simpler, equally-safe reaction in REACTION_MAP membership check.
  • actions/setup/js/ai_credits_context.cjs: iterateAuditEntries() now delegates to the existing iterateJSONLFiles() helper instead of re-implementing the same file-read/parse/accumulate loop, removing ~20 duplicated lines.

Source references

  • Candidate files were sourced from the code-simplifier's deterministic source-files.json list (built from PR dispatch_workflow: support per-call ref override for runtime branch targeting #49408, the only merge in the scan window).
  • recent-prs.json / recent-commits.jsonl show no other in-scope PRs touching these files during the window; simplification opportunities were scoped by scope-filter and detailed by simplification-scout sub-agents (both claude-haiku-4.5) rather than a full manual re-read of every candidate file.

Validation

  • npx vitest run add_comment.test.cjs ai_credits_context.test.cjs add_reaction.test.cjs add_reaction_and_edit_comment.test.cjs275 passed, 0 failed.
  • make lint → 0 errors; 0 new warnings introduced in the changed files (all 161 warnings are pre-existing, in other files).
  • make build → succeeds.
  • make test-unit → no changed Go files, so Go unit tests were (correctly) skipped; JS behavior is covered by the vitest run above.

Token-efficiency notes

  • Reused the deterministic pre-computed source-files.json / recent-context.json / history-summary.json inputs instead of re-querying GitHub.
  • Delegated exploratory scoping (scope-filter) and opportunity scouting (simplification-scout) to lightweight claude-haiku-4.5 sub-agents to avoid loading and reasoning over all 20 candidate files in the main context; only files flagged simplify:yes were read/edited directly.

Generated by 🔧 Code Simplifier · auto · 94.1 AIC · ⌖ 8.86 AIC · ⊞ 9.1K ·

  • expires on Aug 1, 2026, 8:29 PM UTC-08:00

- add_comment.cjs: extract normalizeMentionAliases() to remove duplicated
  alias-trimming pipeline between preResolvedMentionAliases and
  configuredMentionAliases
- add_reaction.cjs: simplify REACTION_MAP membership check to use the
  'in' operator instead of Object.prototype.hasOwnProperty.call
- ai_credits_context.cjs: reuse iterateJSONLFiles() inside
  iterateAuditEntries() instead of duplicating the file-read/parse loop

No behavior changes. Validated with targeted vitest suite (275 tests
passed across add_comment, ai_credits_context, add_reaction, and
add_reaction_and_edit_comment test files), make lint (0 new
warnings), and make build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review August 1, 2026 04:33
Copilot AI review requested due to automatic review settings August 1, 2026 04:33
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #49462 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors safe-output JavaScript helpers to remove duplicated normalization and JSONL iteration logic.

Changes:

  • Extracts mention-alias normalization.
  • Reuses the shared JSONL iterator.
  • Simplifies reaction validation, but introduces inherited-property acceptance.
Show a summary per file
File Description
actions/setup/js/add_comment.cjs Deduplicates mention-alias normalization.
actions/setup/js/add_reaction.cjs Changes reaction membership validation.
actions/setup/js/ai_credits_context.cjs Delegates audit parsing to the shared JSONL iterator.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread actions/setup/js/add_reaction.cjs Outdated
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Clean refactor — no issues found. The extracted normalizeMentionAliases helper correctly deduplicates the repeated inline logic, the reaction in REACTION_MAP idiom is safe for a plain object literal, and delegating iterateAuditEntries to iterateJSONLFiles with a single-element array is behaviorally equivalent.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 15.5 AIC · ⊞ 5.3K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Verdict: Approve — no blocking issues

Three small, behavior-preserving dedup refactors (mention-alias normalization helper, in operator swap, JSONL iteration delegation). Verified each against the pre-refactor logic; all are equivalent.

Analysis notes
  • normalizeMentionAliases() in add_comment.cjs is byte-for-byte equivalent to the two inlined pipelines it replaces.
  • reaction in REACTION_MAP vs hasOwnProperty.call is safe here since REACTION_MAP is a plain object literal with no prototype pollution risk.
  • iterateAuditEntries() delegating to the existing iterateJSONLFiles([path], ...) helper preserves single-file semantics (missing/empty file falls through to defaultValue), despite the helper adding a nested try/catch layer that is a no-op difference for the single-path case.

A grumpy-coder sub-agent pass independently found no actionable issues either.

🔎 Code quality review by PR Code Quality Reviewer · auto · 23.6 AIC · ⊞ 7.8K
Comment /review to run again

@github-actions github-actions Bot mentioned this pull request Aug 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Skills-Based Review 🧠

Applied /codebase-design and /improve-codebase-architecture — approving.

📋 Key Themes & Highlights

Key Themes

  • Deduplication is clean: normalizeMentionAliases() correctly unifies two identical pipelines; call-sites no longer need their own pre-guards since the helper handles non-array inputs.
  • in operator substitution is safe: REACTION_MAP is a plain object literal; no inherited properties could cause a false positive.
  • iterateAuditEntries delegation: semantics are preserved — iterateJSONLFiles uses continue on missing files while the old code used an early return, but with a single-element array the outcomes are identical. Outer try/catch is kept for safety.

Positive Highlights

  • ✅ All three changes reduce surface area without altering behaviour
  • ✅ 275 passing tests provide confidence
  • ✅ New helper is well-typed (@param {unknown}, @returns {string[]}) and self-documenting

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 31.2 AIC · ⊞ 7K
Comment /matt to run again

@pelikhan

pelikhan commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@copilot run pr-finisher skill

Done in b6fe1d0. I ran the PR finisher pass, restored own-property reaction validation, added a regression test, and revalidated locally with targeted vitest, make fmt, make lint, TEST_UNIT_RUN_FULL=1 make test-unit, make test, and make agent-report-progress.

Copilot AI requested a review from pelikhan August 1, 2026 05:49
@pelikhan
pelikhan merged commit 2248c79 into main Aug 1, 2026
8 checks passed
@pelikhan
pelikhan deleted the code-simplifier/js-safe-outputs-dedup-20260801-918df80d3b22b9c8 branch August 1, 2026 06:24
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.84.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants