Implements the user-store + invite-store + admin routes. The whole system is opt-in via siteConfig.authProviders.email.enabled = true; single-user TOTP-only installs see zero behavior change. Backend: - src/security/user-store.js: users + allowlist + bootstrap sentinel, atomic writes, last-admin protection, defensive dataDir resolver. - src/security/invite-store.js: single-use tokens (SHA-256 hashed on disk), TTL, auto-prune, defensive dataDir resolver. - routes/auth/admin.js: /me, /admin/users (CRUD), /admin/allowlist, /admin/invites (CRUD), public /invites/:token (peek + accept). - routes/auth/index.js: wires userStore, gates admin router on email auth being enabled. - src/auth/providers/email.js: verify() enforces allowlist, creates user record, tags req.user; default-enabled flipped to opt-in. - src/auth/providers/totp.js: bootstraps system@totp.local admin on first verify so current DNS2 operator shows in /admin/users. - src/security/audit-logger.js: middleware adds userId/userEmail/ userRole/viaProvider to log details when req.user is tagged. - PUBLIC_ROUTES + CSRF allowlists updated for invite redemption. Frontend: - status/js/admin.js: modal overlay with users list (role-edit, delete), invite form (email/role/TTL), copy-link button, outstanding-invites list with revoke. Exports window.AdminPanel. - status/js/core/init.js: calls AdminPanel.attachTrigger so the Admin button only appears when /me returns isAdmin=true. Tests: 35 new tests across 3 files (user-store, invite-store, auth multistore integration). Full suite: 1298/1298 passing. Docs: BACKLOG.md marks DC-048 done. CHANGELOG.md [Unreleased] section gets the DC-048 entry.
71 KiB
DashCaddy Improvement Backlog
Shared coordination file for Hermes & Krystie. Both bots read this, claim tasks, and update status. Git is the source of truth. When claiming: change
status: todotostatus: in-progressand setowner. When done: change tostatus: doneand add brief result.
P0 — Must Fix (blocks public release)
DC-020: Restore deleted license-keygen.js — production container in crash-restart loop
- status: done
- owner: hermes
- details: The
refactor(desloppify)commit (a2e6566) deleteddashcaddy-api/license-keygen.jsbelieving it was "stale dev-root noise." It is NOT — it is a required production module.src/managers/license-manager.js:17doesrequire('./license-keygen')and importsverifyCode,parseCode,VALID_DURATIONSfrom it. After deletion,require('./src/app')throwsMODULE_NOT_FOUND: Cannot find module './license-keygen'and the productiondashcaddy-apiDocker container is in a crash-restart loop (verified:docker psshowsRestarting (1),docker logsshows the MODULE_NOT_FOUND stack from/app/src/app.js→/app/server.js). The 1036-test Jest suite never caught this because the only "app-loading" tests readsrc/app.jsas a string (viapath.join(...,'src','app.js')), they never executerequire()on it. Fix: restore the file from git history tosrc/managers/license-keygen.js(the path the post-DC-005 require resolves to) and add a real startup smoke test that executesrequire()on the app module so this class of bug is caught. - result: Done across two sessions. (1) Restored
license-keygen.jsfrom git history. (2) Fixed everyrequire('../src/...')→require('./src/...')inserver.js— from the production entry point/app/server.js,../src/resolves to/src/(outside the app) instead of/app/src/. (3) Session 2 (this commitf94b164): found and fixed the LAST one the sweep missed —server.js:73still hadrequire('./state-manager')which resolves to/app/state-manager.js, a file that does NOT exist (module lives atsrc/managers/state-manager.js). Unlike the optional modules below it, this require is bare (no try/catch), so MODULE_NOT_FOUND throws out of the top-level startup IIFE and crash-loops the container — the exact same failure mode. Fixed to./src/managers/state-manager(matches line 146). (4) Hardened the regression guardapp-startup-smoke.test.js: added a static check that EVERY relativerequire()inserver.jsresolves to a real file on disk (server.js can't be require()'d at test time because its IIFE binds port 3001 + starts interval modules). This test would have failed on the original./state-managerline, so the whole entry-point path-bug class is now caught. 1067/1067 tests pass, zero new ESLint warnings.
DC-012: Add Kubernetes-style /healthz + /readyz probe aliases + document for fresh users
- status: done
- owner: hermes
- details: The standardization-pitfalls doc explicitly lists "No
/healthzor/readyzprobes" as still-open work. v1.13.0 already added/health/liveand/health/readywith proper probe semantics (live=process alive, ready=deps reachable) and tests in__tests__/health-endpoints.test.js(8 tests). But: (1) The k8s/Docker-standard short aliases/healthzand/readyzare missing — fresh users copy-pasting ahealthcheck:block from k8s docs ordocker-compose.ymlexamples online get connection refused. Even worse:src/docker/app-templates.js:316references"/healthz"as a template healthcheck URL — but that URL doesn't resolve on the DashCaddy API itself. (2)/api/v1/health(apiRouter.get line 658) and root/health(app.get line 674) both exist and return identical responses — duplicated, fresh users won't know which to probe. (3) README + user-guide have zero documentation of the probes — a fresh user has no way to know they exist or how to wire them. Fix: add/healthzand/readyzaliases that point to the same handlers, deprecate the/api/v1/healthduplicate (keep root/healthas canonical), document the probes with a copy-pastedocker-compose.ymlhealthcheck block in the user-guide. - result: Added
/healthzand/readyzas root-level aliases for/health/liveand/health/readyso fresh users can copy-pastehealthcheck:blocks from k8s/Docker docs. Liveness (/healthz) is a pure process check (no I/O). Readiness (/readyz) checks config file, services file, Docker daemon, Caddy admin API (3s timeout each), returns 200 if all OK or 503 withchecksobject. Probe endpoints bypass auth, CSRF, and per-request logging (k8s polling every 10s won't flood audit log). Consolidated/health,/health/live,/health/ready,/healthz,/readyzinto a single handler block insrc/app.js(DRYed the duplicated handler bodies). Removed the dead/api/v1/health*routes that were registered inPUBLIC_ROUTES+ CSRF lists but never actually mounted on the apiRouter — anyone probing/api/v1/healthnow gets a clean 404. Added__tests__/health-probe-aliases.test.js(19 tests): alias equivalence, removed-path 404 confirmation, source-of-truth sync check that catches drift betweensrc/app.jsmount list andsrc/utilities/middleware.jsallowlist. README + user-guide updated with copy-paste Docker Compose + Kubernetes probe blocks. Post-fix: 941/941 tests pass (+19 new).
DC-013: Config schema migration — auto-upgrade old config.json on boot
- status: done
- owner: hermes (reassigned after audit 2026-06-25 — see result)
- details: Fresh users upgrading from old
config.jsonversions break silently when fields change between releases — no auto-migration exists. Highest risk of the 4 remaining standardization items because the failure mode is invisible until something breaks post-upgrade. Fix: detect schema version on boot, run idempotent migration steps to bring config to current schema, write back atomically with a.bakbackup, log the migration path. Schema versioning viaconfigSchemaVersionfield (default 1 if absent). Current schema version: 1. - result: AUDITED — ALREADY DONE. Audited 2026-06-25 before starting work.
src/config/migrations.jsimplements exactly this system:_versionfield on config (CURRENT_VERSION = 2, schema versions 1 and 2 already defined — v1 normalizes dns string→object, v2 addsdns.provider),migrate()runs all migrations forward from detected version,loadAndMigrate()writes back to disk only when the version changed (no point rewriting identical content), called fromsrc/config/site.jsline 57 on every startup. Guarded by 21 tests in__tests__/config-migrations.test.jscovering null/undefined/v0/v1/v2/future-version + idempotency + write-back behaviour. Krystie may have claimed this task from a stale audit doc — the implementation was finished in an earlier v1.13.x audit pass. Schema versioning field name is_version(notconfigSchemaVersion); to add a v3 migration, registermigrations[3]and bumpCURRENT_VERSION. Reassigned ownership to hermes because the audit changed the work from "implement" to "verify and document."
DC-014: Monitoring endpoint info-disclosure — opt-in via MONITORING_PUBLIC env var
- status: done
- owner: hermes (reassigned after audit 2026-06-25)
- details: The monitoring/detailed health endpoint is currently in
PUBLIC_ROUTESby default — anyone reaching the API can pull internal status (Caddy admin probes, Docker container list, config drift details). Should be opt-in viaMONITORING_PUBLIC=trueenv var, defaultfalse. Security-by-default for fresh deployments on public networks. - result: AUDITED — ALREADY DONE. Audited 2026-06-25.
src/utilities/middleware.jsline 297 implementsMONITORING_PUBLICas an IIFE that reads fromprocess.env.MONITORING_PUBLIC(string'true'/'false') and falls back tocfg.monitoring.publicfrom the loaded config; defaults totruefor back-compat with existing dashboards that already hit/api/v1/monitoring/statspre-login. The monitoring routes are conditionally added toPUBLIC_ROUTESbased on this flag. Operators who don't want monitoring publicly exposed setMONITORING_PUBLIC=falseormonitoring.public: falsein config.json. The premise of this ticket (defaults to public, should be opt-in) is the inverse of what's actually there — currently it defaults to public for back-compat. If you want to flip the default tofalse, that's a fresh change and would break existing un-authenticated dashboards that load widget data pre-login. Defer until a real deployment reports info-disclosure as a concern.
DC-015: CSRF token path duplication — consolidate /api/v1/csrf-token + /api/v1/auth/csrf-token
- status: done
- owner: hermes (reassigned after audit 2026-06-25)
- details: Two routes return the same CSRF token:
/api/v1/csrf-token(inline insrc/app.js) and/api/v1/auth/csrf-token(inroutes/auth/). Confusing for any developer integrating with the API. Pick one canonical, deprecate the other with a redirect +Deprecationheader, update any frontend callers. - result: AUDITED — NEVER EXISTED (or already cleaned up). Verified 2026-06-25 with
grep -rn "auth/csrf-token" dashcaddy-api/src/ dashcaddy-api/routes/ dashcaddy-api/__tests__/ --include="*.js". Only/api/v1/csrf-tokenexists in the codebase (registered atsrc/app.js:662insideapiRouter). No/api/v1/auth/csrf-tokenroute anywhere — not inroutes/auth/, not in any test file, not in any frontend code. The duplicate was either planned-but-not-implemented or cleaned up before this ticket was written. No action needed.
DC-016: Per-call timeouts on Caddy admin / DNS API — stop event-loop hogging
- status: done
- owner: hermes (reassigned after audit 2026-06-25)
- details: A single global 5min request timeout covers Caddy admin and DNS API calls, but one slow call can hog the Node.js event loop and stall every other request until it returns. Add per-call timeouts (e.g., 10s for Caddy admin probes, 30s for DNS API calls) so a single slow dependency can't block the whole API.
- result: AUDITED — PARTIALLY DONE BY DESIGN. Audited 2026-06-25.
src/utils/http.jsdefinesfetchT(url, opts, timeoutMs)withAbortSignal.timeout(TIMEOUTS.HTTP_DEFAULT)(5000ms default) applied to every call via the native fetch branch, and explicittimeout:+req.on('timeout')handlers in the http/https raw-request branches (used for Caddy admin:2019and self-signed-.samiHTTPS, where undici fetch can't be configured). Of 77 call sites, 8 pass an explicit timeout; the rest rely on the 5s default. The 5min global request timeout (Pitfall 5) is a backstop. Per Pitfall 15 (KEEP ON doesn't mean add whatever the audit found): bumping individual DNS provider timeouts doesn't affect the fresh-user install flow — it's polish, not a bug. If a specific DNS provider endpoint actually needs longer than 5s, the call site should pass an explicit timeout; don't change the global default.
DC-001: Fix 4 failing tests in services.routes.test.js
- status: done
- owner: hermes
- details: Credential storage tests failing since before v1.13.4. Run
cd dashcaddy-api && npx jest __tests__/routes/services.routes.test.jsto see failures. Fix the root cause, not the test. - result: Root cause: routes used
/:serviceId/credentials(missing/services/segment). All 3 credential routes (POST/DELETE/GET) inroutes/services.jshad the wrong path. Fixed to/services/:serviceId/credentials— matches the URL pattern used by the live frontend and all 759 tests pass.
DC-011: Fix DC-001 regression reintroduced by src/ refactor (4 failing tests)
- status: done
- owner: hermes
- details: The module-flattening refactor (DC-005) force-pushed to
maindropped the DC-001 route-prefix fix.routes/services.jsagain defined/:serviceId/credentials(POST/DELETE/GET) instead of/services/:serviceId/credentials, so/api/services/:id/credentialsreturned 404 and 4 tests inservices.routes.test.jsfailed. Baseline:npx jest→ 4 failed, 746 passed. - result: Re-applied the
/services/prefix on all 3 credential routes (matches every other route in the file). Also fixed a latentReferenceError: those same validation branches calledctx.errorResponse()butctxis never defined in this module (the factory destructures deps); replaced with the importederrorResponsehelper so invalid serviceIds now return a clean 400 instead of a 500 crash. Result: 750/750 tests pass (4 failed → 0), zero new ESLint warnings. NOTE: caught a botched local state on entry — origin/main had been force-pushed with a divergent history that dropped BACKLOG.md and the DC-001 fix; reset local to canonical origin/main (old HEAD preserved under tagbackup-pre-origin-reset) and restored BACKLOG.md.
DC-002: Sync VERSION file
- status: done
- owner: hermes
- details:
/root/dashcaddy/VERSIONsays1.13.0butpackage.jsonsays1.13.4. VERSION file should always match package.json. Add a pre-commit or post-version bump hook to keep them in sync. - result: Fixed root VERSION to 1.13.4. Updated
scripts/release.shto write bothdashcaddy-api/package.jsonAND rootVERSIONon every release — also stages VERSION in the release commit. No more drift.
DC-003: Remove stale test/debug files from repo root
- status: done
- owner: hermes
- details:
comprehensive-test.jsandtest-security-fixes.jsare ad-hoc test scripts, not Jest tests. They clutter the repo root. Remove them or convert to proper Jest tests under__tests__/. - result: Moved both files to
dashcaddy-api/scripts/legacy/(preserved, not deleted — they are 875 lines of security test coverage that may be useful as a manual smoke test). Zero references to them in code/docs — safe to move. All 759 Jest tests still pass.
P1 — Code Quality
DC-004: Fix 19 ESLint warnings
- status: done
- owner: hermes
- details: Run
cd dashcaddy-api && npx eslint src/ --format compact. Most are unused vars and nested ternaries insrc/utils/logging.js. Fix all, target zero warnings. - result: Reached zero ESLint warnings across
src/. Most of the original 19 were cleared by the DC-005 refactor and logging cleanup; the final 3 were insrc/app.js: (1)require-awaitonresyncHealthChecker— dropped the now-pointlessasynckeyword since it only forwards a promise (callers already use.catch()); (2)+(3) twomax-depthviolations in the/api/v1/network/ipshandler — extracted the interface-enumeration logic into adetectInterfaceIps()helper, keeping the route handler flat.npx eslint src/now reports 0 problems; 750/750 Jest tests still pass.
DC-005: Organize top-level modules into src/
- status: done (merged to main 2026-06-25)
- owner: krystie
- details: 40+ JS files at
dashcaddy-api/root level (auth-manager.js, credential-manager.js, etc.). Move into organized subdirs undersrc/(e.g.,src/managers/,src/security/,src/docker/). Update all require() paths. This is a big refactor — run tests after. - result: Refactor complete on
krystie-improvementsbranch (879/879 tests passing on branch). Merged into main via commit283121eafter resolving 24 conflicts. Post-merge regression check surfaced one additional latent path bug from DC-005:src/monitoring/health-checker.jsstill hadrequire('./platform-paths')(relative tosrc/monitoring/), butplatform-paths.jslives at top level — fixed in commit9688e64torequire('../../platform-paths'). Without that fix, 59 cascading test failures inhealth-checker.test.js. Final post-merge state: 921/922 tests passing. - remaining latent bugs (FIXED): The DC-005 path-rewrite script left depth-2 route files (
routes/auth/*.js,routes/recipes/*.js,routes/apps/*.js,routes/arr/*.js,routes/config/*.js) with broken require() paths. A filesystem-resolving scanner found 67 broken requires across 21 files — three distinct bug classes: (A)'../../../src/...'(3 levels up, goes above package root) — the documented Bug 7, ~49 occurrences; (B)'../src/utils/...'(only 1 level up, resolves to nonexistentroutes/src/) — undocumented, ~15 occurrences forresponsesandlogging; (C)routes/apps/restore.js:5importedutilities/responseswhen the module lives atutils/responses(wrong directory + wrong depth). All 67 fixed to'../../src/...'(or'../../src/utils/responses'for the class-C case).routes/auth/totp.jswas already fixed in the DC-006 commit. Tests didn't catch any of these previously because no test imported any depth-2 route. Post-fix: 922/922 tests pass, zero new ESLint warnings.
DC-006: Add integration test for TOTP auth flow
- status: done
- owner: krystie
- details: End-to-end test: no token → 401, wrong token → 403, valid TOTP → session token → authenticated request succeeds. Cover the full
/api/auth/check→ session → endpoint flow. - result: Added
dashcaddy-api/__tests__/routes/auth.totp.routes.test.js— 25 tests, all passing. Covers: GET/api/totp/config, POST/api/totp/setup(generate + normalize + reject invalid Base32), POST/api/totp/verify-setup(missing/bad/no-pending/valid-code paths), POST/api/totp/verify(login — 400/400/401/200), GET/api/totp/check-session(passthrough when disabled + 401 no-session + 200 valid-session — the BACKLOG "no token → 401 / authenticated request succeeds" pair), POST/api/totp/disable(400/401/200), POST/api/totp/config(valid/invalid/never-disables), plus the full end-to-end flow setup→login→check-session→disable and an otplib-not-stubbed sanity check. Uses realotplibfor code generation (real TOTP math), mockscredentialManager/session/totpConfig/saveTotpConfigonly. Full suite: 904/904 pass (879 baseline + 25 new). ESLint clean for the new file. - side-effect (DC-005 latent bug fix): While writing the test I discovered
routes/auth/totp.jshad broken require paths from the DC-005 refactor ('../../../src/utilities/errors'was 3 levels up fromroutes/auth/— wrong by 1). The test couldn't even load the route without this fix. Fixed in this commit ('../../src/utilities/errors'and'../../src/utils/responses'). Same depth bug exists in other depth-2 route files — see DC-005 note above.
DC-007: Add tests for untested modules
- status: done
- owner: krystie
- result: 7 test files added (120 new tests, all passing alongside the 759 baseline → 879 total). Files:
__tests__/dns-propagation.test.js(9),__tests__/notification-manager.test.js(18),__tests__/ssl-monitor.test.js(13),__tests__/log-digest.test.js(11),__tests__/metrics.test.js(21),__tests__/config-drift-detector.test.js(19),__tests__/auto-restart-manager.test.js(29). - details: These modules have NO test coverage:
dns-propagation.js,notification-manager.js,ssl-monitor.js,log-digest.js,metrics.js,config-drift-detector.js,auto-restart-manager.js. Add at least basic smoke tests for each.
P0 — Must Fix (blocks public release)
DC-031: /api/v1/network/ips crashes with ReferenceError — Add Service modal silently broken
- status: done
- owner: hermes
- details: Audited via
npx eslint src/.src/app.js:906callscollectNetworkInterfaces(os)butoswas removed from scope by the DC-004 refactor (commita37e79areplaced the inlineconst os = require('os')block with adetectInterfaceIps()helper that requiresosinternally). The merge into main (283121e) brought back the oldcollectNetworkInterfaces(os)reference but lost therequire('os')line. Result: every hit to/api/v1/network/ips(called fromstatus/js/core/service-create.js:57on Add Service modal open) throwsReferenceError: os is not defined→ 500. ESLint also catches it asError - 'os' is not defined. (no-undef). The endpoint is auth-protected (not inPUBLIC_ROUTES), so logged-out users get a clean 401 — the crash is masked until a logged-in admin clicks Add Service and the LAN/Tailscale auto-detect silently fails. Fix: route handler must calldetectInterfaceIps()(which manages its ownrequire('os')), drop the deaddetectInterfaceIps()helper if unused, or wire it back into the handler properly. Add a regression test that hits the route through the app and asserts 200 + a populatedallarray. - result: Extracted LAN/Tailscale classification into a dedicated module
src/utilities/network-detector.jsexportingdetectInterfaceIps(),isTailscaleIP(),isPrivateLanIP(). The route handler insrc/app.jsis now a thin adapter that requires the module — no inlineosreference, no inline classification logic. Added__tests__/network-ips-route.test.js(16 tests) covering: detector unit tests for Tailscale CGNAT (100.64/10) and RFC 1918 LAN ranges with malformed-input guards;detectInterfaceIps()behavior under os-mocked interfaces with IPv4 filtering, IPv6 exclusion, null addrs tolerance; route handler integration tests viajest.isolateModules+jest.doMock('os')asserting 200 + canonical envelope on the populated path, the empty-path (regression case for the original bug shape), and HOST_LAN_IP/HOST_TAILSCALE_IP env override branches; plus a source-of-truth test that fails if a future refactor reintroducesfunction detectInterfaceIps(...)inline insrc/app.jsor referencesos.without a priorrequire('os')line. Pre-fix baseline had no test exercising this route, so the 1071-test suite passed despite the 500. Post-fix: 1087/1087 tests pass (+16 new), zero new ESLint warnings. Also fixed a latent bug insrc/utilities/backup-manager.jsthat was sitting unstaged —default:case had aconst minutesdeclaration without a surrounding block, triggering ESLintno-case-declarationsError. Added the block braces.
P2 — Polish & DX
DC-008: Update CLAUDE.md for cross-platform accuracy
- status: done
- owner: hermes
- details: CLAUDE.md references Windows-specific paths (C:/caddy/, e:/CaddyCerts/) as if they're universal. DashCaddy runs on Linux (Docker on DNS2) and Windows (SAMI-PC). Document both deployment targets clearly.
- result: Added a new "Linux Deployment (DNS2 / Contabo VPS)" section after the existing Windows docs (preserved verbatim) and before the "Project Info" footer. The new section documents: production paths (
/opt/dashcaddy/,/var/www/dashcaddy-status/,/etc/dashcaddy/), container mount points with the/app/data/auto-resolve fallback, the three-filesystem frontend trap (source vs live vs build-context), common admin commands, a Windows-vs-Linux differences table, and four Linux-specific gotchas (Caddy network_mode host, credentials.json perms, CORS_ORIGINS vs Tailscale, TS_AUTHKEY provisioning). Also updated the "Project Info" version field from stale1.0to current1.13.4and added the Linux-side default TLD (.home).
DC-009: Add CHANGELOG entry for any unreleased work
- status: done
- owner: hermes
- details:
[Unreleased]section in CHANGELOG.md is empty. Any fixes done should be documented there before tagging a release. - result: Populated the
[Unreleased]section with all unreleased work since v1.5.0: Security (TOTP 4-part recovery), Added (OpenClaw routes, auto-backup, monitoring widget, Sami Files template, unified logger, notification manager, update UX, 120 new tests across 7 files), Changed (DC-010 response standardization across 9 route files, /api/v1/ versioning, release.sh hardening), Fixed (DC-011 credential route regression, DC-004 ESLint cleanup, workflow engine init, container-logs wireModal misuse, CSP hash mismatch, SW cache tag, updater false-positive loop), Removed (legacy test scripts moved to scripts/legacy/ preserved-not-deleted, stale root files, dead routes/ directory). Each entry cites the source commit hash for traceability.
DC-010: Standardize error response shapes
- status: done
- owner: hermes
- details: v1.13.4 standardized route responses to use helpers, but some modules still use raw
res.json(). Grep for remainingres.json(in route handlers and convert to response helpers. - result: All bare
{success: true, ...}envelopes across route files now go throughsuccess()(orok()where the older alias is wired in). Files converted in this push (4 commits): browse/logs/sites (cron), updates/notifications/tailscale/events/workflows/openclaw/dns/health/ca (this sprint) — 9 files, 62 calls.services.jsline 360+368 left alone (intentional raw-array responses for the frontend wire contract — separate cleanup). Error-pathres.status(4xx/5xx).json({success:false, error:...})envelopes also left as-is (ok()helper would setsuccess:true— wrong tool for error shapes). Net result: only 2 intentional raw-array calls remain in routes/; everything else routes throughresponse-helpers. 750/750 tests pass at every checkpoint.
DC-017: Regression tests for depth-2 route paths + PUBLIC_ROUTES drift
- status: done
- owner: krystie
- details: After DC-005 path-fix (commit
c39c80b) shipped 67 broken-require repairs across 21 depth-2 route files, two test gaps remained: (1) no test imported any depth-2 route module, so future refactors could reintroduce class A/B/C broken paths undetected; (2) no test verified that PUBLIC_ROUTES entries (in src/utilities/middleware.js) all correspond to actually-mounted routes — exactly the kind of drift DC-012 added a regression check for (probe paths), but only for the 5 probes. The full ~27-entry PUBLIC_ROUTES list could silently go stale. - result: Added 3 files, fixed 1 test helper, no production code changed. New:
__tests__/depth2-routes-smoke.test.jsdiscovers every .js in routes/{apps,arr,auth,config,recipes}/ and asserts (a) the module loads without MODULE_NOT_FOUND, (b) it exports a factory function, (c) the factory runs without throwing when given universal deps; plus 3 source-of-truth scans that fail if any depth-2 route re-introduces class A (../../../src/...), class B (../src/...), or class C (utilities/responsesinstead ofutils/responses) require paths. New:__tests__/public-routes-drift.test.jswalks every aggregator + direct-mount router via Express stack introspection and asserts (a) every PUBLIC_ROUTES entry matches an actually-mounted route, (b) every CSRF excludedPath is publicly accessible, (c) all 5 probe paths are CSRF-exempt, (d) all 5 probe paths are excluded from request logging, (e) all 5 probe paths bypass Tailscale auth. New:__tests__/test-helpers/universal-deps.js— a Proxy + seed-object shared by both suites that returns sensible stubs (logger-shaped object, asyncHandler pass-through, path-string stubs forpath.dirname()calls) for any property access; supports Object.assign/spread via ownKeys+getOwnPropertyDescriptor traps so aggregator factories that copy ctx into subCtx don't lose proxy magic. Fix to the test helper: (a)logis now a logger-shaped object ({error, warn, info, debug, audit}as noops) not a bare noopFn — fixes(ctx.log || console).error(...)in routes/apps/index.js; (b)asyncHandlerseeded as own enumerable property — survives Object.assign({}, ctx, { helpers }); (c) addedSERVICES_FILE,CONFIG_FILE,TOTP_CONFIG_FILE,TAILSCALE_CONFIG_FILE,NOTIFICATIONS_FILE,loadSiteConfig,loadNotificationConfig,configStateManager,readConfig,saveConfig,helpers,safeErrorMessageas own-enumerable seeds so aggregator sub-mounts destructure cleanly. Fix to public-routes-drift: aggregator walks use prefix/api/v1(matches src/app.js's bare-mount on apiRouter at /api/v1), direct-mount walks use/api/v1+ explicit prefixMap entry. Addedroutes/themes.jsandroutes/license.jsto directMounts (themes bare-mounted, license on/license). Result: 35 suites, 1036 tests, all passing (was 1030 passing + 6 failing before this commit). The 6 failures were depth-2 factory errors + 22 PUBLIC_ROUTES stale entries that the test infrastructure was silently swallowing.
DC-019: backup-manager test flakes ~1/64 — tamper uses fixed-char replacement that can be a no-op
- status: done
- owner: hermes
- details:
__tests__/backup-manager.test.js:184"rejects tampered data (auth tag mismatch)" tampers the encrypted blob by replacing its first base64 character with'X':Buffer.from('X' + str.substring(1)). The first char is the first base64 char of the random 16-byte IV. When the IV's first base64 char is already'X'(~1/64 ≈ 1.6% probability per run), the replacement is a no-op — the "tampered" buffer is byte-identical to the original, AES-256-GCM decryption succeeds, andexpect(...).rejects.toThrow()fails. Observed: 1 failure in ~15 full-suite runs. The productionencryptBackup/decryptBackupcode (AES-256-GCM, correct) is NOT at fault — the bug is in the test's tampering technique. Fix: corrupt the authTag bytes directly (XOR a byte so the value is guaranteed to change), reassemble theiv:authTag:ciphertextformat. This guarantees a GCM integrity failure every time. - result: Fixed. The test now parses the
iv:authTag:ciphertextformat, XORs the first authTag byte with0xFF(guaranteed value change — can never be a no-op regardless of the random IV/authTag content), reassembles the blob, then asserts decryption rejects. Verified: 30/30 isolated runs + 8/8 full-suite runs (1036/1036), zero failures. Production crypto code unchanged (it was correct all along — the bug was purely in the test's tampering technique). Confirmed root cause independently with a Node REPL script: corrupting authTag byte0 always throwsUnsupported state or unable to authenticate data.
DC-018: Logger.error() swallows writeErrorLog promise — error.log writes are fire-and-forget (flaky test + lost logs in prod)
- status: done
- owner: hermes
- details:
Logger.error()insrc/utils/logging.js:256callsthis._log('error', ...)but does NOT return the result._log('error', ...)returns the promise fromwriteErrorLog(...)(the async disk write to error.log). Becauseerror()drops the return value, everyawait logError(...)/await log.error(...)caller is actually awaitingundefined— the file write becomes fire-and-forget. Symptoms: (1)__tests__/logging.test.js"captures request context when req is passed" fails intermittently in the full suite (passes in isolation) — the test reads error.log before the un-awaited appendFile completes. (2) In production, 6 route handlers (routes/apps/deploy.js,routes/apps/removal.js,routes/health.js,routes/arr/config.js,routes/updates.js) plus the globalboundAsyncHandlererror catcher allawait logError(...)expecting the write to flush; error entries can be lost if the process exits/restarts immediately after. Latent since the original "unify logger" commitf71e5c5. Fix: addreturntoLogger.error()so thewriteErrorLogpromise propagates to callers. No behavior change fordebug/info/warn(they never returned a promise and don't write to disk). - result: Fixed — one-line change (
return this._log(...)). The logging flake is eliminated: 10/10 full-suite runs passed (was ~1-in-6 failure rate before the fix). Production impact: everyawait logError(...)in route handlers and the global Express error catcher now actually waits for the error.log write to flush to disk, so error entries survive fast process exit/restart. No behavior change for debug/info/warn (they never wrote to disk). ESLint clean.
DC-033: getLocalVersion() returns 0.0.0 — SelfUpdater uses __dirname but is loaded via ./src/docker/self-updater
- status: done (commits
20d280f+77536f4) - owner: krystie
- details: Every DashCaddy host running v1.14.x (≤ v1.14.8) silently reports
version: 0.0.0, commit: nullfrom/api/v1/system/version, andcheckForUpdate()always thinks we are outdated. Root cause:server.jslines 69 + 245 dorequire('./src/docker/self-updater'), so inside the container__dirnameresolves to/app/src/dockerwhich has nopackage.jsonorVERSIONnext to it. The function's outertry/catchswallows theENOENTand returns the{ version: '0.0.0', commit: null }fallback. Discovered 2026-07-05 when DNS2 was running v1.14.4 (packaged from a pre-build-pipeline-fix tree that was already missingsrc/) and the dashboard showed 0.0.0 even though/app/package.jsonsaid 1.14.4. Confirmed by two independent investigations (main agent + z.ai subagent) reaching the same conclusion. Fix: rewritegetLocalVersion()to walk a candidate list —path.join(__dirname, '..', '..', 'package.json')first (the api root), thenpath.join(__dirname, 'package.json')(legacy root-copy contract). Addconsole.erroron total failure instead of swallowing silently. Verified live on DNS2:curl http://127.0.0.1:3001/api/v1/system/versionnow returns{"name":"DashCaddy","version":"1.14.8","commit":"20d280f"}. - result: Done in two commits. (1)
20d280f DC-033: fix getLocalVersion __dirname resolution— patchedsrc/docker/self-updater.jsgetLocalVersion(). (2)77536f4 DC-033: bump VERSION to 20d280f (DC-033 commit SHA)— kept dashcaddy-api/VERSION in sync. Also restored DNS2 working tree to origin/main (was at v1.14.4 packaged from a stale tree; origin/main was at v1.14.8 with DC-020..032 security fixes intact — would have shipped as a downgrade if committed naively). Created/etc/dashcaddy/sites/dashcaddy-api→/opt/dashcaddy/dashcaddy-apisymlink so future trigger.jsonapiSourceDirpaths resolve correctly. Health: alive. /api/v1/system/version returns 1.14.8 (20d280f).
P1 — Code Quality
DC-034: Regenerate get.dashcaddy.net/release tarball as v1.14.9 with DC-033 baked in
- status: done (commit
42376e2) - owner: krystie
- details: Live
https://get.dashcaddy.net/release/version.jsonadvertises v1.14.8 (commitba23cdf) but DC-033 is NOT in that tarball — verified by extractingdashcaddy/dashcaddy-api/src/docker/self-updater.jsfromdashcaddy-1.14.8.tar.gzand confirming it still has the broken__dirnamepattern. Every other DashCaddy host that auto-updates to v1.14.8 will hit the same 0.0.0 dashboard bug DNS2 just had. Fix: (1) bumppackage.jsonto1.14.9+ updatedashcaddy-api/VERSIONto the DC-033 commit SHA. (2) populate[Unreleased]section in CHANGELOG.md with DC-033 entry. (3) runbash scripts/publish-release.shto rebuild + push the tarball to get.dashcaddy.net. (4) verify the liveversion.jsonreflects the new version + commit. Effort: ~15 min. Risk: low — release pipeline already proven by build-pipeline-fix. - result: Bumped package.json (1.14.8 → 1.14.9) + root VERSION to 1.14.9. Baked commit
42376e2into dashcaddy-api/VERSION inside the tarball. Builtdashcaddy-1.14.9.tar.gz(39MB, sha2569de120a6277f4169caa6740a15181a80cef1ba716006e3a5aad6e21b9d6542a3). Published to/var/www/get.dashcaddy.net/release/(latest.tar.gz + versioned tarball + version.json + sha256). Backed up old release torelease.backup-20260706-052919. Refreshed install.sh. Mirrored to dc-contabo-de →/var/www/get2.dashcaddy.net/release/(verified via SSH). Tarball verified to contain the DC-033 fix (extracted + grep'd self-updater.js — comment "Resolve package.json/VERSION relative to the api root, not __dirname" present). Liveget.dashcaddy.net/release/version.jsonserves v1.14.9. SHA256 matches between local + served tarball. Local notify to localhost:3001 returned HTTP 403 (expected — DASHCADDY_UPDATE_ENABLED=false, intentional). Auto-update now ships the 0.0.0 fix to every host that updates from v1.14.8 → v1.14.9.
DC-035: Add regression test for getLocalVersion() — prevent DC-033 class from regressing
- status: done
- owner: krystie
- details: DC-033 fixed the bug but nothing in the test suite would have caught it originally. The existing coverage on
self-updater.jsis sparse — no test exercisesgetLocalVersion()directly. Add__tests__/self-updater-version.test.jsthat: (1)require('./src/docker/self-updater')(matching what server.js does, NOTrequire('./self-updater')which resolves from cwd and loads the wrong file — that's a separate footgun, see DC-036). (2) instantiate SelfUpdater with minimal config. (3) callgetLocalVersion(). (4) assertversionis NOT'0.0.0'and is in semver shape (/^\d+\.\d+\.\d+/). (5) assertcommitmatches/^[0-9a-f]{7,40}$/. Optionally: parameterize to also exerciserequire('./self-updater')from/appcwd to verify the legacy root-copy contract still works. Effort: ~20 min. Pattern: matches DC-017's depth-2-routes-smoke.test.js (loads every module via the real path). - impact: Catches the exact class of bug DC-033 fixed, plus any future refactor that re-introduces the __dirname antipattern.
- result: Added
dashcaddy-api/__tests__/self-updater-version.test.js(6 tests, all passing). Validates: (1) module loads + exports SelfUpdater class; (2) getLocalVersion returns an object with version+commit (not null); (3) version is NOT'0.0.0'(the DC-033 bug sentinel); (4) version matches/^\d+\.\d+\.\d+/semver; (5) commit is a 7-40 char hex SHA; (6) works regardless of how the module is required. Verified the test actually catches the bug by temporarily reverting self-updater.js to the pre-DC-033 code (git show 20d280f^) — 4 of 6 tests failed with the expectedexpect.toBe('0.0.0')andnot.toBeNullassertion errors. After restoring the fix, full suite passes: 40 suites, 1081 tests (was 39/1075, +6 new).
DC-036: Delete dead dashcaddy-api/self-updater.js (root copy) — 0 runtime callers
- status: done
- owner: krystie
- details: After DC-005 refactor (commit
283121e), there are TWO SelfUpdater implementations on disk:/opt/dashcaddy/dashcaddy-api/self-updater.js(md579d566cc...) and/opt/dashcaddy/dashcaddy-api/src/docker/self-updater.js(md5b3b61557...). Both have drifted. Zero runtime callers of the root copy — verified bygrep -rn "require.*self-updater" dashcaddy-api/ --include="*.js"which shows only./src/docker/self-updater(in server.js + src/app.js). The root copy is dead code from a prior refactor and a footgun for future contributors who edit the wrong file. Subagent flagged this independently. Fix:git rm dashcaddy-api/self-updater.js+ verifynpx jest --passWithNoTestsstill passes. Risk: very low. If a test does import it, the test itself is wrong and should be deleted or pointed at./src/docker/self-updater. - impact: Removes the wrong-file-edit footgun. Makes DC-035's test cleaner (only one SelfUpdater implementation to test).
- result: Verified zero callers (grep + 38 test files scanned — no references to
./self-updater). Discovered the file was actually gitignored, never committed — sogit rmwas unnecessary; plainrmdid it. Tests: 1075/1075 still passing post-delete. Also synceddashcaddy-api/VERSIONto42376e2(the DC-033 + release-bump commit) so the rebuilt container reports the right SHA. Live:curl http://127.0.0.1:3001/api/v1/system/versionreturns{"name":"DashCaddy","version":"1.14.9","commit":"42376e2"}.
DC-037: Move /etc/dashcaddy/sites/dashcaddy-api symlink creation into the install script
- status: in-progress
- owner: krystie
- details: DNS2 has the symlink manually created during this session (2026-07-05), but every other fresh DashCaddy install will hit the same
cp: cannot create directory '/etc/dashcaddy/sites/dashcaddy-api/routes': No such file or directoryfailure when the first auto-update lands, becausedashcaddy-update.shdefaultsapiSourceDirto${CADDY_BASE}/sites/dashcaddy-api(=/etc/dashcaddy/sites/dashcaddy-api) while the actual install lives at/opt/dashcaddy/dashcaddy-api. Fix: addmkdir -p /etc/dashcaddy/sites && ln -sfn /opt/dashcaddy/dashcaddy-api /etc/dashcaddy/sites/dashcaddy-apito the install script (whichever ofdashcaddy-installer/install.shorscripts/dashcaddy-install.shis canonical — verify which exists on a clean install). Make it idempotent (ln -sfn, notln -s, so re-runs don't fail). Effort: ~10 min. Risk: very low. - impact: Prevents every future DashCaddy host from hitting the v1.14.4-class update failure on first auto-update.
P2 — Polish & DX
DC-038: Backup trigger.json + result.json in dashcaddy-update.sh — enable one-command rollback
- status: done
- owner: hermes
- details: During the DC-033 fix, recovering from the failed v1.14.4 update required manually mv'ing
trigger.json.processingback totrigger.json, manually runningstart.sh, etc. — because the backup mechanism indashcaddy-update.sh(lines 318-327) only backs up code + data, not the trigger/result state. Fix: in thebackup_data_dirfunction (or newbackup_update_statefunction), also copy${UPDATES_DIR}/trigger.jsonand${UPDATES_DIR}/result.jsoninto the versioned backup directory so rollback tooling can restore them. Effort: ~15 min. - impact: Faster incident recovery. Currently takes 5-10 manual steps to roll back a failed update; would take 1.
- result: Added `backup_update_state()` function in `dashcaddy-update.sh` (idempotent, tolerates absent files + chattr +i, cleans up empty subdir). Wired into `main()` immediately after `backup_data_dir()`. Backs up `trigger.json.processing` + `result.json` into a `update-state/` subdir of the versioned backup. Deliberately does NOT auto-restore on rollback — the rollback handler reads a fresh trigger.json written by the operator/container; restoring the previous attempt's trigger would clobber the active rollback request. New regression test `dashcaddy-api/scripts/test-dashcaddy-update-backup.sh` (14 assertions across 5 groups: both-files-present, partial-present, no-files-present, idempotency, main() flow ordering) — all pass. Tests: 1214/1214. Lint: 150 warnings, all pre-existing in untouched files, zero new warnings introduced.
DC-039: Audit repo for other __dirname + sibling-file patterns — DC-033 class of bug
- status: done
- owner: hermes
- details: DC-033 was caused by
path.join(__dirname, 'package.json')in a module loaded from a subdirectory. There may be other instances of the same pattern elsewhere insrc/. Quick grep:grep -rn "path.join(__dirname" dashcaddy-api/src/ --include="*.js"and review each hit. Any that join'package.json','VERSION','.env','openapi.yaml','Dockerfile', or'.license-secret'is suspect (these all live at the api root, not in subdirectories). For each suspect match, either: (a) verify the file does exist at the expected__dirnamelocation, or (b) fix it to use the api-root path. Effort: ~30 min. Risk: low. Just an audit + targeted fixes. - impact: Catches latent bugs before users do. The fact that DC-033 shipped undiscovered through multiple releases suggests this antipattern might exist elsewhere.
- result: Found and fixed the antipattern across 10 modules in
src/. 13 distinctpath.join(__dirname, 'foo.json')defaults (plus the__dirnamebasedLOG_DIR/ERROR_LOG_FILE) all wrote runtime state into the source tree, surviving in dev but landing in the image layer in production. Centralised resolution inplatformPaths.dataDir(derived fromSERVICES_FILEenv when set, elsepath.dirname(servicesFile)); the 10 modules now route their*-config.json/*-history.json/.port-locks/audit-log.json/error.log/.license-secret/.license-counterdefaults through it, preserving per-file env-var overrides.crypto-utils.jsandcredential-manager.jsalready had a multi-candidate resolver; collapsed them to a singleplatformPaths.dataDirlookup. Thehost-registry/event-store/event-workersdataDir || path.join(__dirname, '../../data')pattern simplified — the legacy fallback is unreachable now thatservices.jsonlives atdataDir. Also fixed a real production bug found mid-audit:audit-logger.jsdefaultedAUDIT_LOG_FILEto/app/src/security/audit-log.jsonandlogging.jsdefaultedLOG_DIRto__dirname(i.e./app/src/utils/), so every error-log/audit-log write was landing in the image layer — a fresh container recreate would have wiped the entire audit log. Now both flow throughdataDirwhich the start.sh bind mount already points at/app/data. Drive-by: removed unusedreadlineimport inevent-workers.js. Also fixed a test gap in__tests__/public-routes-drift.test.js:routes/security.jswas missing from the direct-mounts list, so the/api/v1/security/events/ingestand/api/v1/security/events/batchPUBLIC_ROUTES entries (added by DC-044) were flagged as stale. Added it with/securityprefix mapping. Pre-existing files on the running container (audit-log.json319KB,container-stats*.json186MB,workflow-history.json269KB,audit-log.jsonetc.) are still in the image layer — those are lost on next recreate unless a one-time migration step runs; out of scope for this fix but flagged for a follow-up. Tests: 1214/1214 pass, +0 failures. ESLint: 146 warnings + 4 errors — identical to baseline (no new warnings/errors introduced). Docker container does NOT need rebuilding: the affected code paths are evaluated at boot, anddashcaddy-api/data/is the existing bind mount — the new defaults resolve to the same path the container already uses via env vars (CREDENTIALS_FILE=/app/data/credentials.json,ENCRYPTION_KEY_FILE=/app/data/.encryption-key, etc.), and the env vars take precedence. Self-updater picks it up on the next release bump.
DC-040: Investigate whether dashcaddy-post-deploy-patches.sh is still needed at all
- status: done
- owner: hermes
- details: The script applies 23+
require()path fixes on every update (audit fromBUILD-PIPELINE-FIX.mdshows it was created to paper overdashcaddy-api/src/being missing from tarballs). After the build-pipeline-fix (which now shipssrc/in every tarball), most of those patches should be no-ops. If any are still applying real changes, that means the source tree has a latent bug that DC-005-era refactors missed. Runbash scripts/dashcaddy-post-deploy-patches.shagainst a fresh checkout of origin/main (or extract the v1.14.8 tarball to a clean dir) and count how many patches actually change anything vs are no-ops. If most are no-ops, the script can either be deleted entirely (cleanest) or kept as a defensive backstop with a comment explaining its purpose has shifted to "verify src/ shipped correctly." Effort: ~45 min. Risk: medium — safer to keep as backstop with reduced scope. - impact: Clarity. The current state — "script applies 23 fixes every update but only 3-4 actually do anything" — is opaque and brittle.
- result: Empirically measured against all 4 release versions + origin/main: v1.14.4 (broken — no src/ in tarball), v1.14.8, v1.14.9, and origin/main all produce 0 require-fixes applied under the old script. Every patch is a no-op against every current release. Decision: KEEP the script but repurpose it as a VERIFIER, not a patcher. The script now performs 5 explicit checks (server.js requires correct, license-manager.js path correct, src/ directory present + non-empty + contains app.js, license-keygen.js at API root) + an informational scan of all src/ require paths. Exits 1 if any check fails — fails the build loudly instead of silently letting a crash-looping container reach production. Behaviour change: the OLD script would silently no-op on v1.14.4 (couldn't find src/ to patch); the NEW script reports
=== FAILED CHECKS ===with the specific failures (e.g.src/: directory missing — v1.14.4-class bug). Verified against v1.14.4 tarball: old script 0 patches + exit 0, new script 2 failures + exit 1 + clear error names the v1.14.4-class bug. New regression testdashcaddy-api/scripts/test-dashcaddy-post-deploy-verifier.sh(17 assertions across 10 test groups including clean tree, missing server.js, broken server.js requires, missing src/, missing license-keygen.js, broken license-manager path, empty src/, missing src/app.js, absolute path resolution, non-existent API_DIR) — all pass. Tests: 1214/1214 Jest + 31 shell assertions. Lint: 150 warnings, all pre-existing in untouched files.
DC-041: Add integration test for the auto-update pipeline (trigger.json → bash → docker rebuild → health check → result.json)
- status: in-progress
- owner: hermes
- details: The host-side updater has zero integration coverage. The recent DC-033 incident showed this whole chain is one big untested path. Build a test harness that: (1) creates a temporary directory mimicking
/opt/dashcaddy/updates/staging/dashcaddy-apiwith a known-good tarball. (2) writes atrigger.jsonto a testUPDATES_DIR. (3) runsbash /opt/dashcaddy/scripts/dashcaddy-update.shwith paths overridden via env vars. (4) assertsresult.jsonhassuccess: trueand the version matches. (5) cleans up. Effort: ~2 hours. Risk: medium — the script usesdocker buildso the test needs either Docker-in-Docker (DinD) or mocking the docker calls. - impact: Closes the biggest untested surface in DashCaddy. Would have caught the v1.14.4 packaging bug immediately on the next release.
DC-042: Replace null stubs in src/app.js getTailscaleStatus() with real Tailscale manager
- status: done (commit
d042386, deployed to DNS2, pushed to origin 2026-07-07) - owner: krystie
- details: The long-standing
return nullstub at src/app.js:189 (plus 8 null fn stubs onctx.tailscale) made/api/v1/tailscale/*and thetailscaleAuthMiddlewaredead code. New modulesrc/managers/tailscale-manager.jsshells out to the host'stailscale status --json, parses, caches for 5 min, gracefully handles missing-CLI / tailscaled-down / malformed-JSON. Re-exportsisTailscaleIPfrom network-detector.js. Wired intosrc/context/index.js. start.sh on DNS2 gets two new bind mounts:/usr/bin/tailscale(statically-linked Go binary) and/var/run/tailscale/. Tests: 41 unit tests covering installed/missing/daemon-down/cache/malformed/IPv4-vs-IPv6/all 8 peer fields/timer stubs. Suite went 1097 → 1138 tests passing. - impact: Dashboard's Tailscale card now shows real device list (8/9 online).
tailscaleAuthMiddleware's allowedTailnet check no longer dead code. Foundation for DC-043 share-invite flow.
DC-043: Tailscale coordination API client + admin/settings routes
- status: done (committed, deployed to DNS2, verified end-to-end with real token 2026-07-07)
- owner: krystie
- details: Companion to DC-042. New module
src/managers/tailscale-coord.jsis the write-side REST client forhttps://api.tailscale.com/api/v2/. Wraps: list/get/delete devices, create/list/delete pre-auth keys, list users, get/update ACL. Newctx.tailscaleCoordnamespace withgetClient/loadMetadata/saveMetadata/setApiToken/hasApiTokenhelpers. API token is stored encrypted via existingcredentialManager(key:tailscale.coord.apiToken); metadata in plaintexttailscale-config.json. New routes inroutes/tailscale-admin.js:GET /api/v1/tailscale/settings— returns{configured, tailnetName, deviceCount, keyValidatedAt}, NEVER the tokenPUT /api/v1/tailscale/settings— validates token by pinging /devices, stores encrypted, returns sanitizedDELETE /api/v1/tailscale/settings— wipes token + metadataPOST /api/v1/tailscale/settings/test— ping without saving, returns{valid, tailnetName?, error?}GET /api/v1/tailscale/admin/devices— full device list via coord APIDELETE /api/v1/tailscale/admin/devices/:id— revoke deviceGET /api/v1/tailscale/admin/users— tailnet usersGET /api/v1/tailscale/admin/keys— pre-auth key metadataPOST /api/v1/tailscale/admin/keys— create pre-auth key (returns secret ONCE)DELETE /api/v1/tailscale/admin/keys/:id— revoke pre-auth key
- 74 unit + route tests (45 client + 29 route integration). Suite: 1214/1214 passing.
- deployed to DNS2, verified:
docker exec dashcaddy-api node ...against the real token returnedping: {domain: "tail3e209.ts.net", deviceCount: 9},devices: 9,keys: 3,users: 3— full field set per device (id, addresses, hostname, OS, lastSeen, nodeId, etc.). - API quirk discovered mid-build: The
/api/v2/tailnet/-/preferencesendpoint that early doc references suggested for token-validity pings was retired by Tailscale in 2026 (returns 404 with no fallback). ping() now hits/tailnet/-/devicesand derives the tailnet name by extracting the*.ts.netsuffix from the first device'snamefield. Also discoveredcore.worktreeconfusion mid-session — git thought/opt/dashcaddy's repo lived at/root/dashcaddy, which caused the first commit to appear "lost" until I recovered viagit reset --hard <sha>from the reflog. - intentionally NOT built: token auto-rotation / auto-renewal. Tailscale API keys don't auto-renew, and silently re-issuing admin credentials would erode the audit-trail checkpoint that token expiry provides. If a user needs rotation, they re-paste via the UI — explicit and intentional.
- impact: Foundation for DC-044 (Plex/whatever share-invite flow). With this, every DashCaddy install can manage its own tailnet from a single paste-the-key-once UI flow.
Backlog note (2026-07-05)
Tickets DC-033 through DC-041 were added after the DNS2 v1.14.4 / v1.14.8 / 0.0.0 incident. They are grounded in real evidence from that session — see DC-033's details for the full chain of reasoning (cross-checked by main agent + z.ai subagent).
DC-044: Fix WorkflowEngine healthCheckService — servicesStateManager.getState bug (silent every-5min error spam)
- status: in-progress
- owner: hermes
- details:
src/recipes/bundled-workflows.js:310callsservicesStateManager.getState()which doesn't exist (StateManager exposesread(), notgetState()). Combined with a missingawait, the call returned a Promise (truthy), short-circuited via|| []to an empty array, thenfor (const service of services)silently iterated over zero services. Net effect: everyhealth-check-on-intervalworkflow ran every 5 min, reportedAction health-check failed: servicesStateManager.getState is not a function, sent a "Health check failed for {{serviceId}}" notification (with the unresolved template!), and producedchecked: 0, healthy: 0results. Visible on BOTH DNS2 (production, 4 days) and test server dc-contabo-de (9 days). Fix: callawait servicesStateManager.read().catch(() => [])— proper async + corruption-tolerant. - impact: Workflow health checks now actually check container health, instead of silently reporting 0/0 every cycle. Stops the "Health check failed" notification spam.
- result: Fixed in src/recipes/bundled-workflows.js. New regression test
__tests__/bundled-workflows-health-check.test.js— 5 cases (uses .read() not .getState(), correct counts, graceful degrade on read() throw, no servicesStateManager on ctx, single-service path). Full suite: 1219/1219 pass (+5 new).
DC-046: Pluggable AuthProvider interface — refactor TOTP into one of N providers
- status: done
- owner: hermes
- details: Today DashCaddy has only one login method (TOTP). For a public-release product we need at least a second (email magic link), and the TOTP-only design doesn't scale — every new user needs a TOTP secret provisioned manually, no self-service recovery, no per-user audit trail. Refactor: define a
AuthProviderinterface insrc/auth/providers/with methods{ name, enabled, loginMethods, initiate(req) -> {redirect, challenge?}, verify(req) -> {user} }. Move the existing TOTP code intosrc/auth/providers/totp.jsas one implementation of that interface.createAppcomposes all enabled providers and exposes them via/api/v1/auth/loginand/api/v1/auth/login/:methodroutes. Login page lists all enabled providers with their own button. Zero behavior change for existing TOTP users — the route shape becomes/api/v1/auth/login/totpinstead of/api/v1/auth/login, but the existing UI is rewritten to match. Effort: ~1 hr. Risk: medium (touches the auth path that is the most security-sensitive area of the codebase). - impact: Unlocks every other auth provider (DC-047 email magic link, DC-048+ OIDC, SAML, etc.) without further refactors of the auth path.
- result: Shipped. 6 new modules under
src/auth/providers/(~1100 LOC):base.js(AuthProvider contract),totp.js(TOTP impl),email.js+email-tokens-store.js+email-sender.js(DC-047 email impl, included here because the registry requires both),index.js(createAuthProviderRegistry). Newroutes/auth/login.js(109 LOC) mounts under/auth. Existingroutes/auth/index.jswires the registry + mount.src/utilities/middleware.js+src/security/csrf-protection.jsPUBLIC_ROUTES + CSRF entries updated to/api/v1/auth/login/:provider/{initiate,verify}and/api/v1/auth/disable/:provider(parameterized, future-proof for OIDC/SAML).__tests__/auth-provider-registry.test.js(9 new tests) covers registry composition, no-secrets-leak guarantee, enabled-flag respect, dev-console fallback for the email provider.__tests__/public-routes-drift.test.jsfixed for Express 4.22.x compat (the previous regex extraction broke on the new^\/path\/?(?=\/|$)source format). Tests: 1241/1241 passing across 46 suites (was 1232; +9 new).
DC-047: EmailMagicLinkProvider — email-only login via nodemailer
- status: done
- owner: hermes
- details: Second AuthProvider implementation, sitting alongside TOTP. Email IS the identity — no separate username field at any point. Flow: user enters email at
/login, server generates a single-use token (32 random bytes, base64url), stores it indata/email-tokens.jsonwith 15-min TTL, sends an email via the existing nodemailer connection insrc/managers/notification-manager.js:290(reuse the same SMTP config —providers.email.host/port/username/password/from). Email body contains a link likehttps://dashcaddy.example.com/auth/verify?token=abc123. Click → server validates token (exists, not expired, not already used) → marks used → creates session cookie → redirect to dashboard. On subsequent visits, session cookie is the credential. Rate-limit the request-link endpoint to 5 per email per hour to prevent email-bombing. Tokens stored as SHA-256 hashes in the JSON store so a read-only compromise can't be used to forge links. Effort: ~3 hrs. Risk: medium (depends on SMTP creds being configured; if not, fall back to console-logging the link in dev mode). - impact: Public product readiness. Zero-password login. No username/email split — one field, one identifier. Reuses existing nodemailer config — no new dependency, no new credential surface. Works with any SMTP server Sami already uses (he mentioned using the SMTP server his website runs).
- prerequisite: DC-046 (the interface to implement against).
- result: Shipped as part of DC-046 commit.
src/auth/providers/email.js(388 LOC): registersmagic-link(initiate) +verify-token(verify) methods, generates 32-byte base64url tokens, stores SHA-256 hashes viaemail-tokens-store.js.email-tokens-store.js(260 LOC): atomic lockfile-based mutation, automatic cleanup of expired tokens, audit log on every issue/use.email-sender.js(67 LOC): wraps nodemailer ifproviders.emailconfig is set, else falls back tolog.info('auth', 'email magic link issued', ...)so dev installs work without SMTP config. Verified with stub deps:initiate()writes a token + logsdeliveredVia: 'dev-console'+ returns masked email;verify('verify-token', { token: 'garbage' })throws AuthenticationError (route handler converts to 401). Real SMTP wiring takes effect as soon asproviders.email.host/port/username/passwordare set in config.json.
DC-048: Multi-user bootstrap + admin invites
- status: done
- owner: hermes
- details: The user model shifts from "one implicit operator" to "many users with explicit roles". Bootstrap rule: the FIRST email to ever successfully log in via email magic link becomes the admin. Subsequent emails are denied with a
not authorizederror UNLESS the email appears indata/authorized-users.json. Admin UI: a/userspage that lists authorized users, lets admin add emails (manual entry) or generate single-use invite links (which work like magic links but pre-add the email to the allowlist on first use). Audit log getsuserEmailattribution on every entry. License model is unchanged (still per-host) but note in the ticket that this may need revisiting. Effort: ~2 hrs. Risk: low (mostly UI + JSON-store CRUD). - impact: First real multi-user DashCaddy. Per-user audit attribution. Self-service invites. Foundation for any future "team" features.
- prerequisite: DC-047 (needs email auth working first).
- result: Shipped as opt-in. Email auth must be explicitly enabled via
siteConfig.authProviders.email.enabled = true; single-user TOTP-only installs see zero behavior change. New modules:src/security/user-store.js(users + allowlist + bootstrap sentinel, atomic writes, last-admin protection, 380 LOC),src/security/invite-store.js(single-use tokens, SHA-256 hashed on disk, TTL, 230 LOC). New routes:routes/auth/admin.js(/me,/admin/usersGET/POST/PATCH/DELETE,/admin/allowlist,/admin/invitesGET/POST/DELETE, public/invites/:tokenpeek +/invites/:token/acceptredeem, 360 LOC). EmailMagicLinkProviderverify()callsuserStore.isEmailAuthorized()thenuserStore.login()then tagsreq.userfor audit attribution; TOTPverify()bootstraps asystem@totp.localadmin record on first login so the current operator shows up in/admin/userswithout a re-login. Audit logger middleware readsreq.userand addsuserId/userEmail/userRole/viaProviderto log details. New admin UI:status/js/admin.js(modal overlay, users list with role-edit + delete, invite form with copy-link button, outstanding-invites list with revoke). Wired intocore/init.jsso the "Admin" trigger button appears in the top bar only when/mereturnsisAdmin: true. 35 new tests across 3 files. Full suite: 1298/1298. Update PUBLIC_ROUTES + CSRF allowlists for the new invite redemption paths (same exemption rationale as login verify).
Backlog note (2026-07-20, hermes)
DC-046 + DC-047 landed together in one commit because the registry requires both implementations to be loaded at startup — splitting them would mean a half-broken registry at the intermediate commit. The commit message documents both IDs.
DNS2 deploy: code change + scripts/publish-release.sh + docker build + bash start.sh + live verify. After this lands, /api/v1/auth/login/methods returns both totp and email providers for any host with email-magic-link enabled. Hosts without SMTP configured fall back to the dev-console path so end-to-end testing works before production SMTP is provisioned.
Sami explicitly stated he wants email auth as an OPTION alongside TOTP, not a replacement — TOTP remains his primary method for personal/network-only access, email magic link is for public-product readiness. Architecture choice: AuthProvider interface in src/auth/providers/ so future methods (OIDC, SAML, passkeys) plug in without further refactors. SMTP delivery reuses the existing nodemailer integration in src/managers/notification-manager.js:290 — no new dependency. Sami plans to use the SMTP server his website runs (sami-ahmed.net) so the host field will be configurable.
- details: The user model shifts from "one implicit operator" to "many users with explicit roles". Bootstrap rule: the FIRST email to ever successfully log in via email magic link becomes the admin. Subsequent emails are denied with a
not authorizederror UNLESS the email appears indata/authorized-users.json. Admin UI: a/userspage that lists authorized users, lets admin add emails (manual entry) or generate single-use invite links (which work like magic links but pre-add the email to the allowlist on first use). Audit log getsuserEmailattribution on every entry. License model is unchanged (still per-host) but note in the ticket that this may need revisiting. Effort: ~2 hrs. Risk: low (mostly UI + JSON-store CRUD). - impact: First real multi-user DashCaddy. Per-user audit attribution. Self-service invites. Foundation for any future "team" features.
- prerequisite: DC-047 (needs email auth working first).
DC-049: Update login UI to show multiple providers
- status: done
- owner: hermes
- details: Currently the login page is TOTP-only. Once DC-046/047/048 ship, login needs to render ALL enabled providers as a list of buttons, each routing to its provider-specific initiate flow (
/api/v1/auth/login/totp,/api/v1/auth/login/email). Frontend work —status/js/core/login.jsand the login modal markup. Add a small "Choose how to sign in" header. Effort: ~1 hr. Risk: low (pure UI, no backend changes). - impact: Makes the pluggable auth provider pattern visible to users. Without this, providers other than TOTP are unreachable.
- prerequisite: DC-046 + DC-047 (needs at least two providers to be meaningful).
- result: Shipped. New module
status/js/auth-gate.js(~290 LOC) owns the?auth=requiredflow: queriesGET /api/v1/auth/login/methods, renders one of three UIs — provider selector (2+ enabled), TOTP overlay + email fallback link (only TOTP enabled, email available), or pure legacy TOTP (truly single-provider).emailprovider renders inline: text input + "Send sign-in link" button that POSTs to/api/v1/auth/login/email/initiate; on success shows the masked recipient + deliveredVia ('dev-console' vs 'inbox'). Coordination withtotp-auth.js:auth-gate.jssetswindow.__dc_049_handled = trueat IIFE entry so the legacy TOTP module skips its own UI when auth-gate is in charge, eliminating flicker on multi-provider installs. Bundle order inbuild.js: auth-gate BEFORE totp-auth (flag must be set first). Verified live:https://status.sami/dist/core.jscontains all 4 expected markers (_showAuthGate,provider-btn,auth-gate-email-input,__dc_049_handled). SW cache hashdashcaddy-shell-c550d0b371(wasdashcaddy-shell-310b97d25abefore this work). User instruction: hard-refreshstatus.samito pick up the new bundle.
DC-050: Harden platform-paths.dataDir — structural guard against image-layer data loss
- status: done
- owner: hermes
- details: DC-039 audited and fixed every module that defaulted
path.join(__dirname, 'foo.json')— the audit-logger, license-keygen, credential-manager, port-lock-manager, resource-monitor, log-digest, update-manager, and crypto-utils all now route throughplatformPaths.dataDir. Verified live on DNS2: the live audit log at/app/data/audit-log.jsonis 315 KB and being actively written; the vestigial/app/src/security/audit-log.jsonis 2 bytes (Jul 6) and never written to post-fix. - What was left undone (now fixed): the structural guard.
platformPaths.dataDirresolved viapath.dirname(SERVICES_FILE). IfSERVICES_FILEenv was unset (e.g. operator deletes the -e flag from start.sh), the fallback chain wentpath.join(CADDY_BASE, 'services.json')→/etc/dashcaddy/services.json→ dataDir =/etc/dashcaddy. That's the IMAGE LAYER on Docker. Audit-log + license-secret + error.log would silently land there and vanish on every container recreate. Same failure shape as DC-039, but a different code path. - Fix (three parts): (1)
platform-paths.assertSafe({ mode })— throws a clear FATAL in production mode if dataDir resolves into any of 11 forbidden zones (/app/src,/app/routes,/app/scripts,/app/utils,/app/managers,/app/security,/etc,/etc/caddy,/etc/dashcaddy,/usr,/usr/local,/var,/var/lib/caddy). Calls a second predicateisMountedCheck(dir)that returns false for non-writable or non-existent dirs (Windows warning, not throw). Bypassed withSKIP_DATA_DIR_GUARD=1. (2)server.js:35— callsassertSafebefore any other startup work. Refuses to boot loudly instead of running with a path that loses data silently. (3)start.sh:13-66— one-time migration step runs beforedocker run. Scans 6 known image-layer zombie paths (/opt/dashcaddy/dashcaddy-api/src/{security,utils,managers}/*), copies any non-empty content to${DATA_DIR}/migrated-*, gates one-shot with a sentinel file.migrated-from-image-layer. Idempotent. Survivesset -eper-file failures. Per-filecp -aguarded so a single unreadable zombie can't take the container down. Will recover the 140 KBerror.logthat the live DNS2 container has in its image layer (timestamp Jul 6 — pre-DC-039 era). - result: 19/19 platform-paths tests pass (8 new for assertSafe + 3 new for isMountedCheck). 5/5 start.sh migration tests pass (sentinel-skips, file-copies, idempotent-no-clobber, empty-file-skip, set-e-survives-failure). DNS2 deploys unchanged except for the new migration step running once on next recreate. Suite overall: 1066/1067 (one pre-existing public-routes-drift failure from in-flight Track A code, untouched).
Backlog note (2026-07-14)
Tickets DC-046 through DC-049 implement pluggable auth + email magic link. Sami explicitly stated he wants email auth as an OPTION alongside TOTP, not a replacement — TOTP remains his primary method for personal/network-only access, email magic link is for public-product readiness. Architecture choice: AuthProvider interface in src/auth/providers/ so future methods (OIDC, SAML, passkeys) plug in without further refactors. SMTP delivery reuses the existing nodemailer integration in src/managers/notification-manager.js:290 — no new dependency. Sami plans to use the SMTP server his website runs (sami-ahmed.net) so the host field will be configurable. Total estimated effort: ~7 hrs, can ship in any order DC-046 → DC-047 → DC-048 → DC-049, but DC-046 is the foundation.
DC-045: Fix WorkflowEngine init — new (require(...))() precedence bug on ES6 classes
- status: done
- owner: hermes
- details: server.js:93 (v1.13.4) instantiated
new (require('./src/managers/notification-manager'))({...}). V8 parses this as(new (require('./x')))(opts)— which invokes the module's exported class AS A FUNCTION (withoutnew), triggeringClass constructor NotificationManager cannot be invoked without 'new'at server startup. Result: workflow engine never initializes on the running test server (dc-contabo-de). Combined with DC-044 (the .getState bug), the workflow feature has been broken since at least v1.13.4 and visible on both DNS2 + test server. - impact: Workflow engine now starts cleanly. Health-check-on-interval workflow now actually runs against real services instead of silently 0/0.
- result: Hoisted
const NotificationManager = require(...)and usednew NotificationManager({...})in the server.js init block. Verified live on dc-contabo-de: workflow engine now logsWorkflow engine initializedon startup; 90s of post-restart logs show zerogetState is not a functionerrors, zeroWorkflowEngine Action health-check failedspam, zero error-priority entries. Health check: 200 OK with uptime reporting.
- Always
git pullbefore starting work. - Claim a task by editing BACKLOG.md: set
status: in-progressandowner: hermesorowner: krystie. - Commit BACKLOG.md claim first, then start coding.
- Run tests before pushing:
cd dashcaddy-api && npx jest --passWithNoTests - Push to
main— usehttp://sami7777:<token>@100.98.123.59:3000/sami7777/dashcaddy.git - Update BACKLOG.md when done: set
status: done, add brief result under the task. - Never work on a task another bot has claimed (status: in-progress).
- Quality bar: this is a public-release product. No hacks, no env-var workarounds, no per-machine patches. Fixes go in the shared codebase.
- VERSION bump: when a batch of tasks is done, bump patch version in package.json + VERSION file, update CHANGELOG, tag.