Skip to content

[alpha_factory] Fix Insight v1 demo readiness and CSP-safe bootstrap - #4633

Open
MontrealAI wants to merge 3 commits into
mainfrom
codex/fix-demo-readiness-errors-for-alpha_agi_insight_v1
Open

[alpha_factory] Fix Insight v1 demo readiness and CSP-safe bootstrap#4633
MontrealAI wants to merge 3 commits into
mainfrom
codex/fix-demo-readiness-errors-for-alpha_agi_insight_v1

Conversation

@MontrealAI

Copy link
Copy Markdown
Owner

Motivation

  • The Insight v1 demo failed offline readiness checks due to CDN dependencies, inline scripts blocked by a strict Content Security Policy (CSP), and an unresolved d3 module specifier, so the page must be usable offline and CSP-compliant for automated verification.

Description

  • Replaced remote Tailwind/DaisyUI CDN usage with the local bundled stylesheet by switching index.html to load style.css so the demo no longer depends on network assets.
  • Removed CSP-blocked inline runtime code and added an external docs/alpha_agi_insight_v1/bootstrap.js that defines required globals, provides a resilient window.toast, and performs guarded service-worker registration with SHA-384 integrity checks.
  • Kept the import map available but made it inline and added a sha256 CSP entry so the import map and module imports (e.g., d3) resolve without violating CSP.
  • Updated docs/alpha_agi_insight_v1/index.html to reference bootstrap.js, the inline import map, and the local style.css to ensure offline, CSP-safe startup.

Testing

  • Ran python scripts/verify_demo_pages.py and the script reported all demos ready, including alpha_agi_insight_v1 (pass).
  • Installed browsers with python -m playwright install chromium and system deps with python -m playwright install-deps chromium to enable Playwright checks (completed successfully).
  • pre-commit run --files docs/alpha_agi_insight_v1/index.html docs/alpha_agi_insight_v1/bootstrap.js could not be executed in this environment because the pre-commit binary is not installed (not run here).

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7bc82539f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

</script>

<script type="importmap">{"imports":{"d3":"./d3.exports.js"}}</script>
<script src="bootstrap.js"></script>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve SW_HASH assignment in index for build tooling

Moving the service-worker hash constant out of index.html into bootstrap.js breaks the docs build pipeline, because scripts/build_insight_docs.sh still runs python scripts/ensure_insight_sw_hash.py "$DOCS_DIR" (line 97) and that updater only scans index.html for SW_HASH (scripts/ensure_insight_sw_hash.py lines 13 and 32-33). In this commit, index.html no longer contains any SW_HASH assignment, so the updater raises ValueError("SW_HASH not found in index.html") and aborts the build/deploy flow.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7165028372

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/alpha_agi_insight_v1/index.html Outdated
}
</style>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; connect-src 'self' https://api.openai.com; frame-src 'self' blob:; worker-src 'self' blob:; script-src 'self' 'wasm-unsafe-eval' 'sha384-177zXf5eB3dnF9pKwGvc3ITN0EN04yL+Lju+41FYl59Rk/ooEBgXYv3+I8s/0zR0' 'sha384-79nEfECpiwNfTKeXO3LCt0sLutpd3k4stwrBgGfcJBKvwd9SsNd9wIP34JDO4M50' 'sha384-S/HpIy5nMSwGRdVif2eZ3cvGREvSWay48Hf5S44wcCUQ0HW9qYkQDrwyKoG6dSj5' 'sha384-eR8sYzoSk2xJcnjk7RVrsGWKil+DbPgMionlm2xuFpCTJRuyTQ/l6jHF2OY7ZnIL'; style-src 'self' 'unsafe-inline'" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; connect-src 'self' https://api.openai.com; frame-src 'self' blob:; worker-src 'self' blob:; script-src 'self' 'wasm-unsafe-eval' 'sha256-dDxHY9jsmwCNT6SL2iClsP0FZJhaJdDwa84djmuXewU=' 'sha256-MZlivqP55xBVZ2jmS02uBj9OM0b1thDoF0fdP8evk2k=' 'sha256-Ieor5mDwXPSfgARysDOt31nGHdS8ZJCQUvuusk0K4pA='; style-src 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline'" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore SHA-384 CSP hashes for inline scripts

scripts/ensure_insight_csp.py and tests/security/test_csp.py both treat inline script allowlists as SHA-384 entries ('sha384-...'), but this script-src now only lists SHA-256 hashes. That means the test’s computed SHA-384 hashes for the inline scripts are never permitted, so the CSP integrity check fails and the docs build helper will keep rewriting this tag back to SHA-384-based values.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant