Repository navigation
offline profile 4: the offline compose overlay, the image bundle script and the install guide (stacked on #2929, #2937, #2936) - #2938
Open
colinmegill wants to merge 14 commits into
Open
colinmegill wants to merge 14 commits into
colinmegill wants to merge 14 commits into
Conversation
The legacy participant page (the default /<conversation_id> page) loaded jwt-decode@latest from cdn.jsdelivr.net with a synchronous <script> in <head> (public/index.ejs:36). Offline, that blocks parsing until the request fails, and hangs where a firewall drops packets. The global it provided is still used once: index.ejs decodes the OIDC access token to read the delphi_enabled claim, and js/views/participation.js:984 hides the donate box when it is set. So the tag is replaced, not just dropped: a ten-line inline decoder reads the payload the same way jwt-decode 3.1.2 (what jsdelivr serves for @latest at this path) does, base64url then UTF-8 then JSON, and throws on a missing or malformed token as before, which the existing try/catch logs. No behaviour change for pol.is: the donate box is hidden for the same users. No schema change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
…ith OFFLINE client-report (public/index.html:15-16) and the legacy participant page (client-participation/public/index.ejs:21-22) loaded the Simple Analytics script and noscript image unconditionally, in every build mode. client-admin already gated them on isProduction (public/index.html:15-26). All three templates now test one template option, simpleAnalytics, which each webpack config sets to: production mode, and OFFLINE is not 1/true. OFFLINE is a new build-time flag, declared as a build ARG in each client stage of file-server/Dockerfile and documented in docs/configuration.md under "Client Build Flags". Compose does not pass it yet; the offline overlay will. client-report's HtmlWebpackPlugin moves from webpack.common.js into the production and development configs through a small htmlPlugin(mode) helper, so the page knows its mode. No behaviour change for pol.is: the file-server image builds every client with build:prod and OFFLINE unset, so the tag stays. Development builds and dev servers of the report and legacy page no longer load it, matching client-admin. No schema change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
…FFLINE parse_env_bool returns the string "true" or "false" (Makefile:15-16), but the profile lines tested it with $(if ...), which is true for any non-empty string (Makefile:36-37 and 59-60). So --profile postgres and --profile local-services were always added, even with POSTGRES_DOCKER=false or LOCAL_SERVICES_DOCKER=false. All four lines now use $(filter true,...), as the USE_PRODCLONE lines already do. Generated `make -n start` commands, before and after: - .env with POSTGRES_DOCKER=true, LOCAL_SERVICES_DOCKER unset, and example.env (both true): unchanged, both profiles. Unset still means true. `docker compose ... config --services` with that command lists the same fifteen services. - both false: before, both profiles; after, neither. - POSTGRES_DOCKER=true, LOCAL_SERVICES_DOCKER=False: before, both; after, postgres only. Adds an OFFLINE target in the PROD/TEST position. Until the offline compose overlay lands it only prints what `make OFFLINE start` will do, and exits 2 so the following goal cannot fall through to the development stack. No behaviour change for pol.is or for a default development checkout. No schema change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
… OFFLINE; ollama behind a profile On a local stack (DYNAMODB_ENDPOINT set) the image CMD ran scripts/setup_ollama.sh on every start (delphi/Dockerfile:115-118), which pulls llama3.1:8b from registry.ollama.ai, even with LLM_PROVIDER=anthropic. And the ollama service had no profile (docker-compose.yml:447), so every `docker compose up` started it. - delphi/Dockerfile: the CMD runs setup_ollama.sh only when LLM_PROVIDER=ollama, and never when OFFLINE is 1 or true. Each skip logs why. The MinIO setup and the job poller run as before. The production branch (DYNAMODB_ENDPOINT unset) is unchanged. - docker-compose.yml: the ollama service is behind the `ollama` profile. The delphi service forwards OFFLINE (fallback empty); LLM_PROVIDER is already forwarded with fallback anthropic. - Makefile: `make start` adds --profile ollama when the env file sets LLM_PROVIDER=ollama, so a development stack that uses Ollama still starts it. - docs/configuration.md and example.env describe both. - delphi/tests/test_compose_math_env.py runs the image CMD with stub python and setup_ollama.sh across provider and OFFLINE values, checks the production branch never runs the setup, that the ollama service is profile-gated and no stack starts Ollama without a profile, and that delphi forwards OFFLINE. Nine of the new cases fail against the previous Dockerfile and compose file. No behaviour change for pol.is: production deploys start named services (scripts/after_install.sh), never ollama, and run the image with DYNAMODB_ENDPOINT unset. A development stack with the default LLM_PROVIDER=anthropic no longer starts the ollama container or pulls a model. No schema change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
OFFLINE=1 (or true) is for a box with no network (offline profile item 5). Unset, nothing changes. When set, the server skips: - Auth0 Management API in isProConvo (routes/comments.ts), reached on every participant comment post and on comment lists filtered by mod_gt: it answers false without a lookup. False is what the function already returns on every error path, so the box keeps today's offline result minus the network timeout, and the Gemini / ip-api.com moderation it gates is never reached. - Akismet verifyKey at module load (server.ts); nothing else calls Akismet. - dd-trace init in production mode (index.ts), via shouldInitTracer. - Google Translate: SHOULD_USE_TRANSLATION_API is ignored (comment.ts). - SES: with SES_ENDPOINT unset, sends become a debug log of the subject only and resolve with no message id. A set SES_ENDPOINT (ses-local) still gets the mail. Each skip is announced once at startup (utils/offline.ts), never per request. Compose forwards OFFLINE to the server service, empty by default. docs/configuration.md gains an "Offline mode (server)" section. Tests: __tests__/unit/offlineFlag.test.ts loads each real module with the flag on and off; delphi/tests/test_compose_offline.py checks the compose passthrough. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
…N tags
The report loaded d3 v4 (d3js.org), d3-scale-chromatic v1 (d3js.org),
Plotly 2.27.0 (cdn.plot.ly) and Font Awesome 4.4.0 (maxcdn) from tags in
public/index.html. With no network the graphs and topic plots fail.
- Pin the versions those URLs served: d3 4.13.0 (was ~4.6.0 in
package.json, while the page ran the 4.13.0 global), d3-scale-chromatic
1.5.0 and plotly.js-dist-min 2.27.0 (its plotly.min.js is byte-identical
to cdn.plot.ly/plotly-2.27.0.min.js).
- src/vendorGlobals.js, the first import of src/index.js, sets window.d3
(d3 plus the chromatic schemes, as the two UMD scripts did, with d3.event
kept live) and window.Plotly. The call sites and the unit tests that stub
those globals stay as they are.
- Drop the webpack `externals: { d3: "d3" }` so d3 is bundled.
- Remove the Font Awesome stylesheet: no fa- class or react-fontawesome
component is used anywhere in client-report, so no icon set is needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
public/index.html loaded Space Mono (400, 700, 400 italic) from fonts.googleapis.com. Ship the same woff2 files Google Fonts served (latin, latin-ext and vietnamese subsets for each style) under public/font/space-mono/ with the SIL OFL licence, and declare them with @font-face in the page's existing <style> block, keeping the same unicode ranges and font-display: swap. CopyPlugin already copies public/ into the build, and the server already proxies /font/* to the file server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
Offline profile item 7. SentenceTransformer downloads all-MiniLM-L6-v2 from the Hugging Face hub on first use (embedding.py:63-78), so a box with no network fails its first run. - Dockerfile (final stage): ARG BAKE_EMBEDDING_MODEL=false and ARG SENTENCE_TRANSFORMER_MODEL=all-MiniLM-L6-v2. With true, the model is downloaded at build time into the default HF cache (about 92 MB for MiniLM-L6); a failed download fails the build. With the default the step runs nothing, so the production image contents are unchanged. - Compose passes both args to delphi and math-python (same image tag), and forwards OFFLINE to delphi with fallback empty. That line is byte-identical to the one in #2929, so the two merge cleanly in either order. - polismath/utils/offline_env.py: with OFFLINE 1 or true, the job poller and run_delphi.py set HF_HUB_OFFLINE=1 and TRANSFORMERS_OFFLINE=1 on their own environment before spawning any pipeline step (the HF libraries read them at import), and the embedding engine loads with local_files_only. - docs/configuration.md: "Offline embedding model (Delphi)", including the image-size cost and building with USE_CPU_TORCH=true for an offline box. Tests (delphi/tests/test_compose_offline.py): compose forwards OFFLINE and the model name, build args default to false on both services and match, the Dockerfile defaults match compose, the bake RUN runs python only for true and fails the build on a failed download, the flag values, the spawners apply the flags before spawning, and the engine's local_files_only follows OFFLINE. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
…e source Review follow-up. - The server parsed OFFLINE with the `boolean` package, which also accepts yes/y/t, while the Delphi image and job poller accept only 1 and true, so OFFLINE=yes would have switched the server off-network but not Delphi. The server now accepts the same two values (any case, trimmed); tests cover yes/on/y/t staying off. docs/configuration.md no longer claims yes/on. - delphi/Dockerfile: the model download moves to its own `embedding-model` stage built on the dependency layer (`builder-deps`), before any project source is copied, so a code change no longer re-downloads the model. The final stage copies /models/ into /root/ ahead of the packages; with the default the directory is empty and the copy adds no files. Tests check the stage order and the copy. docs/configuration-env-reference.md is not edited: it is a census pinned to a source snapshot with counted totals, so a hand edit would make it disagree with its own snapshot. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
…gin/offline-2-server-flag-baked-model' and 'origin/offline-3-vendor-report-libs' into offline-4-overlay-bundle
docker-compose.offline.yml runs Polis on one machine with no network. Core tier: postgres, server, file-server, nginx-proxy, client-participation-alpha (nginx proxies to it by name) and math-python (pool 1, 1.5 GB limit, hostname identity, the shared MATH_ENV), with the oidc-simulator as the admin login issuer. --profile offline-topics adds delphi (CPU torch, baked model, Ollama), ollama, dynamodb and minio. Built images get local polis-offline/* names; OFFLINE=1 reaches the server, math-python, delphi and the client build. make OFFLINE start replaces the placeholder target: it reads offline.env (example.offline.env is the template), runs the overlay with only the offline-topics profile when OFFLINE_TOPICS=true, and exports OFFLINE=1, BAKE_EMBEDDING_MODEL=true and USE_CPU_TORCH=true. Profiles chosen by PROD/TEST/OFFLINE are no longer appended a second time; make start is unchanged. ci/offline_compose_config_test.sh (parse only) checks the services per tier, that the rendered core tier names no hosted endpoint, and the offline settings; a small workflow runs it on pull requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
scripts/offline-bundle.sh save writes one archive: docker save of every image the tier runs, a manifest of content ids and repo digests, git archive of the checkout, optionally the ollama model volume, and checksums. load checks the checksums, runs docker load and refuses to finish unless every image is present with the manifest's content id. docs/offline.md: tiers, machine sizing, build and install steps, the acceptance checklist, and what still reaches out today (the issuer's mkcert certificates, the legacy page's pol.is images, data export, Delphi plots, the emulators, narrative and collective statement). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
- Bundle script: save and load exited 1 on success and left their scratch directory behind, because the EXIT trap named a function-local variable. The scratch dir is now global, cleaned by a top-level trap, and the script exits 0. New `pull` fetches the upstream topic images at the digests in offline-images.lock; save refuses any other copy, so two bundles carry the same bytes. save prints the archive's sha256; the usage text no longer prints the script's first command. - Overlay: restart: unless-stopped on nginx-proxy, file-server, dynamodb and minio, so a reboot brings ports 80/443 back. nginx serves 443 with the mkcert certificate. - Config test: the hosted-endpoint grep also covers datadoghq, huggingface, ollama.com, cloudflare, jsdelivr and unpkg; it checks a restart policy on every service and that upstream images are pinned. - Guide: admin login over https (oidc-client-ts needs a secure context), verified from a second device; the certificate names the box; the box name is fixed at build time; make and bash on the box; commands for checklist items 1, 3, 4, 8 and 9; DEV_MODE=true side effects and how to avoid them; peak disk during load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
This was referenced Oct 3, 2026
…ocal narratives example.offline.env sets OLLAMA_HOST=http://ollama:11434: the server reads it for the narrative and collective statement and would otherwise use localhost. docs/offline.md takes the lines the data export PR (#2940) and the Ollama narrative PR (#2945) left for it: checklist item 6 adds the conversation data export zip, item 7 has the narrative and collective statement from the local model, and the known gaps drop the Anthropic-only line and describe the streamed export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
Contributor
Delphi Coverage Report
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2929, #2937 and #2936. This branch merges those three branches, so until they land the diff shows their changes too. This PR's own changes are the last three commits (
bedebc536,850d05bd8,a373adc55).This is the fourth offline-profile PR. It adds:
docker-compose.offline.yml;make OFFLINE start, replacing the placeholder target from offline profile 1: drop the unused CDN tag, gate analytics on production builds, fix the Makefile profile test, gate the Ollama pull #2929;scripts/offline-bundle.sh(docker save→ one archive →docker loadon the box);docs/offline.md;It builds on the sibling flags exactly as they are named:
OFFLINE(1/true) for the client build arg, the server and delphi;BAKE_EMBEDDING_MODEL;USE_CPU_TORCH.Services per tier
OFFLINE=1, trusts the issuer's mkcert CA, mounts the JWT keysOFFLINE=1; GA and Datadog RUM args empty/alpha/to it by name and nginx will not start if that name does not resolveMATH_WORKER_POOL_SIZE=1; 1536m limit;MATH_POLLER_ALLOW_HOSTNAME_IDENTITY=1;MATH_ENVshared with the server and delphi (python)offline-topicsOFFLINE=1,LLM_PROVIDER=ollamaoffline-topicsollama-modelsvolume, never pulled on the boxoffline-topicsNot started in either tier: ses-local, localstack, import-worker, coordinator-idle. Every image the overlay builds is named
polis-offline/*in place of the ECR and Docker Hub names, so the rendered config names no hosted registry.The Makefile
make OFFLINE startreadsoffline.env, orOFFLINE_ENV_FILE;example.offline.envis the template, andoffline.envis gitignored. It runs-f docker-compose.yml -f docker-compose.offline.yml, adds--profile offline-topicsonly whenOFFLINE_TOPICS=true, and exportsOFFLINE=1 BAKE_EMBEDDING_MODEL=true USE_CPU_TORCH=true.One side fix: when
PROD,TESTorOFFLINEhas already chosen the profiles,get_env_varsno longer appends them a second time.make PROD startused to print--profile postgres --profile local-servicestwice; it now prints them once.make startrenders the identical command (checked withmake -n).The bundle
scripts/offline-bundle.sh save [--topics] [--with-models]writes one tar. It holds:images.tar:docker saveof every imagedocker compose config --imageslists for the tier;manifest.tsv: image, content id, repo digest;source.tar:git archive HEAD;models.tar, the ollama volume;SHA256SUMS.loadchecks the sums, runsdocker load, and refuses to finish unless every manifest image is present with the same content id. The images are pinned by that id. In the overlay, minio is named by its tag rather than tag@digest, becausedocker loaddoes not always restore a repo digest and compose would then try to pull. The manifest still records the digest.Test
ci/offline_compose_config_test.shusesdocker compose configandmake -nonly. It checks:offline-topicslists exactly the 11;amazonaws|auth0|anthropic|simpleanalytics|googleapis;polis-offline/*;OFFLINE=1on server, math-python and delphi;MATH_ENV=pythonon all three;OFFLINEarg;make -n OFFLINE startadds no dev, local-services or ollama profile.Local result: all checks pass. When the overlay was broken by hand (an ECR image name, pool 4), the test failed with 4 failures. A new
Offline compose configworkflow runs it on pull requests that touch these files.Acceptance checklist (docs/offline.md)
The acceptance test: a participant can open a conversation, vote, and see groups and consensus with the network cable unplugged; an admin can create a conversation and read the report.
make OFFLINE start: every core service comes up and an egress-deny firewall log stays empty/<conversation_id>from a phone on the box's Wi-Fi; every request goes to the box (known exception below)math_mainrowSizing: the core tier needs 4 GB RAM and 2 vCPU (x86-64). With topics and
llama3.1:8b, it needs 16 GB.What is still outstanding
<img>tags (participation.handlebars:53,71,conversationTabs.handlebars:116). Offline they are broken images, so checklist item 2 cannot pass strictly until they are self-hosted.Not run (laptop budget): no image builds, no stack, no bundle save or load.
bash -npasses on the bundle script.Review fixes (a373adc)
saveandloadexited 1 on success and left their scratch directory behind, because the EXIT trap used a function-local variable. Both now exit 0 and clean up.loadround trip of a small local image: rc 0, nothing left behind. Before the fix: rc 1, directory leaked.offline-images.lockpins ollama, dynamodb-local and minio by digest.offline-bundle.sh pullfetches exactly those digests, andsaverefuses any other copy.savealso prints the archive's sha256 so it can be compared out of band.restart: unless-stopped, so a reboot brings ports 80/443 back.https://<box>/, because oidc-client-ts needs a secure context. The checklist now says to verify login from a second device.makeand bash are needed on the box;DEV_MODE=trueand how to avoid them;load.No change to the default stack or production. No schema change.
🤖 Generated with Claude Code
https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s