Skip to content

chore: quality pass for 2.3.0 (leaner code, lint, fixes, docs) - #29

Merged
hexawulf merged 12 commits into
mainfrom
chore/quality-upgrade
Nov 20, 2026
Merged

hexawulf merged 12 commits into
mainfrom
chore/quality-upgrade

Conversation

@hexawulf

Copy link
Copy Markdown
Owner

Quality pass for 2.3.0: less duplicated code, lint in CI, two error-path fixes, one small feature, public-repo hygiene and a README in the style of the other hexawulf repos. No route, response shape, auth path, cookie/session name, CSP/Helmet setting or database schema changed, except where listed under Behaviour changes.

Before / after

Measured on the same machine (Node 24.22.3, npm 11.14.1, scratch PostgreSQL 18), main = 0a7dee5.

Metric main this branch
Unit + DB tests (vitest) 21 files, 357/357 pass 22 files, 363/363 pass
E2E (Playwright) 41/41 pass 42/42 pass
Installer tests 82/82 82/82
Typecheck (tsc) 0 errors 0 errors
Lint not configured 0 problems (first run: 23, all fixed)
npm audit (all / --omit=dev) 0 / 0 0 / 0
Dependencies in package.json (prod + dev) 25 + 20 25 + 24 (ESLint only)
Installed packages (lockfile) 513 637 (+124, all ESLint dev deps)
Client main JS 294.05 kB (96.27 kB gzip) 294.06 kB (96.27 kB gzip)
dist/public / dist/index.js / dist/agent.mjs 552 K / 140.1 kB / 36.3 kB 552 K / 139.5 kB / 36.4 kB
App code (cloc, TS: server, client/src, shared) 7,610 lines 7,613 lines
Test code (cloc, tests/ without fixtures) 3,455 lines 3,596 lines
Tracked text lines (no lockfile, no PNG) 21,976 16,538 (−25%)

App code stays flat although the branch adds a feature, three small modules and a component split: the removed duplicates pay for them.

Commits

  1. refactor(server): one wrapWith() / writeOpts() (server/routes/http.ts), httpError() (server/errors.ts), crontab cache in server/crontab/cache.ts.
  2. refactor(auth): one isFirebaseEnabled(), httpError(), one service-account parse.
  3. chore(deps): drop the stale re2js override (not in the tree; installed tree identical).
  4. fix(auth): firebase-login answers 500 for unexpected errors. New route test.
  5. fix(tasks): 404 instead of a 500/TypeError when a task is deleted during an update. New test.
  6. chore(security): placeholders instead of real emails, hosts and topology (.env.example, the 2.1 plan, comments).
  7. chore: remove docs/archive/.
  8. chore(lint): ESLint (recommended sets only) + npm run lint in CI; the 23 first-run problems fixed.
  9. feat(fleet): clearer empty states. New E2E test.
  10. docs: README rewrite, SECURITY.md, screenshots, engines + .nvmrc.
  11. chore(release): 2.3.0 (CHANGELOG entry says unreleased; set the date when tagging).
  12. chore(security): no host names in the remaining comments and test titles.

Deleted

Item Why Proof
docs/archive/ (10 files, 5,776 lines) 1.x notes its own README marked "not current" only README layout and old CHANGELOG lines referenced it; kept in history (tag v2.2.3)
re2js in overrides stale npm ls re2js --all: none; installed tree identical without it
Unused import in drizzle.config.ts dead ESLint no-unused-vars
Two useEffect state syncs (run history, logs) and the task-form reset effect replaced by derived state / mount-on-open react-hooks/set-state-in-effect

Behaviour changes

  • POST /api/auth/firebase-login: an error without a status (database, session store) used to be answered 401 with its raw message; now it is logged and answered 500 "Internal server error during Firebase login.". The verifier's own 400/401/403/503 answers are unchanged.
  • Task routes (PATCH /api/tasks/:id, POST /api/tasks/:id/runner, POST /api/tasks/:id/toggle-system-managed): if the task is deleted mid-update the answer is 404 "Task not found" instead of a 500.
  • Fleet page: the empty state now says whether filters hide everything (with a Clear filters button) or nothing is scheduled (with a hint about PITASKER_HOSTS when the hub is alone).
  • Task editor: the form state starts fresh on every open (it mounts with the dialog) instead of being reset by an effect. Same visible behaviour; if the task list refreshes while the editor is open, the form is no longer reset.
  • Logs page: until you pick a file, the newest log is shown (and follows a new newest file); before, the first default stuck.
  • Error logging: fleet route errors now get a [fleet] log line before the app's error handler.

