Skip to content

[jsweep] Clean write_daily_aic_usage_cache.cjs#45036

Merged
pelikhan merged 4 commits into
mainfrom
signed/jsweep/write-daily-aic-usage-cache-034b1982c7b134a0
Jul 13, 2026
Merged

[jsweep] Clean write_daily_aic_usage_cache.cjs#45036
pelikhan merged 4 commits into
mainfrom
signed/jsweep/write-daily-aic-usage-cache-034b1982c7b134a0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Cleaned write_daily_aic_usage_cache.cjs as part of the daily jsweep unbloat workflow.

Execution context: github-script

Changes

Removed unnecessary try/catch in logCache

The JSON.stringify call in logCache was wrapped in a try/catch, but JSON.stringify only throws for circular references — which are impossible with the plain Record<string, unknown> details object passed to this function. Removed the dead catch block and simplified to a ternary expression.

Used nullish coalescing (??) instead of logical OR (||)

Replaced || with ?? for the cacheFilePath and usageDir parameters in mainWithPaths. This is more precise: ?? only falls back for null/undefined, not for falsy values like empty strings.

Test Improvements

  • Before: 10 tests
  • After: 11 tests (+1)
  • Added test: writes a large AIC value correctly — verifies that a large AIC value (999.99) is written without warnings

Validation ✅

All checks passed:

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js ✓ (11/11 passing for this file)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • traces.example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "traces.example.com"

See Network Configuration for more information.

Generated by 🧹 jsweep - JavaScript Unbloater · 62.9 AIC · ⌖ 8.75 AIC · ⊞ 7.7K ·

  • expires on Jul 13, 2026, 9:00 PM UTC-08:00

- Remove unnecessary try/catch around JSON.stringify in logCache
  (JSON.stringify only throws for circular refs, not expected here)
- Use nullish coalescing (??) instead of logical OR (||) for path defaults
- Add test for large AIC value (10 → 11 tests total)

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

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

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

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ PR Code Quality Reviewer failed to deliver outputs during code quality review.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

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

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

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

Simplifies daily AIC cache logging and path handling while adding a large-value test.

Changes:

  • Removes defensive log serialization handling.
  • Changes path fallback semantics from || to ??.
  • Adds large AIC value coverage.
Show a summary per file
File Description
actions/setup/js/write_daily_aic_usage_cache.cjs Simplifies logging and changes path defaults.
actions/setup/js/write_daily_aic_usage_cache.test.cjs Tests writing a large AIC value.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread actions/setup/js/write_daily_aic_usage_cache.cjs Outdated

@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.

The changes are correct and well-reasoned. The ?? vs || fix is a precision improvement, and the try/catch removal is justified — JSON.stringify only throws on circular references, which cannot occur with a Record<string, unknown> passed at call sites. The new test validates the large AIC value path cleanly.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 13.6 AIC · ⌖ 5.32 AIC · ⊞ 4.8K

@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.

Skills-Based Review 🧠

Applied /codebase-design — changes are clean and well-reasoned.

📋 Highlights

Positive Highlights

  • ✅ Correct removal of dead try/catch — JSON.stringify cannot throw on a plain Record<string, unknown>
  • ?? over || is the right semantic here; the PR description explicitly calls out the behavioral difference
  • ✅ New regression test verifies the removed warning path is truly gone (expect(global.core.warning).not.toHaveBeenCalled())
  • ✅ All CI checks passing

No actionable issues found.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 12.9 AIC · ⌖ 4.32 AIC · ⊞ 6.6K
Comment /matt to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 74/100 — Acceptable

Analyzed 8 test(s): 7 design, 1 implementation, 0 violation(s).

📊 Metrics (8 tests)
Metric Value
Analyzed 8 (Go: 0, JS: 8)
✅ Design 7 (87%)
⚠️ Implementation 1 (13%)
Edge/error coverage 5 (63%)
Duplicate clusters 0
Inflation YES (8 test additions : 3 prod additions = 2.67:1)
🚨 Violations 0
Test File Classification Issues
writes new entry with run_id, aic, timestamp write_daily_aic_usage_cache.test.cjs design_test none
appends + preserves entries within 48h write_daily_aic_usage_cache.test.cjs design_test none
prunes entries older than 48h write_daily_aic_usage_cache.test.cjs design_test none
no usage files writes aic=0 write_daily_aic_usage_cache.test.cjs design_test none
preserves unparseable lines write_daily_aic_usage_cache.test.cjs design_test none
creates cache parent directory write_daily_aic_usage_cache.test.cjs design_test none
writes a large AIC value correctly write_daily_aic_usage_cache.test.cjs implementation_test happy-path only
emits warning on unreadable cache write_daily_aic_usage_cache.test.cjs design_test none
⚠️ Flagged Tests (1)

writes a large AIC value correctly (write_daily_aic_usage_cache.test.cjs) — implementation_test. Validates a numeric value is written unchanged (floating-point fidelity); asserts only the happy path with no warning-emission or edge assertion.

Test Inflation Note: Ratio is 2.67:1 (8 new test lines vs 3 new prod lines), exceeding the 2:1 threshold. However the PR also deletes 11 prod lines (cleanup), so the inflation is a positive signal here.

Verdict

Passed. 13% implementation tests (threshold: 30%). Tests use real filesystem I/O with temp directories (no mock abuse), and cover 5 distinct edge/error scenarios: pruning by age, resilience to corrupt data, missing parent directories, zero-usage-files, and error propagation via core.warning.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 29.2 AIC · ⌖ 9.27 AIC · ⊞ 6.8K ·
Comment /review to run again

@github-actions github-actions Bot mentioned this pull request Jul 13, 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.

✅ Test Quality Sentinel: 74/100. 13% implementation tests (threshold: 30%).

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

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

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@copilot run pr-finisher skill

Reverted ?? back to || for both cacheFilePath and usageDir in b5035b3. Empty strings now correctly fall back to the defaults rather than being used as invalid paths.

Copilot AI requested a review from pelikhan July 13, 2026 14:50
@pelikhan
pelikhan merged commit 43ce73a into main Jul 13, 2026
10 of 11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.82.9

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