torb doc: move the inline head script into a file so a strict CSP allows it #235

Closed
opened 2026-10-08 22:38:45 +00:00 by orion · 8 comments
Collaborator

Follow-up of #17.

Problem. The pages torb doc writes carry one inline <script> in the head: headScript of compiler/src/documentation/site-style.trb, written by compiler/src/reference/site.trb. It restores the stored theme before paint. The registry serves a version's pages (/docs/ in tools/deploy/nginx.conf) with script-src 'self', so the browser blocks that script and a page follows the system theme until the toggle is used.

Proposal. torb doc writes the head script as a file of the site, theme.js at the root of the site (next to search.js), and the head loads it with <script src="{root}theme.js"></script>, without defer so it still runs before paint. A hash in the CSP would break with every toolchain change. The file holds headScript unchanged (one source of truth; its language and referrer parts are no-ops on reference pages, which carry no data-path).

Acceptance.

  • siteFiles of compiler/src/reference/site.trb contains theme.js, with the content of headScript.
  • No page torb doc writes contains an inline <script> (only <script src=...>); the head loads theme.js before search-index.js and search.js, without defer, with the right relative root for index.html and for <package>/<module>.html.
  • Tests in compiler/tests/reference.test.trb cover the three points above (file list, no inline script, the tag per page depth).
  • A page served with the registry's CSP (script-src 'self') restores the saved theme and the console reports no CSP violation (checked once in a browser on the rendered output served with that header; not a CI gate).
  • Docs follow: the file table of docs/tooling/torb-doc.md names theme.js; the comment of the /docs/ location in tools/deploy/nginx.conf no longer says the theme script is blocked; the generated skills are refreshed if the docs change requires it (torb docs skill docs skills --check).

Design point. docs/design/RELEASE.md section 7.7/7.11 (documentation worker, registry shell: no inline script); docs/tooling/torb-doc.md ("The site"). No open question in CONCEPT is involved.

Seed. Not touched: no syntax change, no new native, no driver flag, no std name looked up by string.

Size. One PR, one Conventional Commit, e.g. fix(doc): load the head script of torb doc pages from theme.js.

Out of scope. The documentation site (torb docs site, site-layout.trb) keeps its inline head script: it is not served under a strict CSP.

Follow-up of #17. **Problem.** The pages `torb doc` writes carry one inline `<script>` in the head: `headScript` of `compiler/src/documentation/site-style.trb`, written by `compiler/src/reference/site.trb`. It restores the stored theme before paint. The registry serves a version's pages (`/docs/` in `tools/deploy/nginx.conf`) with `script-src 'self'`, so the browser blocks that script and a page follows the system theme until the toggle is used. **Proposal.** `torb doc` writes the head script as a file of the site, `theme.js` at the root of the site (next to `search.js`), and the head loads it with `<script src="{root}theme.js"></script>`, without `defer` so it still runs before paint. A hash in the CSP would break with every toolchain change. The file holds `headScript` unchanged (one source of truth; its language and referrer parts are no-ops on reference pages, which carry no `data-path`). **Acceptance.** - `siteFiles` of `compiler/src/reference/site.trb` contains `theme.js`, with the content of `headScript`. - No page `torb doc` writes contains an inline `<script>` (only `<script src=...>`); the head loads `theme.js` before `search-index.js` and `search.js`, without `defer`, with the right relative root for `index.html` and for `<package>/<module>.html`. - Tests in `compiler/tests/reference.test.trb` cover the three points above (file list, no inline script, the tag per page depth). - A page served with the registry's CSP (`script-src 'self'`) restores the saved theme and the console reports no CSP violation (checked once in a browser on the rendered output served with that header; not a CI gate). - Docs follow: the file table of `docs/tooling/torb-doc.md` names `theme.js`; the comment of the `/docs/` location in `tools/deploy/nginx.conf` no longer says the theme script is blocked; the generated skills are refreshed if the docs change requires it (`torb docs skill docs skills --check`). **Design point.** `docs/design/RELEASE.md` section 7.7/7.11 (documentation worker, registry shell: no inline script); `docs/tooling/torb-doc.md` ("The site"). No open question in CONCEPT is involved. **Seed.** Not touched: no syntax change, no new native, no driver flag, no std name looked up by string. **Size.** One PR, one Conventional Commit, e.g. `fix(doc): load the head script of torb doc pages from theme.js`. **Out of scope.** The documentation site (`torb docs site`, `site-layout.trb`) keeps its inline head script: it is not served under a strict CSP.
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop), follow-up of #17, not a duplicate. Moves the inline head script of torb doc pages into a file for a strict CSP. next: waiting (refine queued, ready buffer full) until 2026-10-10T04:00:00Z

[loop:torbscript] intake: in scope (author orion, label loop), follow-up of #17, not a duplicate. Moves the inline head script of torb doc pages into a file for a strict CSP. next: waiting (refine queued, ready buffer full) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261025-0542 until 2026-10-25T08:50:00Z (no ready issue is free to implement: all five are in review/CI or blocked, intake since 2026-10-09 not refined yet)

[loop:torbscript] claim refine by session:loop-torbscript-20261025-0542 until 2026-10-25T08:50:00Z (no ready issue is free to implement: all five are in review/CI or blocked, intake since 2026-10-09 not refined yet)
Author
Collaborator

[loop:torbscript] decided by the loop: theme.js holds headScript unchanged instead of a trimmed theme-only script. Why: one source of truth; the language and referrer parts do nothing on reference pages (no data-path, no assembled rule), the file is a few hundred bytes, and the behaviour stays identical to the inline script. Scope is torb doc only (the /docs/ location of nginx.conf is the strict-CSP host); the site's own pages are not served under it.

[loop:torbscript] decided by the loop: `theme.js` holds `headScript` unchanged instead of a trimmed theme-only script. Why: one source of truth; the language and referrer parts do nothing on reference pages (no `data-path`, no `assembled` rule), the file is a few hundred bytes, and the behaviour stays identical to the inline script. Scope is `torb doc` only (the `/docs/` location of nginx.conf is the strict-CSP host); the site's own pages are not served under it.
Author
Collaborator

[loop:torbscript] refine: body rewritten with goal, testable acceptance, design point (RELEASE.md 7.7/7.11, torb-doc.md), seed untouched, one PR / one commit; label ready set. next: ready. Worker tokens ~65k. Claim of session:loop-torbscript-20261025-0542 released.

[loop:torbscript] refine: body rewritten with goal, testable acceptance, design point (RELEASE.md 7.7/7.11, torb-doc.md), seed untouched, one PR / one commit; label `ready` set. next: ready. Worker tokens ~65k. Claim of session:loop-torbscript-20261025-0542 released.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261025-0542 until 2026-10-25T19:40:00Z (PR 481 landed, torb doc area free; implement per the refine comment: one PR, one commit)

[loop:torbscript] claim implement by session:loop-torbscript-20261025-0542 until 2026-10-25T19:40:00Z (PR 481 landed, torb doc area free; implement per the refine comment: one PR, one commit)
Author
Collaborator

[loop:torbscript] release implement: #483, head 21395f9c7f, CI pending after 1500 s (bootstrap, commit messages, pdisc green; tier A/B, gates and the rest queued), Argus review requested, next: waiting (CI + review on PR 483)

[loop:torbscript] release implement: https://git.torb.dev/torbscript/language/pulls/483, head 21395f9c7f29b50af5b3fb63938ae5cccc493132, CI pending after 1500 s (bootstrap, commit messages, pdisc green; tier A/B, gates and the rest queued), Argus review requested, next: waiting (CI + review on PR 483)
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261025-0542 until 2026-10-25T20:30:00Z (CI fix on PR 483 head 21395f9c: tier A one failing test the site > written to disk, the files are there, Assertion failed: written == 8; run 1818 job 20471; gates job 20466 to be checked)

[loop:torbscript] claim implement by session:loop-torbscript-20261025-0542 until 2026-10-25T20:30:00Z (CI fix on PR 483 head 21395f9c: tier A one failing test `the site > written to disk, the files are there`, Assertion failed: written == 8; run 1818 job 20471; gates job 20466 to be checked)
Author
Collaborator

[loop:torbscript] release implement: CI fix on PR 483. Root cause of run 1818: the test the site > written to disk, the files are there still expected 8 written files, but the PR adds theme.js (now 9). The gates job only aggregates its needs (it lists gates.tier-a), so it failed because tier A did. The test now asserts written == 9 and that theme.js exists on disk; the other assertions already named the new file. Still one commit (force-with-lease on loop/235-theme-js, check-commits clean), Argus is a requested reviewer. Head 12aa2b83b5. CI after 1500 s: pending (tier A, gates, agree, playground, seed, archives queued; bootstrap, tier B, tools, commit messages, pdisc green). next: waiting (CI + review on PR 483)

[loop:torbscript] release implement: CI fix on PR 483. Root cause of run 1818: the test `the site > written to disk, the files are there` still expected 8 written files, but the PR adds `theme.js` (now 9). The `gates` job only aggregates its needs (it lists `gates.tier-a`), so it failed because tier A did. The test now asserts `written == 9` and that `theme.js` exists on disk; the other assertions already named the new file. Still one commit (force-with-lease on loop/235-theme-js, check-commits clean), Argus is a requested reviewer. Head 12aa2b83b525b4d62351ecc2639fec048f26c453. CI after 1500 s: pending (tier A, gates, agree, playground, seed, archives queued; bootstrap, tier B, tools, commit messages, pdisc green). next: waiting (CI + review on PR 483)
argus closed this issue 2026-10-25 15:39:36 +00:00
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#235
No description provided.