Not changed on purpose

  • Code defaults that name real paths or hosts stay, because changing them would change runtime behaviour: PITASKER_ORIGIN default in server/middleware/sameOrigin.ts, PITASKER_BIN_MASTER default in server/fleet/hosts.ts, /home/zk/bin defaults. Test inputs for the path guards also keep /home/zk.
  • The E2E harness's PITASKER_TZ=Asia/Taipei (asserted by the fleet tests) shows in the screenshots.
  • Unchanged files still mention real hosts (scripts' usage examples, test fixtures, docs/plans/2.0.md); every file this PR adds or edits was scanned clean of real host names, private IPs and emails.
  • Phase-1 finding "axe/mobile checks skip /fleet" was wrong: tests/e2e/fleet.spec.ts already covers both views in both themes and at 390 px. No change made.
  • GitHub private vulnerability reporting is off for this repo; SECURITY.md works either way. Turning it on (Settings → Code security) makes the Report a vulnerability path in SECURITY.md available.

Screenshots

Taken with npm run screenshots against the E2E harness (fake crontab with tests/fixtures/crontab.demo, scratch database, fixture fleet agents) running in a throwaway container with the host name demo-hub. The spec refuses to capture a page that shows a private address, an email or a non-demo host name.

Manual test checklist (after deploy)

  • /login returns 200; headers keep the CSP (Firebase hosts in script-src, connect-src, frame-src), Referrer-Policy: strict-origin-when-cross-origin, and no Cross-Origin-Opener-Policy.
  • Sign in with Google (allowlisted account) works; a non-allowlisted account gets the 403 message.
  • Break-glass password login works; logout returns to /login.
  • Tasks: create a PiTasker-run task, edit it (form shows its values), Run now, open Runs (newest run selected), delete it.
  • Tasks: edit a crontab-run task → diff dialog → write; the crontab backup appears under Crontab → Backups.
  • Open the task editor twice in a row for different tasks: each opens with its own values.
  • Fleet: all agent hosts online; search for nonsense → "No job matches the filters." + Clear filters works.
  • Logs: newest log file selected by default; picking another one sticks.
  • pm2 logs pitasker --lines 50 --nostream shows no errors.
  • After merge: tag v2.3.0, set the CHANGELOG date, GitHub release.

🤖 Generated with Claude Code

hexawulf and others added 12 commits November 20, 2026 16:54
- server/routes/http.ts: one wrapWith() and writeOpts() for the task,
  crontab and fleet routes (were three wraps and two writeOpts).
- server/errors.ts: httpError() replaces hand-built Object.assign errors.
- server/crontab/cache.ts: the 3 s crontab read cache moves out of
  routes/tasks.ts, so routes/crontab.ts no longer imports a route file.
- moveRunner takes the loaded task (the toggle route read it twice).

No behaviour change; fleet errors now also get a [fleet] log line before
the app error handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arse

security.ts used its own copy of the FIREBASE_ENABLED parse; the Firebase
service built six status errors by hand and had two near-identical
service-account branches. Same messages and statuses as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
re2js is no longer in the dependency tree (npm ls re2js --all: none);
the installed tree is identical without the override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Any error without a status used to come back as 401 with its raw message
(e.g. a database error text). Errors from verifyFirebaseLogin keep their
status and message; everything else is logged and answered with a generic
500. New route test (no database) covers success, 403 passthrough, 400,
and both 500 cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four routes asserted storage.updateTask() found the row; a concurrent
delete turned that into a TypeError and a 500 with a stack in the log.
They now answer 404 "Task not found", like the other task routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repository is public. .env.example carried the real Firebase
allowlist emails and the real fleet (LAN/tunnel IPs, host names); the
2.1 plan carried the host inventory, firewall rules, sudo facts and the
rollout runbook. Now: example.com addresses, documentation IP ranges
(192.0.2.0/24, 198.51.100.0/24), generic host ids, and the plan as a
design record (section anchors kept for the code comments that link to
it). Comment-only edits in AGENTS.md, CHANGELOG.md, app.ts, fleet.tsx.

No runtime change: code defaults (PITASKER_ORIGIN, PITASKER_BIN_MASTER,
PITASKER_BIN_DIR) are untouched. Git history is not rewritten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ten 1.x guides and status notes (~5,900 lines) that their own README
marked as not current. Git history keeps them (last at tag v2.2.3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eslint.config.js: @eslint/js + typescript-eslint recommended on all
TypeScript, eslint-plugin-react-hooks recommended on client/src; no
stylistic rules; .js/.mjs/.cjs are not linted. New dev dependencies
(pinned, all released 2+ weeks ago): eslint 10.14.0, @eslint/js 10.0.1,
typescript-eslint 8.72.1, eslint-plugin-react-hooks 7.1.1.

First run: 23 problems, all fixed:
- react-hooks/set-state-in-effect (5), react-hooks/refs (5): the task
  form mounts on every open instead of resetting state in an effect; the
  run history and log pages derive their default selection; shortcut
  handlers live in useState and the latest callback is set in a layout
  effect.
- no-control-regex (5): three identical regexes become CONTROL_CHARS in
  shared/cron.ts (task names: CONTROL_CHARS or tab, as before); two
  justified disables remain.
- no-useless-escape, unused import/params, require() in a test,
  preserve-caught-error (cause attached).
- Justified disables: Playwright's ({}, use) fixture form; the test
  helper's JSON body type.

The three existing eslint-disable comments are all still needed (ESLint
reports unused directives; none were reported).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When nothing is shown, the Fleet page now says why: with filters set, "No
job matches the filters." plus a Clear filters button; without filters,
"Nothing is scheduled on any host yet." and, when the hub is the only
host, a pointer to PITASKER_HOSTS. Before, both cases read "No job
matches the filters.". New E2E test for the filter case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- README in the shape of the other hexawulf repos: badges (CI, release,
  license, node), features, how it works, quick start, configuration,
  fleet agents, tests, deployment, security, layout. Release notes moved
  out (they are in CHANGELOG.md); no real hosts, addresses or emails.
- SECURITY.md: how to report, scope, design notes.
- Screenshots (tasks, fleet, tasks dark) from the E2E harness with a demo
  crontab (tests/fixtures/crontab.demo): npm run screenshots. The spec
  fails if a page shows anything that looks like a private address, an
  email or a non-demo host name.
- engines: node >=22, .nvmrc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three comments in server/fleet/collector.ts and one test title named real
hosts; a test used an address on a real domain (now example.net).
Comment, title and test-data changes only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bcd243ba-1e45-4a89-affa-5325b3eb3bb8
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T09:36:04.895111Z 31980b1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hexawulf
hexawulf merged commit 9d0e92c into main Nov 20, 2026
3 checks passed
@hexawulf
hexawulf deleted the chore/quality-upgrade branch November 20, 2026 09:57
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.

1 participant