Skip to content

fix: add unsafe-eval to CSP for Alpine.js and Tailwind CDN#353

Merged
bicced merged 8 commits intomainfrom
worktree-review-prompt-system
Mar 6, 2026
Merged

fix: add unsafe-eval to CSP for Alpine.js and Tailwind CDN#353
bicced merged 8 commits intomainfrom
worktree-review-prompt-system

Conversation

@bicced
Copy link
Contributor

@bicced bicced commented Mar 6, 2026

Summary

  • Root cause of blank dashboard: PR security: production readiness audit — Stage 3 (engine) #343 added Content-Security-Policy without 'unsafe-eval', breaking Alpine.js and Tailwind CDN
  • Alpine.js uses new Function() for expression evaluation (x-show, x-data, x-model, etc.)
  • Tailwind CDN uses new Function() for JIT CSS generation
  • Without 'unsafe-eval', both libraries silently fail — [x-cloak] never gets removed, page appears blank
  • Also adds CSP to the SPA catchall route (was missing entirely)

Why 'unsafe-eval' is needed

Alpine.js standard CDN build (alpinejs@3.14.8/dist/cdn.min.js) requires eval()/new Function() to evaluate directive expressions. The alternative is @alpinejs/csp which pre-compiles expressions, but requires significant template changes. 'unsafe-eval' is the pragmatic fix.

Test plan

  • Open dashboard at http://localhost:8420/dashboard/ — page renders correctly
  • Open browser dev tools Console — no CSP violation errors
  • Onboarding banner shows when no credentials/agents
  • Add agent modal opens and functions correctly

bicced added 8 commits March 6, 2026 17:47
Prompt improvements:
- Add "never refuse without trying" to both task and chat mode rules
  (critical for autonomous execution — was lost in prior streamlining)
- Add memory_search hint to task mode (was only in chat mode)
- Clarify "blackboard for other agents only" wording
- Add "read before updating — merge, don't overwrite" to self-evolution
  (prevents agents from clobbering their own workspace files)
- Trim fleet context block from ~15 lines to 2 (blackboard/notify_user
  guidance already covered by operating rules)

Template revisions (all 6):
- Add notify_user step to all multi-agent workflows so users get results
  when agents work via pipelines or heartbeat
- Add domain-specific quality guidance:
  - deep-research: memory_save step for source reuse across sessions
  - content: writing principles, audience matching, review checklist
  - devteam: engineering standards, review focus areas (security, tests)
  - sales: ICP reference from USER.md, what-to-capture checklist
  - monitor: what makes good monitoring targets, severity levels
- Remove placeholder example lines from monitor heartbeat
  (replaced with actionable format the user fills in)
- starter: add autonomous reporting guidance
Standalone agents (no project) no longer see blackboard tools or
references. Changes:

- SkillRegistry: add `exclude` param to list_skills/get_descriptions/
  get_tool_definitions for filtering tools from LLM
- AgentLoop: exclude blackboard tools (read/write/list_shared_state,
  publish/subscribe_event, watch_blackboard, claim_task) when
  mesh_client.is_standalone; omit blackboard references from operating
  rules in both task and chat modes; skip fleet roster fetch
- workspace: standalone SYSTEM.md preamble without blackboard/pub-sub/
  coordination sections
- mesh_tool: remove blackboard mention from list_agents description

Runtime _STANDALONE_ERROR checks in mesh_tool.py remain as defense-in-
depth. All 1660 tests pass.
- Add runtime is_standalone guards on publish_event/subscribe_event
- Conditional "promote" instruction in task mode (standalone omits it)
- Include is_standalone in heartbeat context for conditional cron rules
- Fix wait_for_subagent to read from task.result() first (works standalone)
- Fix wait_for_subagent to catch task exceptions from asyncio.wait_for
- Clean tool descriptions that mentioned blackboard visible to standalone
- Fix _make_loop test helper to set is_standalone=False explicitly
- Add 17 new tests covering all standalone isolation behavior
- _run_subagent: skip write_blackboard when mesh_client.is_standalone
- wait_for_subagent: skip blackboard fallback for standalone agents
- Set is_standalone=False on all mock mesh clients in subagent tests
  (MagicMock auto-attributes are truthy, causing silent wrong behavior)
When fetchSettings() is slow or fails, settingsData stays null and
showOnboarding returned false, leaving the fleet tab completely blank
(no loading skeleton, no onboarding, no empty state). Fall back to
showing onboarding when agents are empty regardless of settings state.
PR #343 added Content-Security-Policy without 'unsafe-eval'. Both
Alpine.js (expression evaluation via new Function()) and Tailwind CDN
(JIT CSS generation) require eval/new Function to operate. Without it,
Alpine directives (x-show, x-data, x-model) never evaluate, x-cloak
never gets removed, and the dashboard appears blank.

Also adds the CSP header to the SPA catchall route for consistency
(was previously missing entirely).
@bicced bicced merged commit 9f870b9 into main Mar 6, 2026
3 checks passed
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