feat(infra): safe-dashboard-deploy wrapper + 2 lints + headless canary + 3 bug-class entries#344
Open
mitwilli-create wants to merge 1 commit into
Open
Conversation
… 2026-05-30 4-fold cascade Codifies the dashboard deploy ritual into a single guarded wrapper. Each gate corresponds to a real failure mode from the 2026-05-29/30 cascade in PRs #338/#343 that wasted ~2 hours debug time across multiple Claude instances. What landed (10 files): - scripts/safe-dashboard-deploy.sh — 6-gate orchestrator, exit codes 2-9 - scripts/lint-browser-context-refs.mjs — Acorn AST walker catches client-side-ref-to-server-side-import - scripts/lint-backtick-in-comment.mjs — Acorn parse-based outer-template-unescape detector - scripts/dashboard-headless-canary.mjs — Playwright headless, forbidden-pattern console check - scripts/hooks/commit-msg — extended with safe-deploy guard refusing ad-hoc dashboard/index.html commits - tests/safe-dashboard-deploy.test.mjs — 17/17 pass - AGENTS.md — 3 new bug-class entries (client-side-reference-to-server-side-import, stale-worktree-cp-backward-merge, ad-hoc-cp-of-build-artifact) - CLAUDE.md — Session Notes 2026-05-30 - package.json + package-lock.json — acorn-walk@8.3.5 dev dep Verified gate-by-gate: - Gate 1 (exit 2): synthetic stale-worktree at HEAD~5 → "source HEAD is BEHIND origin/main" - Gate 2 (exit 3): missing data symlink → actionable ln -sfn recovery - Gate 3 (exit 5): end-to-end run on current main → catches the PR #343 sanitizeObjectStrings bug - Gate 4 (exit 6): unit-tested with synthetic backtick-in-comment - Gates 5+6: unit-tested at contract level PR #343 (sanitizer hotfix) is the precondition for the wrapper's first clean end-to-end run. Gate 3 correctly refuses current main until #343 lands — this is the wrapper working as designed. Spec: data/spec-safe-dashboard-deploy-2026-05-30.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
|
|
||
| // Extract every inline <script> block. Returns [{ idx, attrs, body, blockOffset }] | ||
| function extractScripts(html) { | ||
| const SCRIPT_RE = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codifies the dashboard deploy ritual into a single 6-gate wrapper script. Closes the structural gap that produced the 2026-05-29/30 regression cascade in PRs #338/#343, where four independent failure modes each cost ~30-45 minutes of debug time.
Per spec at
data/spec-safe-dashboard-deploy-2026-05-30.md. ~$0 LLM spend (deterministic infrastructure — no AI calls in scripts).What landed
scripts/safe-dashboard-deploy.shscripts/lint-browser-context-refs.mjs<script>blocks. Cross-block shared scope (top-level defs +window.X = ...) + per-blocktypeofguards. Catches the PR #343sanitizeObjectStringsbug.scripts/lint-backtick-in-comment.mjsscripts/build-dashboard.mjs. Parse failure → diagnose nearby unescaped backtick in JS comments.scripts/dashboard-headless-canary.mjsis not defined,SyntaxError,[object Object],Uncaught,Failed to fetch.scripts/hooks/commit-msgdashboard/index.htmlcommits withoutsafe-dashboard-deployorSKIP_SAFE_DEPLOY=1reference.tests/safe-dashboard-deploy.test.mjsAGENTS.mdclient-side-reference-to-server-side-import,stale-worktree-cp-backward-merge,ad-hoc-cp-of-build-artifact).CLAUDE.mdpackage.json+package-lock.jsonacorn-walk@8.3.5added as dev dep.The 4-fold cascade this prevents
Each gate corresponds to a real 2026-05-29/30 failure mode:
git merge-base --is-ancestor)sanitizeObjectStrings()ref from inline<script>to Node-side import; runtime crash on every drawerlint-browser-context-refs.mjs)lint-backtick-in-comment.mjs)data/symlink evaporation mid-build → 1.4MB HTML instead of 9.4MBdata/applications.mdsymlink → exit 3 with actionableln -sfnrecoveryLint iteration history
lint-browser-context-refs.mjs: v1 per-block-only scope (13 false positives), v2 + cross-block top-level scope (12 FPs), v3 + per-block typeof-guard + cross-block window.X member refs → 1 violation (the actual PR #343 bug).lint-backtick-in-comment.mjs: v1 heuristic text scan (17 false positives), v2 parse-based via Acorn → clean exit when source parses + helpful error when it doesn't.Test plan
node --check+bash -n) — cleannode --test tests/safe-dashboard-deploy.test.mjs— 17/17 passlint-backtick-in-comment.mjsagainst currentbuild-dashboard.mjs— exit 0 (clean) ✓lint-browser-context-refs.mjsagainst current live HTML — exits 1, reports ONE violation =sanitizeObjectStrings✓scripts/hooks/commit-msgsyntax check — clean ✓bash scripts/install-hooks.shto refresh installed hookbash scripts/safe-dashboard-deploy.shfrom main — expect clean end-to-end exit 0Predecessor + downstream
.env.example. Runtime-only flags:SKIP_CANARY=1,SKIP_MARKER_CHECK=1,SKIP_SAFE_DEPLOY=1(in commit msg),CANARY_URL,CANARY_TIMEOUT_MS,CANARY_ROW_CLICK_COUNT.dashboard/index.html.pre-deploy.<unix-ts>for one-line rollback.Mitchell action needed post-merge
bash scripts/install-hooks.shto refresh.git/hooks/commit-msgwith the new guardbash scripts/safe-dashboard-deploy.shfrom maindashboard/index.htmlcommits.Rollback
dashboard/index.html.pre-deploy.<unix-ts>;cp <backup> dashboard/index.html+ restart server.git revert <merge-sha>safe.🤖 Generated with Claude Code