Skip to content

feat: add frontend LOC ratchet warnings - #691

Merged
Astro-Han merged 2 commits into
devfrom
codex/i688-loc-ratchet
May 17, 2026
Merged

feat: add frontend LOC ratchet warnings#691
Astro-Han merged 2 commits into
devfrom
codex/i688-loc-ratchet

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a frontend-architecture CI job that writes the frontend inventory JSON and runs LOC ratchet warnings.
  • Extends script/frontend-inventory.mjs with a warn-only --check-baseline mode for touched production frontend files above >500 / >200 LOC.
  • Updates the frontend architecture manifest with the current LOC baseline and CI-stage wording.

Why

#688 needs executable frontend governance in separate slices. LOC is the smallest first slice because the inventory script and manifest already exist; this PR makes that signal visible in CI without turning LOC into a hard merge gate or touching UI rewrite code.

Related Issue

Refs #688.

Human Review Status

Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.

Review Focus

Please check that the new CI job is scoped as warn-only LOC governance, that it is wired into ci / check as an infrastructure signal, and that this PR does not expand into dependency boundary or cognitive-complexity work.

Risk Notes

  • LOC warnings are advisory only in this slice; they do not reduce existing large files and do not block oversized touched files yet.
  • The CI job fetches full history so git diff can compare PR base/head reliably.
  • No visible UI, packaging, permissions, dependency, or platform behavior changes.

How To Verify

Frontend inventory JSON: passed, summary produced schemaVersion=1 with productionOver500=19 and productionOver200=81
LOC warn dry run: passed, origin/dev..HEAD had 0 changed frontend files and 0 touched production warnings
Focused tests: passed, 11 tests / 0 failures in packages/opencode test/github/frontend-inventory.test.ts and test/github/ci-workflow.test.ts
Diff check: passed, git diff --check reported no whitespace errors

Screenshots or Recordings

Not required; no visible UI changes.

Checklist

  • Human review status is stated above as pending, approved, or not required
  • I linked the related issue, or stated why there is no issue
  • This PR has type, primary area, and priority labels, or I requested maintainer labeling
  • I described the review focus and any meaningful risks
  • I listed the relevant verification steps and the key result for each
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant
  • I reviewed the final diff for unrelated changes and suspicious dependency changes
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

Summary by CodeRabbit

  • New Features

    • Added frontend code size monitoring to the CI pipeline. The system now warns when modified production files exceed size thresholds (>200 and >500 lines of code).
  • Tests

    • Added test coverage for the new code size monitoring functionality.

Review Change Stack

@Astro-Han Astro-Han added ci Continuous integration / GitHub Actions P1 High priority github_actions Pull requests that update GitHub Actions code tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context labels May 17, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation harness Model harness, prompts, tool descriptions, and session mechanics labels May 17, 2026
@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 33 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e21f55f-5a64-403a-985f-303cc1bc3a97

📥 Commits

Reviewing files that changed from the base of the PR and between 5633009 and 4e94c6d.

📒 Files selected for processing (1)
  • packages/opencode/test/github/frontend-inventory.test.ts
📝 Walkthrough

Walkthrough

This PR implements a frontend architecture LOC baseline ratchet that runs as a warn-only CI check. The script gains --check-baseline mode to detect production files exceeding LOC thresholds, a new CI job runs the checks, tests cover the behavior, and governance documentation is updated.

Changes

Frontend LOC baseline ratchet with warn-only CI checks

