Skip to content

fix: include effective token count in noop and detection comment footers#25941

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-footer-token-count
Apr 12, 2026
Merged

fix: include effective token count in noop and detection comment footers#25941
pelikhan merged 3 commits intomainfrom
copilot/fix-footer-token-count

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

The > Generated from [Workflow](url) footer in noop and detection run issue comments was missing the effective token count (● N) that other safe-output footers include.

Before: > Generated from [Workflow](url)
After: > Generated from [Workflow](url) · ● 12.5K

Changes

  • Templates (actions/setup/md/noop_comment.md, detection_runs_comment.md): Append {effective_tokens_suffix} to footer line
  • Shared helper (actions/setup/js/effective_tokens.cjs): New getEffectiveTokensSuffix() reads GH_AW_EFFECTIVE_TOKENS env var and returns formatted suffix or ""
  • Handlers (handle_noop_message.cjs, handle_detection_runs.cjs): Import helper, pass suffix to template context
  • Tests (handle_noop_message.test.cjs): Two new cases covering presence and absence of effective tokens

@pelikhan pelikhan marked this pull request as ready for review April 12, 2026 21:53
Copilot AI review requested due to automatic review settings April 12, 2026 21:53
@pelikhan pelikhan merged commit bf4d0bb into main Apr 12, 2026
69 of 70 checks passed
@pelikhan pelikhan deleted the copilot/fix-footer-token-count branch April 12, 2026 21:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates noop and detection-run issue comment footers to include the effective token count suffix (· ● N) when available, matching other safe-output footers.

Changes:

  • Append {effective_tokens_suffix} to the footer line in noop and detection comment templates.
  • Add getEffectiveTokensSuffix() helper and pass effective_tokens_suffix into template rendering for noop/detection handlers.
  • Extend noop handler tests to cover presence/absence of GH_AW_EFFECTIVE_TOKENS (plus an unrelated workflow runner change).
Show a summary per file
File Description
actions/setup/md/noop_comment.md Appends {effective_tokens_suffix} to the generated footer.
actions/setup/md/detection_runs_comment.md Appends {effective_tokens_suffix} to the generated footer.
actions/setup/js/effective_tokens.cjs Adds getEffectiveTokensSuffix() for env-driven footer suffix formatting.
actions/setup/js/handle_noop_message.cjs Computes/passes effective_tokens_suffix into noop comment template context.
actions/setup/js/handle_detection_runs.cjs Computes/passes effective_tokens_suffix into detection comment template context.
actions/setup/js/handle_noop_message.test.cjs Adds tests for footer suffix inclusion/omission.
.github/workflows/agentics-maintenance.yml Changes validate_workflows runner from ubuntu-slim to ubuntu-latest.

Copilot's findings

Tip

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

  • Files reviewed: 7/7 changed files
  • Comments generated: 2

Comment on lines +217 to +223
function getEffectiveTokensSuffix() {
const raw = process.env.GH_AW_EFFECTIVE_TOKENS;
const parsed = raw ? parseInt(raw, 10) : NaN;
if (!isNaN(parsed) && parsed > 0) {
return ` · ● ${formatET(parsed)}`;
}
return "";
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

getEffectiveTokensSuffix() duplicates the env-parsing/suffix-formatting logic that already exists in actions/setup/js/messages_footer.cjs (getEffectiveTokensFromEnv() returns effectiveTokensSuffix). To avoid two implementations drifting (e.g., formatting or validation changes), consider extracting a single shared helper (or exporting/reusing getEffectiveTokensFromEnv/suffix logic) and using it from both places.

Copilot uses AI. Check for mistakes.
Comment on lines 282 to 285
validate_workflows:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.operation == 'validate' && !github.event.repository.fork }}
runs-on: ubuntu-slim
runs-on: ubuntu-latest
permissions:
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

This workflow job changes runs-on from ubuntu-slim to ubuntu-latest, but the PR description is focused on comment footers/effective token suffixes and doesn't mention a runner change. If this is intentional (e.g., ubuntu-slim is deprecated/unsupported for this job), please document the rationale in the PR description; otherwise consider reverting to keep runner usage consistent with the rest of the workflow.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot mentioned this pull request Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 75/100

⚠️ Acceptable, with suggestions

Metric Value
New/modified tests analyzed 2
✅ Design tests (behavioral contracts) 2 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 1 (50%)
Duplicate test clusters 0
Test inflation detected YES (61 test lines / 6 production lines ≈ 10:1)
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
should include effective token count in footer when GH_AW_EFFECTIVE_TOKENS is set actions/setup/js/handle_noop_message.test.cjs:670 ✅ Design Happy-path only; no edge cases (invalid value, zero, NaN)
should not include effective token count in footer when GH_AW_EFFECTIVE_TOKENS is not set actions/setup/js/handle_noop_message.test.cjs:703 ✅ Design Covers the "absent env var" negative case — good

Flagged Tests — Requires Review

⚠️ should include effective token count in footer when GH_AW_EFFECTIVE_TOKENS is set

Classification: Design test (behavioral contract)
Issue: Covers only the happy path — GH_AW_EFFECTIVE_TOKENS = "12500". The production function getEffectiveTokensSuffix() in effective_tokens.cjs explicitly handles non-numeric values (e.g., "abc"), zero, and negative numbers by returning "". None of these branches are exercised here or in the companion test.
What design invariant does this test enforce? When GH_AW_EFFECTIVE_TOKENS is set to a valid positive integer, the rendered comment body includes the formatted token count (e.g., · ● 12.5K).
What would break if deleted? A regression in token-count formatting or template variable substitution would go undetected.
Suggested improvement: Add a third test case — or extend this one to a table-driven structure — covering at least one invalid value (e.g., GH_AW_EFFECTIVE_TOKENS = "abc") to confirm the footer is gracefully omitted, matching the guard logic in getEffectiveTokensSuffix().


Test Inflation Note

The test file handle_noop_message.test.cjs added 61 lines while the corresponding production file handle_noop_message.cjs added only 6 lines (ratio ≈ 10:1, threshold 2:1). This triggers the inflation flag, but the ratio is misleading in context: each vitest test in this file requires substantial boilerplate (env setup, file system mocking, API mocking via mockGithub), and the feature under test spans three production files (effective_tokens.cjs +16, handle_noop_message.cjs +6, handle_detection_runs.cjs +6 = 28 total). Measured against total production changes, the ratio is 61/28 ≈ 2.2:1 — marginally over the threshold. No concern here.


Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 0 tests
  • 🟨 JavaScript (*.test.cjs): 2 tests (vitest)

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). Both new tests verify observable behavioral contracts (comment body content). The only suggestion is adding an edge-case row for invalid GH_AW_EFFECTIVE_TOKENS values to the first test.


📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

🧪 Test quality analysis by Test Quality Sentinel · ● 475.5K ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 75/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). Both tests verify observable behavioral contracts on the comment body output. Minor suggestion: add an edge-case for invalid GH_AW_EFFECTIVE_TOKENS values.

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.

3 participants