Phase 0B ran the upstream application on a network with no route out and the first turn died in tiktoken, which downloads its BPE table the first time anything counts a token. The browser separately fetched three font families from Google on every page load. Neither is visible on a machine that has been online once, which is why both now have tests. The tokenizer table is vendored at backend/app/context/vendor/cl100k_base.tiktoken and backend/app/context/encoding.py builds the encoding from it directly, verifying its SHA-256 against the digest tiktoken itself pins for that URL. No code path in the tokenizer can reach the network any more — not a warm cache, not an environment variable a deployment could forget. The encoding was checked token for token against tiktoken's own. The three font families are self-hosted as variable fonts under frontend/public/fonts/ (343 KiB, Latin and Latin Extended), declared in frontend/src/styles/fonts.css, and re-vendored by frontend/tools/vendor_fonts.py. Their OFL licences ship beside them. With no remote asset left, the CSP drops both Google hosts and gains object-src, base-uri and form-action; woff2 also gets its real media type, which Python's table lacks on a slim image. A trusted-LAN Ollama turned out not to work at all over HTTPS. httpx verifies against the certifi bundle, so an endpoint whose certificate comes from a CA the user installed on their own machines — a StartOS server's Ollama, for one — was refused with CERTIFICATE_VERIFY_FAILED while curl and the browser on the same host accepted it. app/tlstrust.py builds one context that unions the platform CA store with certifi's, and all four outbound clients use it. A union rather than a swap, so an image with an empty system store cannot start failing on endpoints that worked before. Verification itself is untouched: CERT_REQUIRED, hostname checking on, and no insecure escape hatch. The storyteller listener is now loopback by explicit statement rather than by inheriting uvicorn's default: start.sh, start.ps1, and docker-compose.yml, which publishes to 127.0.0.1 rather than every interface. Reaching an Ollama on another machine is outbound and needs none of that inbound exposure. backend/requirements.lock pins the exact tested closure; requirements.txt keeps the ranges. DEVELOPMENT.md covers setup, the same-host and trusted-LAN Ollama configurations, and how to re-run the offline proof. PROVENANCE.md records the upstream commit, the MIT terms, and both vendored assets. Verified, not just compiled. On an --internal Docker network with 1.1.1.1 unreachable and no name resolving, a campaign was created and played for six turns through same-host Ollama, restarted, and resumed. A second run played ten turns through Ollama on a separate physical machine on the LAN over verified HTTPS, summaries and embeddings included, with the storyteller's default route deleted so the LAN was reachable and the Internet was not. Its capture: 893 packets to the approved host, 730 loopback, zero anywhere else, and zero DNS queries. Two induced model failures left the accepted story bit-identical. The inherited SPA was opened in a browser and a campaign read back from it. Evidence is in planning/reports/M1-BASELINE-REPORT.md, along with the findings that did not belong in this change. 648 backend tests pass, up from the inherited 632; frontend lint and build are clean; the image builds. No M2 work is included: the hosted, cloud, analytics, Postgres and scripting surfaces are untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017foPNqFjAJa2Ngebf5mEfL
107 lines
4.6 KiB
Markdown
107 lines
4.6 KiB
Markdown
# Provenance
|
|
|
|
This repository is the Adventure Storyteller production fork. Its application
|
|
code comes from **AI-DnD**, and its planning package (`planning/`) is original
|
|
to this project.
|
|
|
|
## Upstream
|
|
|
|
| | |
|
|
| --- | --- |
|
|
| Project | AI-DnD |
|
|
| Repository | <https://github.com/parththakkar106/AI-DnD> |
|
|
| Commit | `d72f7c1bda0f34fccd84afb7a25c34eb01c901de` |
|
|
| Subject | Stop paying twice for a block a retry can still throw away |
|
|
| Author date | Mon 31 Aug 2026 16:14:24 +0000 |
|
|
| Position | tip of `upstream/main` on 1 Sep 2026, when the fork was taken |
|
|
| License | MIT, © 2026 Parth Thakkar |
|
|
|
|
The commit is the one pinned by `planning/DECISIONS/009-ai-dnd-production-base.md`
|
|
after Phase 0B. It was not substituted for a newer upstream commit.
|
|
|
|
## How the fork is wired
|
|
|
|
Upstream history is *in* this repository rather than copied out of it. The
|
|
import is a merge of the pinned commit with `--allow-unrelated-histories`, so:
|
|
|
|
- `git log d72f7c1bda0f34fccd84afb7a25c34eb01c901de` shows the real upstream
|
|
history, not a squashed snapshot;
|
|
- upstream paths are unchanged (`backend/`, `frontend/`, `docs/`, …), so a
|
|
later upstream commit can still be fetched and cherry-picked against
|
|
matching files;
|
|
- the planning package that predates the fork keeps its own history on the
|
|
other parent of the merge.
|
|
|
|
To re-verify from a fresh clone:
|
|
|
|
```bash
|
|
git remote add upstream https://github.com/parththakkar106/AI-DnD.git
|
|
git fetch --no-tags upstream
|
|
git cat-file -t d72f7c1bda0f34fccd84afb7a25c34eb01c901de # -> commit
|
|
git merge-base --is-ancestor d72f7c1bda0f34fccd84afb7a25c34eb01c901de HEAD && echo "in this history"
|
|
```
|
|
|
|
## License
|
|
|
|
Upstream is MIT. `LICENSE` is upstream's file, unmodified, and the copyright
|
|
notice stays with it. The MIT terms require that the notice travel with the
|
|
code and with substantial portions of it; keep `LICENSE` in place in any
|
|
redistribution of this fork, including a packaged build.
|
|
|
|
Work done in this repository after the fork is a derivative of that MIT-licensed
|
|
code.
|
|
|
|
## Vendored third-party assets
|
|
|
|
Both were added by Milestone M1 to remove a runtime Internet dependency. Each
|
|
is redistributable and each has a regeneration path in the tree, so neither is
|
|
an opaque binary nobody can rebuild.
|
|
|
|
### `backend/app/context/vendor/cl100k_base.tiktoken`
|
|
|
|
The BPE merge table for OpenAI's `cl100k_base` tokenizer, used for context
|
|
budgeting only — no model of OpenAI's is ever called.
|
|
|
|
- Source: `https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken`
|
|
- SHA-256: `223921b76ee99bde995b7ff738513eef100fb51d18c93597a113bcffe865b2a7`,
|
|
which is the digest `tiktoken` itself pins for that URL, and which
|
|
`backend/app/context/encoding.py` re-checks every time it builds the encoding.
|
|
- Published by OpenAI for use with `tiktoken` (MIT).
|
|
|
|
### `frontend/public/fonts/*.woff2`
|
|
|
|
Cinzel, Crimson Pro and Inter, Latin and Latin Extended subsets, as variable
|
|
fonts. All three are licensed under the SIL Open Font License 1.1; the license
|
|
text ships beside them as `OFL-cinzel.txt`, `OFL-crimsonpro.txt` and
|
|
`OFL-inter.txt`, which is what the OFL requires of a redistribution.
|
|
|
|
Regenerate with `python3 frontend/tools/vendor_fonts.py`, which also rewrites
|
|
`frontend/src/styles/fonts.css`.
|
|
|
|
## What this fork changed in Milestone M1
|
|
|
|
Nothing was removed from upstream. The changes are the offline/locality
|
|
hardening M1 called for; see `planning/reports/M1-BASELINE-REPORT.md` for the
|
|
evidence.
|
|
|
|
- `backend/app/context/encoding.py` (new) and `backend/app/context/builder.py` —
|
|
build `cl100k_base` from the vendored table instead of downloading it on
|
|
first use.
|
|
- `frontend/index.html`, `frontend/src/index.css`,
|
|
`frontend/src/styles/fonts.css` (new), `frontend/public/fonts/` (new),
|
|
`frontend/tools/vendor_fonts.py` (new) — self-hosted fonts in place of the
|
|
Google Fonts link.
|
|
- `backend/app/main.py` — CSP narrowed to same-origin, with the two Google
|
|
hosts dropped and `object-src` / `base-uri` / `form-action` added; `woff2`
|
|
registered so the self-hosted fonts are served with their real media type.
|
|
- `backend/app/tlstrust.py` (new), `backend/app/providers/openai_compatible.py`,
|
|
`backend/app/routers/settings.py` — outbound HTTPS verifies against the
|
|
machine's own CA store as well as certifi's, so a trusted-LAN Ollama with a
|
|
locally-issued certificate works. Verification is not relaxed.
|
|
- `start.sh`, `start.ps1`, `docker-compose.yml` — the storyteller listener is
|
|
explicitly loopback-bound.
|
|
- `backend/requirements.lock` (new) — the exact tested dependency closure.
|
|
- `backend/tests/test_offline_assets.py` and `backend/tests/test_tls_trust.py`
|
|
(new) — regression tests for the above.
|
|
- `DEVELOPMENT.md` (new) — environment setup and Ollama configuration.
|