Layer / File(s) Summary
Baseline checking script implementation
script/frontend-inventory.mjs
Parses --check-baseline, --base, and --head CLI arguments. Implements listChangedFrontendFiles(base, head) to detect modified production files via git diff, checkBaseline(inventory, {base, head}) to identify files exceeding >200 and >500 LOC thresholds, and githubWarning(record, threshold) to format GitHub Actions warning annotations.
CI workflow job and result integration
\.github/workflows/ci\.yml
Adds new frontend-architecture job that installs dependencies, generates a frontend inventory JSON artifact, and runs baseline LOC checks with BASE_SHA/HEAD_SHA. Wires the job into the aggregate check job's needs, captures its result via FRONTEND_ARCHITECTURE_RESULT env var, and treats non-success results as CI failures with failure reason output.
CI workflow test coverage
packages/opencode/test/github/ci-workflow\.test\.ts
Introduces constant frontendArchitectureJobName and adds test case validating the new job's docs-only gating, required workflow actions (checkout, setup-node, setup-bun, cache), script execution, SHA env wiring, and inclusion in check.needs. Updates existing aggregate test to include the job in expected check.needs ordering and assert FRONTEND_ARCHITECTURE_RESULT env propagation in the validation step.
Frontend inventory baseline test
packages/opencode/test/github/frontend-inventory\.test\.ts
New Bun test suite that sets up a temporary git repository, creates and modifies an oversized frontend TypeScript file exceeding LOC threshold, runs frontend-inventory script with --check-baseline against base/head commits, and asserts successful exit, "Frontend LOC ratchet warnings" output, and GitHub-style ::warning annotations referencing the threshold violation.
Governance manifest and documentation
\.github/frontend-architecture-manifest\.md
Updates manifest header to "LOC warn-only CI slice" with new baseline commit. Expands inventory command instructions to include baseline-diff check before markdown generation. Regenerates baseline inventory summary with updated tracked/ratchet file counts and owner lane distribution. Rewrites ratchet stages to specify warn-on-threshold behavior for PR-added production files above >500/>200 LOC. Updates production burn-down list with new file entries and owner lane assignments. Marks Governance PR as "complete" and adds new "LOC warn-only CI PR" row with verification commands and "in progress" status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Astro-Han/pawwork#667: Directly extends the frontend-inventory.mjs script and governance baseline from PR #667 by implementing --check-baseline mode with base-head diff detection and ratchet warning logic.
  • Astro-Han/pawwork#125: Overlaps on .github/workflows/ci.yml modifications to the aggregate check job's dependency contract and corresponding test assertions on check.needs and result env passing.

Suggested labels

app

Poem

🐰 A rabbit hops through baselines true,
Counting LOC in every view.
Warnings echo, clean and kind,
No hard fail—just peace of mind!
The frontend glows with ratchet's grace, 🎯✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: add frontend LOC ratchet warnings' clearly and specifically describes the main change: adding LOC ratchet warning functionality to the frontend architecture.
Description check ✅ Passed The PR description is comprehensive and follows the template well, including all key sections: Summary, Why, Related Issue, Human Review Status, Review Focus, Risk Notes, How To Verify, Screenshots/Recordings, and a completed Checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i688-loc-ratchet

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements a warn-only CI check for frontend architecture governance. The frontend-inventory.mjs script is updated to support baseline comparisons using git diff, enabling it to issue warnings for touched production files that exceed 200 or 500 Lines of Code (LOC). Additionally, the GitHub Actions workflow now includes a frontend-architecture job, and new tests have been added to verify the script's reporting logic and CI integration. The architecture manifest has also been updated to reflect the latest baseline metrics and project status. I have no feedback to provide.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/opencode/test/github/frontend-inventory.test.ts`:
- Around line 23-29: Replace the manual temp-repo creation in the test
(mkdtempSync, git init/config calls) with the shared tmpdir fixture: use "await
using tmpdir({ git: true }) as workspace" (imported from fixture/fixture.ts) to
obtain a git-initialized workspace and automatic cleanup, then copy
inventoryScript into path.join(workspace, "frontend-inventory.mjs") and create
the packages/app/src dir as before; remove the explicit git(...) calls and the
manual mkdtempSync to rely on the fixture-managed repo and root commit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 60a23f6f-6440-4454-85dc-4b4a84e970a8

📥 Commits

Reviewing files that changed from the base of the PR and between c3e9319 and 5633009.

📒 Files selected for processing (5)
  • .github/frontend-architecture-manifest.md
  • .github/workflows/ci.yml
  • packages/opencode/test/github/ci-workflow.test.ts
  • packages/opencode/test/github/frontend-inventory.test.ts
  • script/frontend-inventory.mjs

Comment thread packages/opencode/test/github/frontend-inventory.test.ts Outdated
@Astro-Han
Astro-Han merged commit 3f61ebe into dev May 17, 2026
26 checks passed
@Astro-Han
Astro-Han deleted the codex/i688-loc-ratchet branch May 17, 2026 07:57
Astro-Han added a commit that referenced this pull request May 17, 2026
Prepare PawWork v2026.5.18 for the stable desktop release.

- Bump the desktop package version to 2026.5.18.
- Scope the diagnostics unreadable-file retention test to POSIX permission semantics so Windows advisory does not fail on chmod behavior that Windows does not enforce the same way.

Verification:
- Focused desktop diagnostics test passed locally: 11 pass / 0 fail.
- Release typecheck passed locally for packages/desktop-electron.
- PR #706 CI passed, including ci, desktop-smoke, e2e-artifacts, CodeQL, dependency-review, label-policy, commit-lint, and title lint.

Release notes:
- Drafted against the merged range since v2026.5.17: #691, #692, #693, #694, #702, and #703.
- Cold-read review completed before merge; wording was tightened to avoid overclaiming diagnostics impact and to keep verification short.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration / GitHub Actions documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code harness Model harness, prompts, tool descriptions, and session mechanics P1 High priority tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant