feat: agent guardrails, headless smoke test, and guardrails CI #58
Closed
Timmy
wants to merge 1 commits from
feat/agent-guardrails-and-smoke-test into main
pull from: feat/agent-guardrails-and-smoke-test
merge into: Timmy_Foundation:main
Timmy_Foundation:main
Timmy_Foundation:burn/20260413-0400-qa-remaining-fixes
Timmy_Foundation:fix/resource-counter-animations
Timmy_Foundation:fix/ci-a11y-workflow
Timmy_Foundation:sprint/issue-101
Timmy_Foundation:burn/20260413-0400-fix-ui-bugs
Timmy_Foundation:fix/phase-transition-overlay
Timmy_Foundation:burn/20260413-0348-a11y-workflow-fix
Timmy_Foundation:fix/issue-100-ci-workflows
Timmy_Foundation:burn/20260413-0339-beacon-ui-fixes
Timmy_Foundation:fix/a11y-workflow-game-js-removal
Timmy_Foundation:feat/canvas-combat-visualization
Timmy_Foundation:beacon/polish
Timmy_Foundation:burn/20260413-0220-qa-fixes
Timmy_Foundation:burn/20260413-0202-qa-bug-sweep
Timmy_Foundation:burn/20260412-1220-polish-2
Timmy_Foundation:burn/fix-bilbo-randomness
Timmy_Foundation:sprint/issue-95
Timmy_Foundation:burn/fix-bilbo-drone-screenreader
Timmy_Foundation:sprint/issue-tutorial-fix
Timmy_Foundation:burn/fix-critical-bugs
Timmy_Foundation:qa/playtest-report
Timmy_Foundation:perplexity/dead-code-audit
Timmy_Foundation:burn/20260412-1227-sound
Timmy_Foundation:feat/symbolic-guardrails-1776010892175
Timmy_Foundation:feat/golden-ratio-drones
Timmy_Foundation:feat/gofai-npc-logic
Timmy_Foundation:burn/20260412-1150-a11y-fix
Timmy_Foundation:feat/beacon-mega-1775996281802
Timmy_Foundation:burn/a11y-aria-labels
Timmy_Foundation:burn/20260412-0757-polish
Timmy_Foundation:burn/20260412-0720-mobile-touch-polish
Timmy_Foundation:feat/better-rate-display
Timmy_Foundation:burn/20260411-1845-export-import-keyboard-help
Timmy_Foundation:polish
Timmy_Foundation:burn/20260411-1627-export-import-shortcuts
Timmy_Foundation:burn/20260411-1507-fix-debuff-corruption
Timmy_Foundation:beacon/polish-tutorial-onboarding
Timmy_Foundation:burn/20260411-0022-accessibility-aria-labels
Timmy_Foundation:burn/20260410-2215-boosted-rates-click-power
Timmy_Foundation:feat/modular-engine-v2
Timmy_Foundation:fix/accessibility-aria
Timmy_Foundation:rescue/export-import
Timmy_Foundation:burn/20260410-1920-49-accessibility-aria
Timmy_Foundation:refactor/unslop-phase-1-2
Timmy_Foundation:fix/add-smoke-test
Timmy_Foundation:feat/ci-a11y-checks
Timmy_Foundation:feat/a11y-smoke-test
Timmy_Foundation:burn/20260410-47-export-import-hotkeys
Timmy_Foundation:feat/progression-toasts
Timmy_Foundation:burn/20260410-0817-10-number-formatting
Timmy_Foundation:feat/offline-gains-popup
Timmy_Foundation:feature/locked-building-previews
Timmy_Foundation:feature/production-breakdown
Timmy_Foundation:fix/event-remediation-system
Timmy_Foundation:fix/creativity-double-count
Timmy_Foundation:burn/20260410-0423-25-mempalace-building
Timmy_Foundation:feat/combo-system
Timmy_Foundation:burn/20260410-0355-35-fix-offline-progress
Timmy_Foundation:feat/progress-bar-milestones
Timmy_Foundation:fix/offline-progress-all-resources
Timmy_Foundation:feature/buy-mode-toggle
Timmy_Foundation:burn/20260410-0225-fix-offline-progress
Timmy_Foundation:fix/offline-progress
Timmy_Foundation:burn/20260410-0052-13-static-site-meta
Timmy_Foundation:beacon/unlock-notifications
Timmy_Foundation:feature/save-toast
Timmy_Foundation:burn/20260409-2101-creativity-ops
Timmy_Foundation:burn/20260409-1926-18-spellf-full-number-formatting
Timmy_Foundation:feat/spellf-formatting
Timmy_Foundation:integration
Timmy_Foundation:allegro/code-review-and-enhancements
Timmy_Foundation:bezalel/fleet-story-integration
No Reviewers
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Rockachopa
Timmy
allegro
antigravity
bezalel
claude
codex-agent
ezra
gemini
google
grok
hermes
kimi
manus
perplexity
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Timmy_Foundation/the-beacon#58
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "feat/agent-guardrails-and-smoke-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Three-layer defense against the class of silent correctness bugs surfaced in #54:
AGENTS.md— documented rules for any contributor (human or AI) touchinggame.js. Lead rule: persistent multipliers (*Boost) must never be mutated inside functions that run per tick. Full rationale, war stories, and enforcement map in the file.scripts/smoke.mjs— headless smoke test. Bootsgame.jsin avmsandbox with a minimal DOM stub, no npm deps. Runs 30 assertions covering boot, tick loop,writeCode, building purchase, debuff safety,updateRatesidempotency, and a save/load round-trip. <1s on a dev machine.scripts/guardrails.sh— static grep-based checks that encode the rules in AGENTS.md in a form CI can enforce at parse-time speed.All three are run by a new Gitea Actions workflow (
.gitea/workflows/guardrails.yml) on every PR and push to main.Included bug fix:
community_dramano longer decayscodeBoostThe smoke test caught a silent correctness bug in the debuff system. The original
applyFnforcommunity_dramadid:applyFnis invoked fromupdateRates()on every tick (~10 Hz).G.codeBoostis a persistent multiplier — it isn't reset between ticks — so the*= 0.7compounded. After ~100 ticks of the debuff being active,codeBoost ≈ 3e-16, and the player's code production was effectively zero until they started a new run. The game kept rendering, the click button kept working, the player just slowly and silently lost.The fix targets
G.codeRate(which is reset at the top ofupdateRates()and therefore correctly applies*= 0.7once per tick) instead ofG.codeBoost. The observable behavior — code production at 70% while the debuff is active — matches the original design intent.The smoke test has a dedicated assertion for this: it fires every event's
effect()and then callsupdateRates()200 times, assertingG.codeBoosthas not moved. Before the fix, that assertion producedcodeBoost = 1.046e-31from a starting value of 1.What's in each file
AGENTS.mdSeven rules. The first four are about the interaction between
G.*Boost,G.*Rate, andupdateRates()— i.e. the exact thingcommunity_dramagot wrong. Rule 3 is theloadGamewhitelist rule (now enforced since #55 landed the whitelist). Rules 5–7 cover eventresolveCostduplication,G.flagsconventions, and secrets/copyright hygiene.scripts/smoke.mjsgame.jsviavm.runInContextwith a stubdocument,window,localStorage, and timer functions.const-declared engine values (G,BDEF,tick, ...) are reachable from the harness without patchinggame.js.package.json.scripts/guardrails.sh*Boostmutation insideapplyFn) — hard fail. Uses anawkbrace tracker to restrict matches to insideapplyFn:bodies. Verified to catch the exactcommunity_dramapattern before the fix.getClickPower()consolidation is now on main, so any regression would re-introduce duplicate sites and fail here.Object.assign(G, data)in loadGame) — hard fail. #55's whitelist loader is now on main; regressions fail here.sk-ant-,sk-or-,ghp_,AKIAprefixes across.js/.json/.md/.html/.yml/.yaml/.py/.sh. Filters out the files that contain these literal strings as examples (this script, the workflow,AGENTS.md) so it doesn't self-match..gitea/workflows/guardrails.ymlThree steps:
node -c game.js,node scripts/smoke.mjs,bash scripts/guardrails.sh. Runs onpull_requestandpush: main.Test plan
Run locally:
To verify the
community_dramafix is real, revertgame.js:1537and re-runnode scripts/smoke.mjs— the "codeBoost stable under updateRates()" assertion should fail with a value near 1e-31.Relationship to recent merges
While this PR was being written, #55, #53, and #52 all merged into main. Rebase was clean except for the
G.flags = {}init which #55 also added (trivial dedupe). Thecommunity_dramafix was not touched by #55, so it remains the primary correctness win in this PR.After #55 landed, rules 2 and 3 flipped from PENDING to hard failures — there's no longer anything on main that would violate them, so any future PR that introduces a second click-power formula or re-adds
Object.assign(G, data)will be blocked at CI.Intentionally deferred
resolveCostsingle source of truth (#54 review comment): needs a refactor ofEVENTSentries; AGENTS.md rule 5 documents the interim "copy literally" rule until then.BDEF.find/PDEFS.findMap optimization: micro-optimization at ~24 entries; not worth the diff here.Happy to split any of the above into follow-up PRs.
Refs: #54
b41889650dto0e5538319bCrucial guardrails for the game engine. AGENTS.md provides necessary context for future contributions.
⚠️ Blocked: CI failures — Two checks are failing:
The Guardrails check passed. Please fix the failing checks before merging. The smoke test and a11y-audit workflows may need debugging.
Pull request closed