Skip to content

Centralize bootstrapping into bootstrap.js and strengthen CSP hash generation#4635

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

Centralize bootstrapping into bootstrap.js and strengthen CSP hash generation#4635
MontrealAI wants to merge 2 commits into
mainfrom
codex/fix-demo-readiness-errors-for-alpha_agi_insight_v1-4s7zuz

Conversation

@MontrealAI
Copy link
Copy Markdown
Owner

Motivation

  • Consolidate inline bootstrapping (toast + service-worker wiring) into a reusable file and tighten Content Security Policy handling so the demo can run without remote inline scripts while still allowing required inline pieces.

Description

  • Add bootstrap.js to alpha_factory_v1/demos/alpha_agi_insight_v1/insight_browser_v1 and docs/alpha_agi_insight_v1 to centralize toast implementation, service-worker registration, and demo globals (PINNER_TOKEN, OTEL_ENDPOINT, IPFS_GATEWAY, SW_HASH).
  • Update index.html in both demo and docs to use local style.css, remove several CDN/inline scripts, inject the importmap, set window.SW_HASH, and load bootstrap.js before the module bundle (insight.bundle.js).
  • Improve scripts/ensure_insight_csp.py to support computing both sha384 and sha256 hashes for inline script snippets, allow selecting the algorithm, and add a special-case sha256 entry when an importmap is present so the generated CSP covers both hash algorithms used in the HTML.
  • Remove embedded inline PINNER_TOKEN/OTEL/IPFS assignments from the HTML and consolidate configuration to the new bootstrap globals.

Testing

  • Ran python3 scripts/ensure_insight_csp.py against docs/alpha_agi_insight_v1 and alpha_factory_v1/demos/alpha_agi_insight_v1/insight_browser_v1, and the script completed successfully and updated the CSP meta tags.
  • No other automated tests were modified by this change and the PR does not alter existing unit/CI test behavior.

Codex Task

Copy link
Copy Markdown

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

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: 70177a338a

ℹ️ 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 type="importmap">{"imports":{"d3":"./d3.exports.js"}}</script>
<script>window.SW_HASH = 'sha384-jNrRb0RaME0Q+lz0/ITUhfnQBDj97uJPtmPXPc9rSfGvo79YnRebfKvL0rUyytDQ';</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 Ship bootstrap.js alongside docs index

This HTML now loads bootstrap.js, but this commit does not add docs/alpha_agi_insight_v1/bootstrap.js, so the browser gets a 404 and none of the moved bootstrap logic runs on the published docs page. In practice, service-worker registration and the early toast fallback are skipped for docs users, which regresses offline/update behavior compared to the previous inline implementation.

Useful? React with 👍 / 👎.

</script>

<script type="importmap">{"imports":{"d3":"./d3.exports.js"}}</script>
<script>window.SW_HASH = 'sha384-jNrRb0RaME0Q+lz0/ITUhfnQBDj97uJPtmPXPc9rSfGvo79YnRebfKvL0rUyytDQ';</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 Keep docs service-worker artifact in tree

The page still configures window.SW_HASH for service-worker.js, but this commit deletes docs/alpha_agi_insight_v1/service-worker.js, so the docs build no longer ships the worker it is wired to verify/register. That breaks service-worker-based caching in docs deployments and conflicts with existing docs checks that expect this file to exist.

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