diff --git a/.dagger/src/index.ts b/.dagger/src/index.ts index 2a2d40e1c..ca3a66cbe 100644 --- a/.dagger/src/index.ts +++ b/.dagger/src/index.ts @@ -50,7 +50,9 @@ function touchWorkspaceSources(container: Container): Container { } const NODE_IMAGE = 'node:22'; -const RUST_IMAGE = 'rust:bookworm'; +// Checked against rust-toolchain.toml by scripts/check-rust-alignment.py. +const RUST_VERSION = '1.98.1'; +const RUST_IMAGE = `rust:${RUST_VERSION}-bookworm`; // Pin the tools and their published dependency locks. Unlocked linkcheck // installation picked up jiff 0.2.36, whose packaged doc includes are broken. @@ -198,16 +200,14 @@ function condenseErrorContext(body: string): string { } const HOST_PROFILES: Record = { - // 4 shards × 2 workers ≈ 8 browsers. `ci()` runs endToEnd concurrently with - // clippy/nextest/flutter/vitest, so the box carries those browsers AND their - // four optimized atomic-servers AND cargoBuildJobs=8 AND a 6-wide nextest at the - // same time. Earlier 3-worker runs produced 12 browsers and the suite - // failed accordingly — including a chromium killed outright ("Target page, - // context or browser has been closed"), which is starvation, not a race. - // Raise this only alongside the cargo/nextest widths it shares the host with. + // Four browser workers total, one per shard/server. At eight, full develop + // runs repeatedly exhausted settings-save and app-creation waits while the + // same journeys passed in focused runs. The full local suite also passed + // with two workers and no retries. Keep browser headroom alongside the + // Rust, WASM and frontend jobs instead of widening every interaction wait. mancave: { e2eShardCount: 4, - e2ePlaywrightWorkers: '2', + e2ePlaywrightWorkers: '1', // Back to the suite's own documented default (playwright.config.ts): three // attempts catch a genuinely flaky path while a real regression still // fails all three. This branch dropped it to 1 for runtime, and that trade @@ -327,6 +327,11 @@ export class AtomicServer { ): Container { return ( container + .withExec([ + 'rustup', 'toolchain', 'install', RUST_VERSION, + '--profile', 'minimal', '--component', 'rustfmt,clippy', + ]) + .withEnvVariable('RUSTUP_TOOLCHAIN', RUST_VERSION) .withMountedCache( `${cargoHome}/registry`, dag.cacheVolume('cargo-shared-locks-v1'), @@ -491,7 +496,7 @@ export class AtomicServer { // Fail fast on cheap static checks. A store.ts oxfmt miss used to burn // ~20+ minutes of rust/e2e compile before jsLint surfaced it. - await Promise.all([this.jsLint(), this.rustFmt()]); + await Promise.all([this.jsLint(), this.jsTypecheck(), this.rustFmt()]); // Rust clippy/test still share the `rust-target` cache mount — keep // them serialized (parallel cargo contended the target lock for @@ -530,6 +535,82 @@ export class AtomicServer { .stdout(); } + @func() + async jsTypecheck(): Promise { + // A first attempt at this (#1590) ran `pnpm run typecheck` here, passed + // on a checkout, and failed sixty seconds into its first CI run. Nothing + // it reported was a type error: `jsSource()` does not lay the tree out + // the way a checkout does. The three differences it hit are handled + // below, each one reproduced and then re-checked against a replica of + // this container's paths. A clean `tsc` in a checkout proves nothing + // about this function, so validate a change to it the same way, or by + // dispatching `main.yml` on a branch. + const depsContainer = this.jsSource() + // 1. `data-browser/tsconfig.json` maps `@repo-lib-defaults/*` to + // `../../lib/defaults/*`, which is repo-root `lib/defaults`. The + // browser mounts at /app, so that lands on /lib/defaults, where + // `jsSource()` places only `tasks.json`, and bootstrap.ts's ten + // imports came back TS2307. Mount the directory itself. As with the + // genesis vectors mounted beside it, staying a level below /lib + // leaves the OS libraries alone. + .withDirectory('/lib/defaults', this.source.directory('lib/defaults')); + + return ( + depsContainer + .withWorkdir('/app') + // 2. Packages reached through node_modules need a `dist`. Building + // only lib and react left `@tomic/plugin`, `@tomic/service-ui` and + // `@tomic/edit-mode/react` unresolvable. All five build from + // TypeScript alone, so this stays in the cheap static tier beside + // lint and `cargo fmt`: no WASM, no Rust. + .withExec([ + 'pnpm', + '--filter', + '@tomic/lib', + '--filter', + '@tomic/react', + '--filter', + '@tomic/plugin', + '--filter', + '@tomic/service-ui', + '--filter', + '@tomic/edit-mode', + 'build', + ]) + .withExec([ + 'pnpm', + '--filter=!@tomic/data-browser', + 'run', + '-r', + '--parallel', + 'typecheck', + ]) + // 3. data-browser is the one package that reaches repo-root + // `integrations`, and those files import + // `../../browser/lib/src/index.js`, which here is /browser: the + // symlink `jsSource()` makes so integration tsconfigs can find + // `../../browser/tsconfig.build.json`. `tsc` keeps whichever + // prefix it is handed, so compiling data-browser as /app while its + // own imports arrive as /browser produces two unrelated + // declarations of every type in `lib`, which is the wall of + // "Store is not assignable to Store" the first attempt hit. + // Naming the project by its /browser path puts both ends on one + // prefix. A workdir cannot do this: the kernel resolves the + // symlink, so `process.cwd()` would be /app again. + .withExec([ + 'pnpm', + '--filter', + '@tomic/data-browser', + 'exec', + 'tsc', + '--noEmit', + '-p', + '/browser/data-browser/tsconfig.json', + ]) + .stdout() + ); + } + @func() async jsTest(): Promise { const depsContainer = this.jsBuild(); @@ -607,6 +688,7 @@ export class AtomicServer { dag .container() .from(FLUTTER_IMAGE) + .withEnvVariable('RUSTUP_TOOLCHAIN', RUST_VERSION) .withEnvVariable('CI', 'true') // Same pin as withCargoHomeCache — flutter's cargokit build would // otherwise see all host CPUs. @@ -638,6 +720,10 @@ export class AtomicServer { '-c', 'if [ ! -x "$HOME/.cargo/bin/rustc" ]; then curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal; fi', ]) + .withExec([ + 'sh', '-c', + `${pathPrefix}; rustup toolchain install ${RUST_VERSION} --profile minimal`, + ]) .withDirectory('/workspace/lib', this.source.directory('lib')) .withDirectory('/workspace/flutter', this.source.directory('flutter')) .withMountedCache('/workspace/flutter/rust/target', flutterRustTarget, { @@ -810,6 +896,7 @@ export class AtomicServer { .withExec([ 'cargo', 'build', + '--locked', '-p', 'atomic-server', '--no-default-features', @@ -1009,11 +1096,34 @@ export class AtomicServer { ); } - /** Extracts the unique deploy URL from netlify output */ + /** + * Extracts the unique deploy URL from netlify output. + * + * Says which of the two failures happened, because they need opposite + * responses and for weeks they printed the same sentence. `netlifyDeploy` + * exits 0 with a skip message when `NETLIFY_AUTH_TOKEN` is empty, so an + * unset secret and a parse miss both arrived as "Deploy URL not found" — + * which reads like the URL format changed and is the reason nobody noticed + * that every failed e2e run on develop was publishing no report at all. + * + * That report is not a nicety. `playwright.config.ts` records traces with + * `retain-on-failure`, and this deploy is the only path that carries them + * off the runner: the `upload-artifact` step in `main-ci.yml` uploads + * `./artifact`, which nothing writes, because the Dagger container holding + * them is discarded when the `ci` call throws. So with the token unset the + * per-shard 20k-char log tail is the entire evidence channel for a failed + * run, and "which assertion failed" arrives without "why". + */ private extractDeployUrl(netlifyOutput: string): string { const match = netlifyOutput.match(/https:\/\/[a-f0-9]+--.+\.netlify\.app/); - return match ? match[0] : 'Deploy URL not found'; + if (match) return match[0]; + + if (netlifyOutput.includes('NETLIFY_AUTH_TOKEN not set')) { + return 'no report deployed — NETLIFY_AUTH_TOKEN is empty on this runner, so traces and error-context for this shard were discarded with the container'; + } + + return 'Deploy URL not found (netlify ran but printed no deploy URL)'; } @func() @@ -1156,6 +1266,15 @@ export class AtomicServer { .withFile( '/lib/defaults/tasks.json', this.source.file('lib/defaults/tasks.json'), + ) + // browser/e2e/tests/apps.spec.ts serves this checkout's embedded app SDK + // as a fixture, read with a plain `readFileSync` at + // `../../../server/src/plugins/assets/view-client.js`. From /app/e2e/tests + // that resolves to /server/..., and the Rust tree is not mounted here, so + // mount just this one file. + .withFile( + '/server/src/plugins/assets/view-client.js', + this.source.file('server/src/plugins/assets/view-client.js'), ); return sourceContainer; @@ -1174,9 +1293,22 @@ export class AtomicServer { // data-browser/src/config.ts. buildContainer = buildContainer .withEnvVariable('VITE_E2E', 'true') + // The mock integration proxy runs beside the server, so from the + // server's own process it is on loopback. This value is not the + // server's: it is baked into the bundle and used by the browser, + // which runs in the playwright container, where 127.0.0.1 is that + // container and nothing answers on 19090. Every page that lists + // integrations then shows a "TypeError: Failed to fetch" alert, which + // is a second `role="alert"` on screen and makes the specs that assert + // on an alert either read the wrong one or fail strict mode. + // + // `atomic.localhost` is the name the browser is told to map to the + // server service (see ATOMIC_TEST_HOST_MAP, and the note on + // ATOMIC_DOMAIN above), and the mapping is per host, not per port, so + // this reaches the same container's exposed 19090. .withEnvVariable( 'VITE_INTEGRATION_PROXY_URL', - 'http://127.0.0.1:19090', + 'http://atomic.localhost:19090', ); } @@ -1203,6 +1335,7 @@ export class AtomicServer { .withExec(['apt', 'install', '-y', 'nasm', 'protobuf-compiler']), CARGO_HOME_MUSL, ) + .withExec(['rustup', 'target', 'add', target]) .withExec(['rustup', 'component', 'add', 'clippy']) .withExec(['rustup', 'component', 'add', 'rustfmt']); // cargo-nextest used to be installed here, but recent versions need @@ -1245,7 +1378,7 @@ export class AtomicServer { .withMountedCache('/code/target', dag.cacheVolume('rust-target-v3')) .with(touchWorkspaceSources) .withWorkdir('/code') - .withExec(['cargo', 'fetch']); + .withExec(['cargo', 'fetch', '--locked']); const browserDir = this.jsBuild(e2e).directory('/app/data-browser/dist'); const containerWithAssets = sourceContainer.withDirectory( @@ -1261,10 +1394,10 @@ export class AtomicServer { // at an optimisation level where commit round-trips stop dominating, and // cheap enough to compile that Playwright is not left waiting on LTO. const buildArgs = e2e - ? ['cargo', 'build', '--profile', 'e2e', '-p', 'atomic-server'] + ? ['cargo', 'build', '--locked', '--profile', 'e2e', '-p', 'atomic-server'] : release - ? ['cargo', 'build', '--release', '-p', 'atomic-server'] - : ['cargo', 'build', '-p', 'atomic-server']; + ? ['cargo', 'build', '--locked', '--release', '-p', 'atomic-server'] + : ['cargo', 'build', '--locked', '-p', 'atomic-server']; // ⚠️ PRODUCTION IMPACT, not just CI plumbing (2026-07-02): this // function backs BOTH the e2e test server (atomicService) AND the real @@ -1398,6 +1531,7 @@ export class AtomicServer { .withExec(['apt', 'install', '-y', 'nasm', 'protobuf-compiler']), CARGO_HOME_MUSL, ) + .withExec(['rustup', 'target', 'add', 'x86_64-unknown-linux-musl']) .withExec(['rustup', 'component', 'add', 'clippy']) .withExec(['rustup', 'component', 'add', 'rustfmt']) .withFile('/code/Cargo.toml', source.file('Cargo.toml')) @@ -1416,6 +1550,16 @@ export class AtomicServer { '/code/testdata/pairing-request.json', source.file('testdata/pairing-request.json'), ) + // server/src/plugins/plugin.rs and handlers/plugin_release_test.rs + // `include_bytes!` the Playwright suite's plugin zip, which is the one + // packaged plugin both sides test against. Nothing else from + // `browser/` belongs in this container, and mounting the tree would + // make every front-end edit invalidate the Rust layer, so mount the + // single file. Same reasoning as the pairing-contract fixture above. + .withFile( + '/code/browser/e2e/tests/fixtures/test-plugin.zip', + source.file('browser/e2e/tests/fixtures/test-plugin.zip'), + ) .withDirectory('/code/server', source.directory('server')) .withDirectory('/code/integrations', source.directory('integrations')) .withDirectory('/code/testdata', source.directory('testdata')) @@ -1450,7 +1594,7 @@ export class AtomicServer { '-c', 'echo "checks stub" > /code/server/assets_tmp/index.html', ]) - .withExec(['cargo', 'fetch']) + .withExec(['cargo', 'fetch', '--locked']) ); } @@ -1499,7 +1643,7 @@ export class AtomicServer { 'BIN_DIR=/opt/cargo-bin/bin && mkdir -p "$BIN_DIR" && ' + 'if [ ! -x "$BIN_DIR/cargo-nextest" ]; then ' + 'curl -LsSf https://get.nexte.st/latest/linux-musl | tar zxf - -C "$BIN_DIR"; fi && ' + - 'cargo nextest run --workspace --exclude atomic-server-tauri ' + + 'cargo nextest run --locked --workspace --exclude atomic-server-tauri ' + '--no-default-features --features light,wasm-plugins ' + `--build-jobs ${this.hostKnobs.nextestBuildJobs} ` + `--test-threads ${this.hostKnobs.nextestTestThreads} ` + @@ -1531,6 +1675,7 @@ export class AtomicServer { .withExec([ 'cargo', 'clippy', + '--locked', '--workspace', '--exclude', 'atomic-server-tauri', @@ -1751,11 +1896,59 @@ export class AtomicServer { ) .withEnvVariable('MOCK_FRONTEND_ORIGIN', 'http://atomic.localhost:9883') .withEnvVariable('MOCK_PROXY_HOST', '0.0.0.0') + // Website publishing is off until the server is given a site origin, + // and the website specs then get a "hosting is disabled" toast that + // also sits over the preview and swallows clicks meant for it. The + // server asks for a separate `.localhost` origin in development; this + // is that, and it has to stay outside the API domain. + .withEnvVariable('ATOMIC_WEBSITE_ORIGIN', 'http://sites.localhost:9883') + // The name the server answers to, which until now was not the name it + // is addressed by. `ATOMIC_DOMAIN` above is the dagger hostname, and + // the server was given the same string, so its configured origin was + // `http://atomic:9883` while every browser-created subject carried + // `http://atomic.localhost:9883`. Those two are compared as authorities + // in `Subject::from_raw`, where `atomic.localhost:9883` matches neither + // `atomic:9883` nor the `.atomic:9883` suffix case, so the server read + // its own subjects as somebody else's: + // + // from_raw(".../releases/blake3:1a0b3fbb", Some("http://atomic:9883")) + // -> is_local false + // from_raw(".../releases/blake3:1a0b3fbb", Some("http://atomic.localhost:9883")) + // -> is_local true + // + // Splitting the two lets the server know its own name while dagger + // keeps addressing the container as `atomic`. Routing does not move + // with it: `map_request_subject` (lib/src/db.rs) only re-routes a host + // explicitly bound to a Drive, and `atomic` is not bound, so the + // containers that curl `http://atomic:9883` are unaffected. + .withEnvVariable('ATOMIC_DOMAIN', 'atomic.localhost') .withExposedPort(19090) .withEntrypoint([ 'sh', '-c', - 'node /mock-proxy/mock-proxy.mjs & exec /atomic-server-bin', + // Makes `atomic.localhost` resolve inside this container. RFC 6761 + // gives `.localhost` to loopback, but that is a rule browsers and + // Node implement and glibc does not: with `hosts: files dns` the + // name does not resolve at all, and anything here that looks it up + // fails before a request goes out. + // + // This is no longer about `plugin.spec.ts:26`. That was fixed by + // giving the server its own `ATOMIC_DOMAIN` above, so it reads its + // own subjects locally instead of fetching them, and the run after + // that change was green on `:26`, `mt940:16` and + // `installation-recovery:96`. What this line covers now is + // everything else in the container that resolves the name: the + // server for any subject genuinely on another host, and the Node + // mock proxy, which is given `atomic.localhost:9883` as its frontend + // origin. That is a wider scope than the SSRF escape hatch removed + // alongside it, which reached only five Rust call sites, so the two + // were not a pair despite arriving in one commit. + // + // Written at start rather than baked in, because the runtime mounts + // its own `/etc/hosts` over the image's. The server binds `::`, so + // once the name resolves it reaches itself. + 'echo "127.0.0.1 atomic.localhost" >> /etc/hosts; ' + + 'node /mock-proxy/mock-proxy.mjs & exec /atomic-server-bin', ]); // Dagger deduplicates identical services, including their writable state. @@ -1858,6 +2051,16 @@ export class AtomicServer { // devonian-issue-sync.spec.mts) reach into ../../../integrations // relative to /app/e2e/tests, resolving to /integrations here. .withDirectory('/integrations', this.source.directory('integrations')) + // Same shape, one file: apps.spec.ts reads the embedded app SDK with a + // plain `readFileSync` at `../../../server/src/plugins/assets/ + // view-client.js`, which from /app/e2e/tests is /server/... . jsSource() + // mounts it for browser/plugin's unit test, but the specs run here, in a + // fresh Playwright image that copies only what is named, so this + // container needs its own copy. + .withFile( + '/server/src/plugins/assets/view-client.js', + this.source.file('server/src/plugins/assets/view-client.js'), + ) .withWorkdir('/app/e2e') .withMountedCache('/app/.pnpm-store', dag.cacheVolume('pnpm-store')) .withExec(['pnpm', 'config', 'set', 'store-dir', '/app/.pnpm-store']) diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml index fc7471f16..877e7c4a1 100644 --- a/.github/workflows/main-ci.yml +++ b/.github/workflows/main-ci.yml @@ -93,9 +93,19 @@ jobs: # the argument. args: ci --netlify-auth-token env://NETLIFY_TOKEN --host-profile ${{ inputs.host-profile }} --playwright-mode ${{ inputs.e2e-mode }} ${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-') && '--publish-docs' || '' }} - name: Upload artifacts - # `always()`: the e2e traces exported above are only interesting when - # the CI step failed, and without this the upload is skipped exactly - # then. + # `always()`: whatever lands in ./artifact is only interesting when the + # CI step failed, and without this the upload is skipped exactly then. + # + # Nothing writes ./artifact today, so this step uploads nothing on + # every run. The comment here used to say "the e2e traces exported + # above", which is what it was meant to carry and never has: the + # Dagger container holding playwright-report and test-results is + # discarded when the `ci` call throws, and `.dagger` has no host + # export. The disabled wiring is still in browser/e2e/playwright.config.ts + # (`// outputFolder: '/artifact/test-report'`). Until one of those is + # finished, a failed run's only evidence is the per-shard log tail in + # the thrown error, plus the Netlify report when NETLIFY_TOKEN is set — + # which it currently is not on the self-hosted runner. if: always() uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aabd7b787..0f5f362ea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,25 +19,19 @@ concurrency: cancel-in-progress: ${{ github.ref_type == 'branch' && github.ref_name != 'develop' }} # Main prefers Mancave (self-hosted) so Dagger cache volumes stay warm. -# GitHub-hosted runs ONLY when Mancave is unavailable — never as a retry +# GitHub-hosted runs only when explicitly selected or required for PRs, never as a retry # after a red test suite. # # Flow: -# 1. Pick runner — online self-hosted? (optional CI_RUNNER_STATUS_TOKEN) +# 1. Pick runner — trusted self-hosted or explicitly hosted # 2. Main (Mancave) XOR Main (GitHub) — one path, not failure-failover # 3. Main — aggregator for the required status check # -# Availability check needs a PAT that can list repo runners (GITHUB_TOKEN -# cannot). Store it as Actions secret CI_RUNNER_STATUS_TOKEN. Without that -# secret we assume Mancave is up (same as before) and will not fall back -# when tests fail. -# -# Escape hatch (force hosted, skip Mancave): -# Settings -> Secrets and variables -> Actions -> Variables -# CI_RUNNER = ["ubuntu-latest"] -# -# Only this workflow uses the self-hosted runner. Releasing/deploying stay -# on ubuntu-latest — a release must not depend on one PC being awake. +# Trusted runs start directly on Mancave, including selector and result jobs. +# There is no GitHub-hosted prerequisite, so exhausted Actions budgets do not +# block self-hosted CI. If Mancave is offline, jobs queue; explicitly set the +# repository variable CI_RUNNER = ["ubuntu-latest"] to use hosted runners. +# No runner-status PAT is needed. Deployments retain their existing runners. # # SECURITY: pull_request / pull_request_target are forced onto hosted # runners (never Mancave). @@ -47,7 +41,9 @@ name: "Main pipeline: build, lint, test" jobs: pick: name: Pick runner - runs-on: ubuntu-latest + # Trusted runs can start without a GitHub-hosted billing prerequisite. + # Mancave must be online; use CI_RUNNER to explicitly select hosted runners. + runs-on: ${{ fromJSON((github.event_name == 'pull_request_target' || github.event_name == 'pull_request' || vars.CI_RUNNER == '["ubuntu-latest"]') && '["ubuntu-latest"]' || (vars.CI_RUNNER || '["self-hosted", "Linux", "X64"]')) }} permissions: contents: read pull-requests: read @@ -57,7 +53,6 @@ jobs: steps: - id: pick env: - GH_TOKEN: ${{ secrets.CI_RUNNER_STATUS_TOKEN }} FORCE_RUNNER: ${{ vars.CI_RUNNER }} EVENT_NAME: ${{ github.event_name }} REPO: ${{ github.repository }} @@ -76,37 +71,8 @@ jobs: exit 0 fi - if [ -z "${GH_TOKEN:-}" ]; then - echo "No CI_RUNNER_STATUS_TOKEN — assuming Mancave online" - echo "host=mancave" >> "$GITHUB_OUTPUT" - exit 0 - fi - - # Any online runner carrying the self-hosted label counts as - # available (busy is fine — the job will wait its turn). - # On API errors (bad/insufficient PAT), prefer Mancave — do NOT - # treat a 403 as "offline" or we skip the warm box forever. - set +e - body=$(gh api "repos/$REPO/actions/runners" 2>/tmp/runner-api.err) - api_status=$? - set -e - if [ "$api_status" -ne 0 ]; then - echo "Runner API failed (is CI_RUNNER_STATUS_TOKEN a fine-grained PAT with Repository Administration: Read?):" - cat /tmp/runner-api.err || true - echo "Assuming Mancave online" - echo "host=mancave" >> "$GITHUB_OUTPUT" - exit 0 - fi - - if printf '%s' "$body" | jq -e \ - 'any(.runners[]; .status == "online" and any(.labels[]; .name == "self-hosted"))' \ - >/dev/null; then - echo "Self-hosted runner online — using Mancave" - echo "host=mancave" >> "$GITHUB_OUTPUT" - else - echo "No online self-hosted runner — falling back to GitHub-hosted" - echo "host=hosted" >> "$GITHUB_OUTPUT" - fi + echo "Selector is running on the self-hosted runner — using Mancave" + echo "host=mancave" >> "$GITHUB_OUTPUT" - id: e2e env: @@ -206,7 +172,7 @@ jobs: id: saas env: GH_TOKEN: ${{ secrets.ATOMIC_SAAS_DISPATCH_TOKEN }} - BRANCH: ${{ github.ref_name }} + BRANCH: ${{ github.head_ref || github.ref_name }} run: | set -euo pipefail if [ -z "${GH_TOKEN:-}" ]; then @@ -238,6 +204,13 @@ jobs: # (where `clean: false` keeps the checkout around between runs). persist-credentials: false + - name: Set up Python for Rust alignment checks + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Verify paired Rust toolchains and dependencies + run: python3 atomic-server/scripts/check-rust-alignment.py --server atomic-server --saas atomic-saas + - name: Install Rust uses: dtolnay/rust-toolchain@1.98.1 with: @@ -267,28 +240,22 @@ jobs: npm ci npm run build - # Not `--locked`: this commit may have changed atomic_lib's own - # dependencies, which legitimately moves atomic-saas's lockfile. What is - # being checked is that the code still builds and passes; a lock update - # is reported so the saas side commits it on its next touch. + # Both lockfiles must describe the tested pair; update them in paired PRs. - name: cargo check, clippy and test atomic-saas against this commit working-directory: atomic-saas run: | set -euo pipefail - cargo check --all-targets - cargo clippy --all-targets -- -D warnings - cargo test --all-targets + cargo check --locked --all-targets + cargo clippy --locked --all-targets -- -D warnings + cargo test --locked --all-targets # The managed node embeds this repo's server crate and is not a # default workspace member, so the root build does not touch it. # Its own CI runs check, clippy and test; the same here. - cargo clippy -p atomic-managed-node --all-targets -- -D warnings - cargo test -p atomic-managed-node - if ! git diff --quiet -- Cargo.lock; then - git diff --stat -- Cargo.lock - echo "::warning::atomic-saas's Cargo.lock drifted against this commit; run cargo check there and commit Cargo.lock." - fi + cargo clippy --locked -p atomic-managed-node --all-targets -- -D warnings + cargo test --locked -p atomic-managed-node + git diff --exit-code -- Cargo.lock - # Hosted only when pick said Mancave is unavailable (or escape/PR). + # Hosted only when explicitly selected or required for PR events. # Deliberately does NOT run when Mancave finished with test failures. github: name: Main (GitHub) @@ -312,7 +279,7 @@ jobs: name: Main needs: [pick, mancave, github, downstream-saas] if: always() && needs.pick.result == 'success' - runs-on: ubuntu-latest + runs-on: ${{ fromJSON(needs.pick.outputs.host == 'hosted' && '["ubuntu-latest"]' || (vars.CI_RUNNER || '["self-hosted", "Linux", "X64"]')) }} steps: - name: Resolve runner outcome run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ee329cb0..1246bdad0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,11 +33,9 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ inputs.tag || github.ref }} - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@1.98.1 with: - toolchain: stable - override: true - target: wasm32-unknown-unknown + targets: wasm32-unknown-unknown # `version: 8` used to be pinned here while browser/package.json declares # `packageManager: pnpm@10.15.1`, and there was no Node at all — so this @@ -281,7 +279,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2.0.1 name: Install pnpm id: pnpm-install @@ -392,12 +390,9 @@ jobs: version: 10 run_install: false - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@1.98.1 with: - profile: minimal - toolchain: stable - override: true - target: wasm32-unknown-unknown + targets: wasm32-unknown-unknown - uses: taiki-e/upload-rust-binary-action@v1 with: # (required) diff --git a/.github/workflows/rust-alignment.yml b/.github/workflows/rust-alignment.yml new file mode 100644 index 000000000..4a2a3346d --- /dev/null +++ b/.github/workflows/rust-alignment.yml @@ -0,0 +1,17 @@ +name: Rust build policy +on: + pull_request: + push: + branches: [develop] +permissions: + contents: read +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: python3 -m unittest discover -s scripts -p 'test_rust_alignment.py' -v + - run: python3 scripts/check-rust-alignment.py diff --git a/.github/workflows/tauri-release.yml b/.github/workflows/tauri-release.yml index 0a017c3f5..ecaf27ad7 100644 --- a/.github/workflows/tauri-release.yml +++ b/.github/workflows/tauri-release.yml @@ -187,7 +187,7 @@ jobs: version: 10 run_install: false - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@1.98.1 with: targets: ${{ matrix.rust-targets }} @@ -400,7 +400,7 @@ jobs: sdkmanager --install "ndk;27.2.12479018" >/dev/null echo "NDK_HOME=${ANDROID_SDK_ROOT}/ndk/27.2.12479018" >> "$GITHUB_ENV" - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@1.98.1 with: # arm64 only: phones/tablets we ship to. The other three Android # targets were Tauri's generated default and made the universal APK @@ -547,7 +547,7 @@ jobs: version: 10 run_install: false - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@1.98.1 with: targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios,wasm32-unknown-unknown diff --git a/.gitignore b/.gitignore index 51f6e7e15..57b394b53 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ scratchpad node_modules/ # Generated integration certification evidence /artifacts/integration-certification/ +# Raw footage and cuts from browser/e2e/scripts/record-*.mjs +/browser/e2e/recordings/ diff --git a/AGENTS.md b/AGENTS.md index 9b331c520..17a6b89e4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,6 +44,16 @@ second writer on tracked files. Four ways that has cost real time: vite sees a file change, and the page reloads. That is not cosmetic: a reload abandons in-flight work, and this silently cancelled a destroy mid-test. If `git status` shows `.po` churn on a clean checkout, settle them and commit. +- **The compiled catalogs are a second artifact.** Wuchale compiles the `.po` + files into `src/locales/.wuchale/`, which is gitignored. `git checkout -- + src/locales/` resets the `.po` files and leaves the compiled output from + another state; the two then disagree and *every indexed string shifts*. + Missing entries show as `[i18n-404:NNN]`; shifted entries show a different + real string, so nothing looks wrong and tests fail on the wrong element. + Whenever you reset the `.po` files, also `rm -rf + browser/data-browser/src/locales/.wuchale` and restart vite. Do not make + the `.po` files read-only to stop the rewrite; the compiled output goes + stale instead. - **`pnpm clean-translations` is not the same writer.** It extracts from test files too, which the vite plugin does not, so its output is a *different* fixed point. Settling by running the app is what matches the dev server. @@ -283,6 +293,13 @@ cd browser && pnpm run test-e2e:light # Playwright @smoke (feature-br cd browser && pnpm run test-e2e # Full Playwright suite (develop / tags) ``` +When you restart an `atomic-server` for tests, gate on `curl` returning HTTP +200, never on the port: redb's lock outlives the listening socket by several +seconds, so an immediate restart exits with "Database already open" and the +suite runs against nothing, failing in ways that look like product bugs. Retry +the spawn when the log says so, and give a fresh server about ten seconds +before the first spec. + `atomic_lib`'s unit tests need the `db` feature — `hierarchy.rs`'s test module calls `Db::init_temp` and `test_utils::setup_test_env`, both gated behind it. So `cargo test -p atomic_lib --no-default-features` does **not** compile; don't diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a26cf56..a9290fcf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,149 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain ## UNRELEASED +- Fix: a stale authentication proof no longer fails a request that needed no + authentication. A browser keeps its proof in the `atomic_session` cookie, and + until `AUTH_MAX_AGE_MS` arrived in 0.41 a proof never expired, so a stale one + is the ordinary state of any tab left open. Every request such a tab made was + answered 401, public ones included: on staging one tab polling the public + `GET /server` endpoint produced 4,215 rejections, all carrying the same + `signed at` timestamp. An HTTP request, and the headers a socket is opened + with, now treat a proof that has aged out as no proof at all and continue as + the public agent, leaving the rights check to decide whether that matters for + what was asked. A signature that does not verify is still refused outright, + and so is a stale proof in an `AUTH` frame or a peer handshake, where the + caller asked to be authenticated and is owed the answer + (`get_agent_from_auth_values_or_public` beside the existing + `get_agent_from_auth_values_and_check`). + +- Sentry no longer records every server error twice. `sentry_actix` captures a + handler's 5xx with the request attached, and `tracing_actix_web` separately + logs "Error encountered while processing the incoming HTTP request" at + `error!`, which the Sentry tracing layer turned into a second event; the two + staging floods of September arrived as paired issue groups of 6313 and 6312 + events for the same incidents. The tracing layer now ignores the + `tracing_actix_web` target and delegates every other target to + `default_event_filter`, so background work reports as before and the stdout + log line is unchanged (`server/src/trace.rs`). + +- Plugin install path, three fixes after the runtime convergence (#1571): + - A publish refused for claiming the wrong `world` used to have already + stored the package bytes and cached the release record. The claim is now + checked before the first write, so a refusal leaves nothing behind + (`POST /plugin-release-package`). + - A JS plugin whose Installation could not be read, or whose `grants` could + not be, ran with everything its own manifest declared. Only a legacy draft + with no Installation still reads the manifest; anything else grants nothing + and logs why. Reading which classes a resource has also went through + `Value::to_subjects`, which errors on the scalar `isA` encodings, so an + encoding alone could widen a plugin's grants. `Resource::class_subjects` + and `Resource::has_class` are the one encoding-tolerant reader, shared + with `ClassExtender`. + - An Installation's `release` is declared an `atomicURL` and now holds one. + The browser's two zip paths dropped the `Release` subject the publish + response carries and stored the bare `blake3:` id, which meant writing the + property with datatype validation switched off. `release::resolve` still + accepts a bare id, for Installations written before this. +- `atomic_lib`: a signed destroy commit now removes the resource (and its + cascade-deleted children, Loro snapshot, index and search rows) in the same + redb transaction that stores its envelope and commit row. `Db::apply_commit` + used to call `remove_resource`, which applied a transaction of its own, so a + crash between the two left a deleted resource with no signed destroy for + `SYNC_DIFF.removeCommits` to carry; tombstones are now recorded once that + single transaction has landed. The destroy branch also returns an error on a + malformed commit instead of panicking the request. +- Security hygiene, from the September 2026 audit (`planning/security-audit-2026-09.md` + D, C16, F): + - CORS: any origin may still read (Atomic is a headless CMS), but + `Access-Control-Allow-Credentials` is now sent only to origins this + server answers for — the configured domain, a subdomain of the base + domain, loopback, and the desktop webview origins (`tauri://localhost`, + `http://tauri.localhost`) — by the same rule `RequestContext` uses for + trusting `Host`. Before, every origin was told it could attach the + session cookie; `SameSite=Lax` was the only thing stopping it + (`server/src/cors.rs`). + - Client errors are answered as client errors instead of 500: a request + body that does not parse is 400 (`AtomicErrorType::ParseError` maps to + `BadRequest`; malformed commits are parse errors), a signature that does + not verify, an unknown signer, or authentication headers that do not + parse are 401 (`Commit::validate_signature` and + `get_agent_from_auth_values_and_check` type every failure as + unauthorized, and `get_client_agent` no longer flattens the type into a + string). These no longer reach Sentry as crashes. + - `/upload` returns 400 when the multipart body cannot be read (no + boundary, truncated part) instead of ending its loop quietly and + answering 200 for the files that made it through. + - `atomic_lib`: the "importing from a peer" flag and the import source are + a tokio task-local scope (`sync::ws_apply::import_scope`) instead of + process-wide statics, so two peer connections importing at once no + longer clear each other's flag or stamp each other's peer id on their + writes (audit C16). The live push loop no longer consults a global mute; + it skips the one peer a change came from, via the `source_id` the scope + stamps on the `DbEvent`, which now also covers `COMMIT` frames applied + for a live peer. `CommitIngestOpts::suppress_live_echo` is gone: a peer + commit is attributed to the connection's import scope instead. + `sync::peer::is_importing()` is now per task; a listener on another + task should read the event's `source_id` (the Flutter binding does). + - `collections::sort_resources` is a total order (missing values last in + both directions, numbers compared numerically with `NaN` in a fixed + place, numbers before strings), so a collection sorted through the + `sort_by` query parameter can no longer panic `sort_by` on Rust 1.81+. + - `sync::peer`: the live peer map recovers from a poisoned lock instead of + unwrapping it, so one panic no longer stops live broadcast for the rest + of the process. +- `atomic_lib`: `DbEvent::Destroyed` for a cascade-deleted child is sent only + after the removal has been applied. `Db::recursive_remove` announced each + child while it was still queueing the deletes into a transaction the caller + had yet to apply, so a listener (`atomic-server`'s `CommitMonitor`, which + fans removals out to WebSocket subscribers; a peer transport) heard of a + deletion that could still fail or roll back, and heard of the children + before their parent. The callers (`remove_resource`, the destroy branch of + `apply_commit`) now announce every removed subject once the transaction has + landed; the destroyed subject itself is still announced exactly once, wrapped + in its signed destroy commit. `remove_resource` now also announces the + subject it was called for, which it never did. Follow-up to #1544. + +- `classify_commit_error` classifies "Commits cannot be edited." (a write whose + subject is itself a Commit) as the new `IMMUTABLE_COMMIT` (10) error code, on + the WS `ERROR` frame and the HTTP `/commit` error body's `errorCode` alike. + It was going out as `UNKNOWN`, leaving clients to match the message text to + know the refusal is terminal. The Rust outbox drops such entries as terminal. +- Query index: a drive-scoped, sorted, class-filtered collection could list + and count fewer rows than the store held, with nothing to show for it + (`planning/silent-failures.md`). Rows whose `isA` read back as a plain + `String` were in the index and then hidden, because the built-in + collection class extender could not parse the value and + `Db::resolve_query_member` dropped any row an extender check errored on; + an extender that cannot decide is now skipped with a warning and the row + is listed. Rows whose `isA` was a `String` holding the JSON array were + never indexed under their class and never matched it; the index keys and + the matcher now read the array's elements from one helper + (`Value::to_reference_index_strings`, `Value::contains_value`). New + `Db::check_query_index(&Query)` compares a query's member index with a + scan of the store and reports the missing and stale subjects; the first + build of a filter cross-checks the equality constraints the planner did + not scan (bounded by its 512-entry scan cap), warns with the filter and + the subjects, and files them. DID resources stamped into another drive no + longer enter a drive's watched query on commit or build: the `Db` resolves + each watched filter's `drive` subject to its drive root and compares + stamps (security audit C17; the filter's identity is unchanged). +- Startup store-size diagnostics and automatic redb compaction. Opening the + store now logs the file's size and open duration (a warning above 1 GiB, + naming `atomic-server compact`) and, from redb's `DatabaseStats`, how much + of the file is live, fragmented and reclaimable (bytes on disk minus pages + in use; redb's sparse growth headroom does not count). When the file is at + least 256 MiB on disk and at least 30% of that is dead, `Db::init_redb_file` + compacts it before the server listens and logs the before/after sizes and + duration; the outcome is kept in the store and readable through + `Db::last_compaction`. A compaction failure is a warning, never a refused + start. New options `--auto-compact` (`ATOMIC_AUTO_COMPACT`, default + `true`), `--auto-compact-min-mb` (`ATOMIC_AUTO_COMPACT_MIN_MB`, `256`) and + `--auto-compact-min-reclaimable-percent` + (`ATOMIC_AUTO_COMPACT_MIN_RECLAIMABLE_PERCENT`, `30`); `atomic_lib` callers + pass a `db::compaction::CompactionPolicy` to + `Db::init_redb_file_with_policy`. Not applied to the OPFS (browser) or sled + backends. See `planning/disk-storage-and-persistence-optimization.md`. + - CI: the `:develop` docker image is published by its own job instead of a step tacked onto the end of the CI job. As a step it inherited whatever the CI step had already spent (a wedged Dagger engine on the runner burned the @@ -30,6 +173,25 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain `.map`). `AppState::init` drops its own core-models bootstrap branch: its "store did not exist" check ran after the store directory had been created, and `Db::init_redb_file` already seeds a fresh store on open. + +- `atomic_lib`: host-to-Drive mappings are reconcilable, so a control plane can + install hosted vanity subdomains without an agent that can sign on the + Drive's behalf. `Db::sync_drive_mappings` adds, repoints and removes a + desired set idempotently and scopes removal to the hosts it installed + itself (so `/bind-drive` bindings and the `localhost` entries from setup + survive); `Db::list_drive_mappings` and `Db::managed_alias_hosts` read the + table, which had no read path beyond a single-host lookup. Mapping keys are + now normalized, so a mixed-case `Host` header resolves the Drive it was + bound to instead of falling through to the store root. +- A host bound to a Drive now serves that Drive or answers 404. It used to + fall through to the store root when the bound Drive was missing — not synced + yet, or moved to another node — which on a multi-tenant server answers one + tenant's hostname with another namespace's content. +- New `--served-domain-suffix` / `ATOMIC_SERVED_DOMAIN_SUFFIX`: answer for + `*.` so the request origin follows the hostname the visitor used, + without `--base-domain`'s other effect of also becoming the store's base + domain (which changes how subjects are normalized and migrated, and is not + something to switch on for a server that already holds data). - The outbox drains over a live Iroh link too (`sync::peer::LivePeerCommitTransport`): a device with no hub in reach delivers its queued writes to a paired peer as signed `COMMIT` frames, which the peer validates and applies like a hub diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 361f2d20b..4c3ae6d63 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -481,3 +481,40 @@ journalctl -u atomic.service --since "1 hour ago" -f 1. `cd cli` 1. run `cargo wasi build --release --no-default-features` (note: this fails, as ring does not compile to WASI [at this moment](https://github.com/briansmith/ring/issues/1043)) 1. `wapm publish` + +## Coordinated Rust updates + +Server and SaaS use the same exact Rust release, selected by each repository's +`rust-toolchain.toml`. CI pins and Dagger's `RUST_VERSION` must match it. The +Server-owned checker validates those copies; do not switch a workflow or Docker +image back to floating `stable`/`rust:bookworm`. + +For an update, create branches with the same name in both repositories. Existing +paired-branch CI resolves both heads to commit SHAs and tests that exact pair. +Update both toolchain files, the workflow pins, and Dagger's version together. +Keep separate committed `Cargo.lock` files. Update selected shared versions with +`cargo update -p NAME@OLD --precise VERSION`, then run from the Server checkout: + +```sh +python3 scripts/check-rust-alignment.py --saas ../atomic-saas +cargo metadata --locked --format-version 1 > /dev/null +(cd ../atomic-saas && cargo metadata --locked --format-version 1 > /dev/null) +``` + +The check compares Loro (including common transitive Loro crates), Iroh, Serde, +JSON, Ed25519/Curve25519, Tokio, Reqwest, and Object Store. It fails on different +resolved version sets, including additional prereleases. Other dependencies may +differ: SaaS's own redb database intentionally still uses major 2 while Server +uses major 4. Add a crate to the policy when its alignment matters; do not copy +whole lockfiles or force unrelated dependencies to match. + +Development profiles also match (`line-tables-only` for local crates, no debug +info for dependencies). Features, targets, native toolchains, and intentionally +different CI profiles can still produce separate cached artifacts. A shared +build cache does not synchronize dependencies. + +Paired Rust checks and SaaS build/release commands use `--locked` so source changes cannot silently +rewrite the tested dependency graph. Commit any needed lockfile updates in the +paired PR, run the affected Rust suites, and merge the pair together after CI. +The SaaS alignment gate requires the Server checker, so land the Server PR +before the SaaS PR when first introducing this policy. diff --git a/README.md b/README.md index de86ffaa5..545762819 100644 --- a/README.md +++ b/README.md @@ -5,52 +5,54 @@ [![MIT licensed](https://img.shields.io/github/license/atomicdata-dev/atomic-server.svg?color=blue&logo=github&logoColor=blue)](./LICENSE) [![github](https://img.shields.io/github/stars/atomicdata-dev/atomic-server?style=social)](https://github.com/atomicdata-dev/atomic-server) -**Create, share, fetch and model [Atomic Data](https://docs.atomicdata.dev)! -AtomicServer is a lightweight, yet powerful CMS / Graph Database. -Demo on [atomicdata.dev](https://atomicdata.dev). +**AtomicServer is an all-in one workspace / CMS / Graph Database. Docs on [docs.atomicdata.dev](https://docs.atomicdata.dev/atomic-data-overview)** -This repo also includes: +This repo includes: -- [Atomic Data Browser](/browser/data-browser/README.md), the React front-end for Atomic-Server. +- **AtomicServer**, our main product, as [self-hostable server](/server) or as [desktop / mobile app](/desktop). +- [`docs`](docs/README.md) documentation / specification for Atomic Data ([docs.atomicdata.dev](https://docs.atomicdata.dev)). +- [Atomic Data Browser](/browser/data-browser/README.md), the React front-end powering Atomic-Server. - [`@tomic/lib`](/browser/lib/README.md) JS NPM library. - [`@tomic/react`](/browser/react/README.md) React NPM library. - [`@tomic/svelte`](/browser/svelte/README.md) Svelte NPM library. - [`atomic_lib`](lib/README.md) Rust library. - [`atomic-cli`](cli/README.md) terminal client. -- [`flutter`](/flutter) a Dart / Flutter client for Atomic Data, plus AtomicCanvas, a collaborative infinite drawing canvas that syncs peer-to-peer between devices. -- [`docs`](docs/README.md) documentation / specification for Atomic Data ([docs.atomicdata.dev](https://docs.atomicdata.dev)). +- [`flutter`](/flutter) a Dart / Flutter client (with demo app AtomicCanvas) _Status: alpha. [Breaking changes](CHANGELOG.md) are expected until 1.0._ ## AtomicServer -- 🏠 **Local-first**: create and edit data with no server at all. Resources are addressed by [`did:ad` identifiers](https://docs.atomicdata.dev/did) and resolve peer-to-peer over the Mainline DHT, so an identity is a keypair you hold rather than an account on someone else's machine. Edits are signed CRDT commits that merge when you reconnect. -- 🔒 **Encrypted at rest, per agent**: each agent's in-browser database is encrypted with XChaCha20-Poly1305, under a key wrapped by that agent's own private key. Signing out leaves the cache in place but unreadable to the next session, so no wipe is required. -- 🔑 **Passkey-backed recovery**: a WebAuthn passkey wraps the backup of your agent secret (Argon2id + AES-GCM), so onboarding hands you nothing to write down, and a lost device doesn't have to mean a lost account. -- 🚀 **Fast** (less than 1ms median response time on my laptop), powered by [actix-web](https://github.com/actix/actix-web) and [redb](https://github.com/cberner/redb) -- 🪶 **One self-contained binary** (~70MB): server, web app, full-text search and database in a single file, with no runtime dependencies and nothing to install alongside it. -- 💻 **Runs everywhere** (linux, windows, mac, arm) -- 🔧 **Custom data models**: create your own classes, properties and schemas using the built-in Ontology Editor. All data is verified and the models are sharable using [Atomic Schema](https://docs.atomicdata.dev/schema/intro.html) -- ⚙️ **Restful API**, with [JSON-AD](https://docs.atomicdata.dev/core/json-ad.html) responses. -- 🔎 **Full-text search** with prefix typeahead and 1-edit fuzzy matching, often <3ms responses. Same KV index on the server and in the browser. -- ✨ **AI** with [MCP](https://modelcontextprotocol.io/) support, use any model via OpenRouter or host your own with Ollama. -- 🗄️ **Tables**, with strict schema validation, keyboard support, copy / paste support. Similar to Airtable. -- 📄 **Documents**, collaborative, rich text, similar to Google Docs / Notion. -- 💬 **Group chat**, performant and flexible message channels with attachments, search and replies. -- 📂 **File management**: Upload, download and preview attachments. -- 💾 **Versioning** / history from the Loro oplog, with writes authorized by [Atomic Commits](https://docs.atomicdata.dev/commits/intro.html) -- 🔄 **Real-time synchronization**: instantly communicates state changes with a client. Build dynamic, collaborative apps using [websockets](https://docs.atomicdata.dev/websockets) (using a [single one-liner in react](https://docs.atomicdata.dev/usecases/react) or [svelte](https://docs.atomicdata.dev/svelte)). -- 🧰 **Many serialization options**: to JSON, [JSON-AD](https://docs.atomicdata.dev/core/json-ad.html), and various Linked Data / RDF formats (RDF/XML, N-Triples / Turtle / JSON-LD). -- 📖 **Pagination, sorting and filtering** queries using [Atomic Collections](https://docs.atomicdata.dev/schema/collections.html). -- 🔐 **Authorization** (read / write permissions) and Hierarchical structures powered by [Atomic Hierarchy](https://docs.atomicdata.dev/hierarchy.html) -- 📲 **Invite and sharing system** with [Atomic Invites](https://docs.atomicdata.dev/invitations.html) -- 🌐 **Embedded server** with support for HTTP / HTTPS / HTTP2.0 (TLS) and Built-in LetsEncrypt handshake. -- 📱 **Runs on mobile**: `atomic_lib` compiles into Flutter apps through [flutter_rust_bridge](https://github.com/fzyzcjy/flutter_rust_bridge), so phones get the same local-first store, signing and peer sync as the browser, not a thin REST wrapper. See [`/flutter`](/flutter). -- 📚 **Libraries**: [Javascript / Typescript](https://www.npmjs.com/package/@tomic/lib), [React](https://www.npmjs.com/package/@tomic/react), [Svelte](https://www.npmjs.com/package/@tomic/svelte), [Rust](https://crates.io/crates/atomic-lib), and a [Dart / Flutter client](/flutter/lib/atomic) - -https://user-images.githubusercontent.com/2183313/139728539-d69b899f-6f9b-44cb-a1b7-bbab68beac0c.mp4 +- 🏠 **Local-first**: works offline in the browser, syncs when you reconnect with [Atomic Sync](https://docs.atomicdata.dev/sync). +- 🔄 **Real-time collaboration**: live cursors, typing indicators, and following what a teammate is doing. +- 📄 **Documents**: collaborative rich text, like Google Docs or Notion. +- 🗄️ **Tables**: strict schema, keyboard navigation, copy / paste. Like Airtable. +- 📋 **Kanban, calendar, dashboard and timer views** on any table. +- 🧰 **Templates**: issue tracker, CRM, project tasks, time tracker and more. +- 🌐 **Websites**: design pages in the browser, publish in one click, roll back any version. +- 🗂️ **Virtual drive**: mount your drive as a folder in Finder or Explorer (desktop app). +- ✨ **AI** with [MCP](https://modelcontextprotocol.io/) support, any model via OpenRouter or local Ollama. +- 🧩 **Apps**: custom screens in plain JavaScript, backed by your own data. +- 🔌 **Plugins and integrations**: Wasm plugins, and syncing from Notion, GitHub and more. +- 💬 **Group chat**: channels with attachments, search and replies. +- 🎥 **Meetings**: video calls with shared notes and presence. +- 🎨 **Canvas**: an infinite drawing surface, shared live. +- 📂 **Files**: upload, download and preview attachments. +- 🔧 **Custom data models**: your own classes and properties in the Ontology Editor, shared as [Atomic Schema](https://docs.atomicdata.dev/schema/intro.html). +- 🔒 **Encrypted at rest**: each agent's local database is encrypted under their own key. +- 💾 **Versioning**: full history, every write a signed [Atomic Commit](https://docs.atomicdata.dev/commits/intro.html). +- 🔎 **Full-text search**: typeahead and fuzzy, often under 3ms, same index on server and client. +- 🔐 **Authorization**: read / write rights, [hierarchies](https://docs.atomicdata.dev/hierarchy.html) and [invite links](https://docs.atomicdata.dev/invitations.html). +- ⚙️ **RESTful API** with [JSON-AD](https://docs.atomicdata.dev/core/json-ad.html), plus RDF, Turtle, N-Triples and JSON-LD. +- 📖 **Pagination, sorting and filtering** with [Atomic Collections](https://docs.atomicdata.dev/schema/collections.html). +- 🚀 **Fast**: under 1ms median response time, powered by actix-web and redb. +- 🪶 **One binary** (~70MB): server, web app, search, database and automatic HTTPS. +- 💻 **Runs everywhere**: linux, windows, mac, arm, plus desktop and mobile apps. +- 📚 **Libraries** for JavaScript, React, Svelte, Rust and Dart / Flutter. + +https://github.com/user-attachments/assets/32e82de5-11ca-4c2e-8c25-b293d79f6023 ## Documentation diff --git a/TESTING_COVERAGE.md b/TESTING_COVERAGE.md index 6cda0d8c7..13b2304e8 100644 --- a/TESTING_COVERAGE.md +++ b/TESTING_COVERAGE.md @@ -1,3 +1,88 @@ +File uploads during tab handoff (2026-09-22): `browser/lib/src/client-db-handoff.test.ts` closes the leader during hashing and blob storage, verifies recovery when the uploader or a third tab takes over, and covers duplicate announcements, non-repeatable mutations, timeout and teardown. A local Chromium harness also exercised these four handoffs with real Web Locks, BroadcastChannel, WASM and OPFS, verifying the blob survives reload. The exact reported staging profile-picture event could not be retrieved from Sentry on this host; a live-but-unresponsive leader without a handoff still uses the bounded timeout. + +Account redirects (2026-09-22): mounted `GettingStartedFlow.test.tsx` and `IdentityReconcileGate.test.tsx` cover hosted local sign-in, settings/passkey continuation, invite/drive priority, missing-data recovery and cancellation of stale identity/hosting checks. See [the route map](browser/data-browser/AUTH_FLOWS.md). Portal session, email-link and dashboard browser checks live in atomic-saas and use HTTP fixtures; real production passkey registration is not covered by these checks. + +New-drive sync: WebSocket unit coverage verifies SUB and SYNC wait for a pending genesis acknowledgement, then resume on ResourceSaved. The Local DB-off rendering E2E exercises this ordering with real server persistence. + +Cover repositioning: `cover-reposition.spec.ts` uploads a real image and verifies multiple pointer movements update its framing before release (native image dragging previously interrupted the gesture). + +Template visibility: `settings-templates.spec.ts` toggles Hide templates through Settings, verifies the loaded New page hides templates across reload, and restores them when unchecked. + +AI settings search: browser coverage checks API matches retain provider credentials but hide model, generative, and voice controls; titles matches show only the title toggle within AI. + +Model option details: settings browser coverage checks input/output prices per million tokens and the OpenRouter added month inside an option, while preserving selection and dropdown width. + +OpenRouter privacy: settings browser coverage filters out models absent from the mocked ZDR endpoint list. The BYOK voice/chat flow asserts provider.zdr is sent on its chat completion; voice audio remains outside this chat-only policy. + +Model dropdown geometry: `ai-settings.spec.ts` checks that the open list matches its input width (regression: viewport-wide popover). + +Speech settings: browser coverage selects a transcription model, persists the voice toggle across reload, hides the mic when disabled, and verifies the selected model in the personal-key audio request. The managed-credit model remains service-controlled. + +AI settings: `ai-settings.spec.ts` exercises navigation from the chat agent menu, +provider controls and default model selection, agent/skill/MCP creation and reload +persistence, and settings search. Provider/MCP APIs are mocked. Agent radios expose +saved selection; voice BYOK regression still passes after the menu refactor. + +Voice feedback: unit checks cover audio-level bounds and local-recognition cancellation; the personal-key Chromium flow checks mic scaling with simulated volume and interim word rendering. Real on-device transcription requires browser support and an installed language pack. + +Voice with personal OpenRouter key: `ai-voice-byok.spec.ts` verifies the mic remains usable, direct audio requests carry the configured key, and no SaaS voice endpoint is called. Media and model responses are mocked. + +Voice chat: `voiceTurn.test.ts` checks PCM WAV serialization and cancellation +without retries. `ai-live.spec.ts` runs the actual chat controls with mocked media +and OpenRouter responses: record, transcribe, hosted AI reply and speech playback, +without a personal API key. SaaS `ai::voice` validates input bounds and model pinning; +shared AI tests cover credit reservations and settlement. Real microphone/provider +quality remains unverified without the SaaS OpenRouter key. The earlier GPT-Live +lifecycle tests remain for its retained, separate backend implementation. + +Plugin configuration: hook tests retain a release's validation schema when a save +receipt omits computed metadata, and clear it when the release or installation +changes. The plugin-install E2E checks invalid config after saving valid config. + +Editor sync formatting: unit tests cover both enabling and disabling bold before +an incoming property update, so sync receipts cannot reset the next typed text's +formatting. The production-bundle typing E2E exercises the keyboard shortcut. + +Sidebar layout: browser checks sample both docked sidebar transitions halfway +through opening/closing and verify that the main content moves with them, with +matching duration/easing. They also cover hover reveal, mobile backdrop dismissal, +and keeping the main content aligned while resizing and after reopening. +Section resizing: hook tests cover touch pointers, drag thresholds, size bounds, +tap preservation, cancellation, secondary pointers and unmount cleanup. Chromium +uses native touch gestures on the AI Chats header to shrink/grow the list, checks +the 44px touch target, saved height after reload, collapse/expand and New Chat. + +Creation catalog/context menus: browser checks cover the embedded sidebar filter, +keyboard filtering, removal of plugin/website/app creation actions from menus, +discovery of their blank starters on a fresh drive, and file/upload searches. +Existing app, plugin, and website browser flows create through the catalog, +including a website seeded from its selected parent document. + +Mobile AI chat navigation: Chromium covers opening the left sidebar above chat, +Back dismissal without leaving the page, the AI settings link, an empty composer +without vertical overflow, and messages without a redundant sender row. History +unit tests cover StrictMode, explicit close, and navigation to another page. +Resource links dismiss mobile chat even for the already-open resource; Chromium +covers current/different targets, retained conversation and desktop staying open. +Link unit tests check dismissal waits for navigation; history tests protect +destinations when navigation inherits the chat marker. + +Included AI: managed transport tests cover signed-out status, explicit consent, +backend errors, streaming credit failure and non-streaming title generation without +forwarding a provider key or SDK User-Agent header (Firefox/Zen CORS regression). +Assistant rendering tests retain historical errors and partial replies while +suppressing the duplicate current error when the composer displays it. +Setup component tests cover consent failure/retry and +successful dismissal. atomic-saas owns account isolation, budget concurrency, +month rollover, paid-drive aggregation, origin/auth checks and disconnected-client +accounting tests. These tests do not call the live funded OpenRouter service. + +AI setup recovery: component tests reproduce dismissed setup reopening on repeated +requests, prevent login-button mounts from overwriting an in-flight OpenRouter +verifier, verify the clicked link's PKCE challenge and verifier length, and check +visible feedback with navigation cancelled when browser storage is blocked. +Real OpenRouter consent and paid model requests are not exercised by these tests. + Website exports open in a dedicated frozen preview. Browser coverage verifies the export resource shows original content after source edits and reload, with scripts disabled and no publication action. @@ -239,6 +324,10 @@ imports do not wait on local indexing or WebSocket readiness. `cargo test -p atomic-server --test build_assets` exercises content/settings cache separation, corrupted Brotli recovery and concurrent atomic publication. +`cargo test -p atomic-server --test build_plugin_runtime --features wasm-plugins` +builds a tiny release workspace using the production runtime build script. It +checks that nested Cargo completes while the parent holds its release lock and +that the server embeds a real WASI component, including with a custom target dir. The context-menu E2E flow catches title blur stealing focus from the menu; Enter retains its explicit handoff into page content. @@ -492,6 +581,7 @@ Two things worth knowing about the runners: | RBSR reconciliation, drive hashing | `lib/src/sync/rbsr.rs`, `tests.rs` | | RBSR finds a remote-only subject sorting below every local one | `lib/src/sync/rbsr.rs` **and** `browser/lib/src/rbsr.test.ts` (regression, see below) | | Remote update merge, drive-spoof rejection, tombstones | `lib/src/sync/ws_apply.rs`, `tombstones.rs` | +| `DbEvent::Destroyed` for a removed resource and its cascade-deleted children arrives only after the removal is applied (the store no longer holds them when a listener hears), each subject announced exactly once | `lib/src/db/test.rs` (`destroyed_events_follow_the_applied_removal`) | | Pairing envelope encode/decode | `browser/lib/src/pairing.test.ts` | ### Cross-process — covered since 2026-07 @@ -552,6 +642,7 @@ Not covered: table `contains`; Playwright search overlay on the KV path and asse | Offline edits persist and sync on reconnect | `sync.spec.ts` | | Second device cold-loads a drive from the server | `second-device-load.spec.ts` | | Property reads stay pending through loading-placeholder notifications until hydration completes | `browser/lib/src/store.test.ts` | +| Cold-load local hydration: all `useResource` misses of one tick share one worker round trip, a duplicate subject is asked once, a miss during a flush lands in the next batch, a failed bulk read is a per-subject miss, batches chunk at 200 | `browser/lib/src/store.read-policy.test.ts` | --- @@ -765,8 +856,9 @@ Not covered: derived AI tools invoked through a real model; MCP protocol project |---|---|---| | Hashed `view-transition-name` plus `view-transition-class` per tag | glue | `browser/data-browser/src/helpers/viewTransition.test.ts` | | `startViewTransition` throw / hung `finished` / rejected `ready` still navigates and skips the overlay | glue | `browser/data-browser/src/helpers/viewTransition.test.ts` | +| Navigation skips `startViewTransition` unless the user opts in, and uses it once they do | glue | `browser/data-browser/src/hooks/useNavigateWithTransition.test.tsx` | -Not covered: visual morph of a grid card into the resource page in Firefox (needs a headed Firefox run; Playwright's firefox project is locks-only and automation bypasses view transitions unless `forceViewTransitions` is set). +Not covered: visual morph of a grid card into the resource page in Firefox (needs a headed Firefox run; Playwright's firefox project is locks-only and automation bypasses view transitions unless `forceViewTransitions` is set). Android Chrome is not covered at all, which is why transitions are off by default ([#1563](https://github.com/ontola/atomic-server/issues/1563)): re-enabling by default needs a per-browser check first. ## Documents @@ -784,6 +876,7 @@ No automated end-to-end coverage: uploaded-file conversion through the full UI a |---|---|---| | `LoroDoc` values are not KV-index keys | protocol | `lib/src/values.rs::loro_doc_is_not_indexed` | | Content commits are not stored; genesis/ACL/destroy are | protocol | `lib/src/db/test.rs::content_commits_are_not_stored` | +| Signed destroy removes the resource, keeps its envelope and tombstones the subject in one apply | protocol | `lib/src/db/test.rs::destroy_commit_removes_resource_and_keeps_envelope_atomically` | | Sequential saves do not chain `previousCommit`; commit DIDs are not store resources | glue | `browser/lib/src/commit.test.ts` | ## Personal drive identity @@ -794,13 +887,13 @@ No automated end-to-end coverage: uploaded-file conversion through the full UI a | Cross-language personal-drive vector | `genesis.rs` + `genesis.test.ts` | | Repeat genesis for that DID merges Loro state | `lib/src/commit.rs::repeat_personal_drive_genesis_merges` | | Repeat genesis without a cert is still rejected | `lib/src/commit.rs::repeat_genesis_without_cert_is_still_rejected` | -| `createDrive({ personal: true })` uses the derived DID | `browser/lib/src/store.personal-drive.test.ts` | -| Two stores with the same key mint the same subject | `store.personal-drive.test.ts` | -| Extra drives are listed on the derived personal drive | `store.personal-drive.test.ts` | +| `createDrive({ personal: true })` uses the derived DID | `browser/lib/src/store.private-drive.test.ts` | +| Two stores with the same key mint the same subject | `store.private-drive.test.ts` | +| Extra drives are listed on the derived personal drive | `store.private-drive.test.ts` | | Extra drive created offline drains on reconnect (genesis must not set a rewind baseline) | `browser/lib/src/offline-create-drain.test.ts` | | Idempotent offline saves clear only after a complete local snapshot matches the synced baseline | `browser/lib/src/offline-create-drain.test.ts`, `browser/e2e/tests/offline-create-then-online.spec.ts` | -| Lists from a previous random-DID home are unioned onto the derived drive | `store.personal-drive.test.ts` | -| `Agent.personalDriveSubject` matches the genesis helper | `agent.test.ts` | +| Lists from a previous random-DID home are unioned onto the derived drive | `store.private-drive.test.ts` | +| `Agent.privateDriveSubject` matches the genesis helper | `agent.test.ts` | | `Db::setup` / `ensure_personal_drive` use the derived DID and are idempotent | `lib/src/db.rs::personal_drive_tests` | | Extra `Db::create_drive` is listed on the personal drive | `lib/src/db.rs::personal_drive_tests` | @@ -845,6 +938,38 @@ Cloud Vault display metadata: `vaultAutoBackup.test.ts` verifies name/emoji enro authenticated read from the real managed node. Plan purchase alone creates no enrollment. Real Stripe-hosted test-card checkout remains a deployment check. +## Host-to-Drive routing and hosted vanity subdomains + +`Tree::DriveMapping` is what makes one server answer for many hostnames. It +backs `/bind-drive` for self-hosters and hosted vanity subdomains for +`atomic-saas`, whose control plane reconciles it through +`Db::sync_drive_mappings`. + +- `db::drive_mapping_tests`: the reconcile a managed node runs on every policy + poll — add, repoint, remove; idempotent on an unchanged list; scoped so a + binding it did not install (including the `localhost` / `127.0.0.1` entries + from `setup_test_env`, and anything bound by hand through `/bind-drive`) is + never removed; keys normalized so a mixed-case `Host` still resolves; empty + hosts and empty drives skipped. +- `db::resolver_tests::a_bound_host_whose_drive_is_missing_does_not_serve_the_store_root`: + the multi-tenant leak. A host bound to a Drive this node does not hold (not + synced yet, or migrated away) must 404 rather than fall through to the store + root, which would answer one tenant's hostname with another namespace's + content. This is the property that lets the control plane authorize a + certificate on reservation instead of only after a node confirms. +- `context::tests::a_served_domain_suffix_accepts_tenants_without_a_base_domain`: + `--served-domain-suffix` makes the request origin follow the hostname the + visitor used, without turning on `--base-domain` and with it the store's + subject normalization. +- Paired `atomic-saas` coverage (registry, plan gating, `/caddy-ask`, the + heartbeat report) is listed in that repo's + `planning/TEST_COVERAGE_AND_CI.md`. + +**Not covered:** no test drives a real HTTP request against a vanity host +end to end — the reconcile and the resolver are tested separately, and joining +them needs the representative two-service environment. The multi-node gateway +routing that a second node would require does not exist yet. + ## Error reporting and feedback - `browser/data-browser/src/helpers/feedback.test.ts`: unavailable reporting, failed delivery, blank input and successful submission. @@ -888,6 +1013,19 @@ mounts without resetting or re-registering the global parser. drops), backoff, blocked entries and cancellation cannot report persistence. It also covers offline transport failures, successful retries, unrelated subjects and edits arriving during an acknowledged save (#1388). +- `destroy-via-outbox.test.ts` exercises `Resource.destroy()` through the same + outbox: an online delete POSTs one destroy commit and removes the resource; a + delete while disconnected queues the pre-signed envelope, survives a simulated + reload (fresh `LocalOutbox` hydrating the same agent namespace) and is POSTed + exactly once on reconnect; create + delete while offline POSTs neither + envelope; a never-saved `newResource` is dropped without a POST; a server + refusal rejects `destroy()` and keeps the entry queued; a transport failure + resolves as queued and flips the store offline; "already gone" server answers + (`already applied here`, `predates the resource's genesis`, `does not exist + yet`) count as acknowledged; a pending destroy blocks resurrection through + `applyIncoming` / `hydrateResourceFromJsonAd` and is excluded from + `computeDriveSyncState`. Not covered: a real server round trip for the + reconnect drain (no `*.integration.test.ts` or Playwright variant yet). - `scripts/owned-process.node.mjs` exercises the template runner process lifecycle, including independent ephemeral ports and descendant cleanup. The superseded @@ -912,6 +1050,18 @@ mounts without resetting or re-registering the global parser. - `client-db.worker.test.ts` requires vault cursor commits to flush before the worker acknowledges backup completion, and propagates flush failures. The SaaS `vault-refresh.spec.ts` checks stored objects and bytes across reloads. +- `db::compaction::tests::startup_compaction_shrinks_a_bloated_store_and_keeps_every_resource` + (`cargo test -p atomic_lib --features db-redb --lib`) churns a real redb + file through `Db::init_redb_file_with_policy` — overwrites that double in + size plus throwaway resources deleted mid-file, so the buddy allocator + cannot reuse the holes — and reopens it: the policy compacts, the file + gives back most of the measured free space, every kept resource reads its + last value, the record survives the next open, and a disabled policy leaves + the file byte-for-byte alone. Overwrites *alone* leave only ~20% dead + (freed blocks coalesce and get reused), which is why the test deletes. + `server::config::tests` cover the `--auto-compact*` flags. Not covered: + compaction of a store another process holds open (the open itself fails + first, as before), and the cost of `DatabaseStats` on a multi-GB file. - `synthetic_agent_reads_have_stable_history_without_persisting` checks that fallback agent lookups neither invent creation timestamps nor generate new CRDT history or persist a resource merely by reading it. @@ -1350,7 +1500,12 @@ network transport, OS-process isolation or reviewed alias/reference repair. - Connection-state test verifies alias provenance, preserved baseline, incremented revision, idempotent reads and rejection of the earlier checkpoint revision. - `drain-datatype-tags.test.ts` reproduces and fixes newly added JSON values becoming - strings on incremental saves. The full client suite has 564 passing tests. + strings on incremental saves. It also drives the public `newResource → set → save` + flow through the real outbox drain and replays the posted `loroUpdate`s: the signed + incremental commit carries `json`/`resourceArray` tags for properties first set + after genesis, and the tag write runs after the user's ops are sealed, so the edit + keeps its own commit origin and stays on the undo stack. The full client suite has + 564 passing tests. - Five Chromium flows pass against rebuilt native/WASM code. Duplicate review uses real authenticated SYNC_PUSH plus a signed primary decision and fresh lookup; the other flows cover setup recovery, MT940 and Clockify. It does not yet test @@ -1509,6 +1664,15 @@ setup currently fails opening OPFS before it can create its dev drive. structured `SYNC_REJECTED` classification are covered. - `store-commit-fallback.test.ts`: a WebSocket enrollment refusal is not duplicated over HTTP; a transport failure still falls back. +- `local-outbox.test.ts` ("classification is code-first") and + `save-acknowledgement.test.ts` ("terminal drops are classified by error + code"): a recognized `AtomicError.code` (`GENESIS_COLLISION`, + `IMMUTABLE_COMMIT`, ...) decides terminal/benign/blocking regardless of + message wording, including one parsed off an HTTP `/commit` JSON-AD error + body's `errorCode`; a code-less legacy message still classifies; another + recognized code wins over a legacy phrase in the message. Rust: + `protocol::classify_commit_error_matches_known_patterns` covers + `IMMUTABLE_COMMIT`. - Server `errors::admission_error_tests`: enrollment/quota refusals carry a blocking code and HTTP 403 rather than an internal-error response. - Server `tests::content_addressed_image_download`: raw, WebP and AVIF downloads @@ -1687,6 +1851,14 @@ cannot resolve early and needs no second RPC during identity handoff. coalesces DOM writes outside ResizeObserver delivery, and cancels pending work on unmount. Table filtering E2E retains strict browser diagnostics. +## CI server hostname mapping + +`browser/e2e/scripts/server-dns.node.mjs` starts a real HTTP server and a Node +child with the CI DNS preload. It verifies callback-based fetch and promise-based +DNS lookup reach the service while preserving the public HTTP Host, and that +unrelated hosts remain unchanged. The template and plugin integration E2E tests +use the public server URL for generated configuration and signed requests. + ## Unified templates and create-drive setup `chunks/Templates/model.test.ts` tests version-pinned composition, duplicate keys, @@ -1749,6 +1921,8 @@ deep packaged ancestry, bounded app writes, cycles and unavailable ancestors. `viewSession.test.ts` checks canonical resource/error replies. The actual packaged and generated SDK clients share conformance tests in `browser/plugin/src/viewProtocol.test.ts`, including ignoring foreign-window replies. +The generated client also accepts a reply after the host's 30-second recovery +window, clears its deadline on completion, and rejects a host that stays silent. The packaged adapter additionally tests canonical requests, caller-supplied policy spoofing, subscription acknowledgements and unsupported operations. @@ -2007,6 +2181,27 @@ on Linux x86_64, including a cached install followed by changed downstream source input and execution of the retained binary. Its aarch64 archive digest is pinned to the upstream release; native aarch64 execution is not covered by that check. Full CI wall-time savings require a completed hosted run. +## Query index consistency (2026-09-18) + +`db::test::is_a_encodings_all_match_the_class_constraint` (formerly +`#[ignore]`d as an open bug) writes four rows whose `isA` names one class in +four encodings and asserts a drive-scoped, sorted, class-filtered query lists +all of them and that `Db::check_query_index` finds index and store in +agreement. `replicated_rows_reach_a_watched_scoped_sorted_query` watches that +query shape with 5 rows and then replicates 17 more through +`persist_replicated_resource` (the sync import path, propvals materialized +from a Loro doc), asserting the sorted, unsorted and differently scoped shapes +all answer 22. `first_build_cross_checks_the_unscanned_constraint` removes one +row's `isA` entry from `PropValSub` and asserts the first build still files +the row through the `parent` constraint. +`check_query_index_names_missing_and_stale_members` corrupts a member index in +both directions and asserts the report names each subject. +`did_rows_stamped_into_another_drive_stay_out_of_a_watched_query` covers the +audit's C17 on both the build and the commit path, including the unstamped +row that is deliberately not excluded. Not covered: the runtime `warn!` text +itself, and a UI-level comparison of a client's local answer with the +server's (see `planning/silent-failures.md`). + ## External cache access and authentication origins (#170) Paired SaaS `portal/e2e/recovery-passkey.spec.ts` uses Chromium virtual PRF authenticators with the real control plane to verify app enrollment followed by portal login using one credential, reuse of a portal-created credential, and account-settings migration without replacing ciphertext or old wrappers. Physical Safari/iCloud, Android/password-manager and native-shell behavior remain device acceptance checks. @@ -2151,3 +2346,99 @@ and upload hook, then delivers multiple files through the drop callback. It verifies the upload targets the displayed drive even when the current drive setting differs. Native drag events, overlay geometry and the refreshed child list are not covered by this component test. + +## Private-drive sign-in availability regressions (2026-09-22) + +Required outcome: a valid agent secret can open a writable private drive at +its deterministic DID even when no prior content can be recovered. Creating +that root must not be presented as successful recovery of previous content. + +`browser/e2e/tests/sign-in-without-data.spec.ts` now requires: + +- A fresh account with no recoverable data opens the exact derived home, + reads it as a Drive, creates a document, and retains its title after reload + (`@smoke`). This subsumes the old "not another workspace" assertion. +- An unavailable legacy home does not prevent that same writable-home outcome. +- A persisted identity with no home can initialize it on a direct link. The + fixture seeds only the supported IndexedDB fallback identity record, so it + does not depend on sign-in first creating the drive. +- An unrelated missing drive stays unreadable; Sync does not claim it is + cached/offline-ready or known to exist on another device. + +The old recovery-roadblock expectation and localStorage-DID-only "place to +write" assertions were removed. The label-only "sync page shows correct +status" test was removed; `sync-devices.spec.ts` retains device rendering, +provider isolation and pairing coverage. + +`helpers/syncPresentation.test.ts` rejects an inferred remote copy in the +missing-drive summary. `helpers/driveData.test.ts` covers read failures and +refresh after a cached miss, alongside local/server refresh dispatch. These +boolean-helper tests do not establish why a read failed or where copies exist. +`private-drive-idempotence.test.ts` requires exactly one own-drive list entry +(previously zero passed); the duplicate same-subject test was removed because +`store.private-drive.test.ts` already checks repeated creation and identity. + +These are regression specifications, not a claim that the implementation is +fixed. Validation results are recorded below. Existing genesis, migration, +sign-out/content preservation and successful Vault restoration tests remain. + +Still missing: late failed reads invalidating a newly initialized home; +reconciliation preserving both old content and new fallback work; integrated +sign-in variants for empty Vault, failed restore, read timeout, offline nodes +and blocked local storage. Vault helper tests cover several return values, +but do not prove sign-in's next action. The real Vault E2E skips without its +control plane. Same-subject library tests are not persistence evidence, and +a second browser using the same populated server is not an unavailable-data +scenario. + +Validation for this coverage change: 14 library tests passed; 14 presentation/ +availability tests passed and the new missing-drive-summary assertion failed +on the unsupported "device that has it" claim. All four Chromium regressions +failed against the current app: both sign-in cases stayed at recovery, the +persisted-session home remained unreadable, and Sync displayed both false +claims. Document creation/reload assertions are downstream of these failures +and are not yet validated by this run. The smoke listing includes the new +no-data sign-in acceptance test. Focused lint/format checks passed. App and +E2E typechecks report errors in unchanged files (including RTE CommandsExtension, +AI, plugin, right-panel and website tests), not the edited coverage files. + +## Rust build alignment + +`scripts/test_rust_alignment.py` tests matching pairs, compiler/workflow pin drift, +development profile drift, transitive Loro versions, missing shared crates, extra +cryptography prereleases, and allowed unrelated dependency differences. Run +`python3 -m unittest discover -s scripts -p test_rust_alignment.py -v`. +The Rust build policy workflow runs these checks; downstream CI checks both +repositories and rejects dependency lockfile drift before builds. + +## Mobile AI chat (#1591) + +`browser/e2e/tests/ai-mobile.spec.ts` checks full-width phone layout and message bodies, long titles keeping the header menu on-screen, the chat resource menu targeting the saved conversation and opening its full-page view, a composer that fits above a simulated keyboard inset, options and token visibility, closing the panel, desktop composer bounds, and model selection with focus returning to the editor. A long-response regression reproduces the final sentence being clipped after keyboard resize, verifies bottom-following and the small gap above the composer, and preserves reading position when scrolled up. AI responses are mocked; a physical mobile keyboard is not exercised. + +AI credit display: `helpers/managed/ai.test.ts` verifies usage notification when the SDK cancels a hosted stream; `components/AI/useHostedAI.test.tsx` verifies the immediate refresh and one delayed settlement refresh without ongoing polling. `HostedAICredits.test.tsx` covers fractional monthly and purchased balances. `ai-mobile.spec.ts` verifies the balance stays hidden until AI Chat options opens, refreshes from the account API, and links to the configured portal. These use mocked account/provider responses and do not verify live billing. + +Recovery read fan-out: `recovery-fetch.test.ts` verifies concurrent reads share +one in-flight request per API/account, settled responses are not cached, failures +can be retried, and signed-out callers make no request. The SaaS legacy recovery +upgrade journey passes with the production per-account request limit. + + +## AI chat folder identity and discovery + +`agent.test.ts` covers independent devices deriving the same valid folder certificate, separation by drive/account, and refusal to derive an identity using a nondeterministic signer. `agentStorage.test.ts` checks stable folder IDs survive non-extractable key storage and subsequent keypair updates. `standardLocations.test.ts` covers concurrent calls across stores, reuse without resetting folder metadata, legacy sessions, and refusal to initialize over transport failures or known deletion. + +`ai-chat-discovery.spec.ts` checks that the visible sidebar includes chats from duplicate folders and the drive root before and after reload, excludes other drives and non-chat resources, and that two separately signed-in browser contexts create chats using the same folder ID. AI responses are mocked. Physical Safari and an offline two-device reconnect are not covered. + +## Compact presence and retry pressure (2026-09-22) + +`NavBarButton.test.tsx` reproduces the compact navbar hiding span-based presence +triggers and verifies only action labels disappear. `presence-follow.spec.ts` +uses two tabs sharing one stored test identity, checks the avatar at 320px, +opens Follow and verifies subsequent navigation. The updated Chromium test +passed against the local app; cross-network staging presence was not certified. + +`recovery-fetch.test.ts` verifies 429 cooldowns (Retry-After seconds and a +60-second fallback), retry after expiry, in-flight sharing and fresh successful +reads. `browser-peer-sync.test.ts` verifies increasing per-peer retry delays and +that repeated discovery notifications cannot bypass them. These mitigate retry +pressure; they do not prove the cause of the reported staging slowdown. diff --git a/brand/README.md b/brand/README.md index 4cf2b8864..7c98f9893 100644 --- a/brand/README.md +++ b/brand/README.md @@ -197,3 +197,18 @@ Two consequences worth knowing: `transform-box`, and the explicit chain has one meaning in every engine. Placement stays an SVG `transform` attribute, copied from `logo.svg`, so a stylesheet failure still leaves a correct static lockup. + +## Atomic Place web identity — September 2026 + +`src/place-mark.svg` and `src/place-mark-mono.svg` supply the centred-orb +icon for the data-browser web app, SaaS portal and marketing site. Native +app and specification icons retain their existing sources for now. Regenerate +only the web surfaces with: + +```sh +node brand/generate.mjs --target=browser/data-browser/public/app_data/images --target=portal/public --target=site/src/app +``` + +The app wordmark in `Logo.tsx` and the boot splash spell `atomic.place` with +a normal o and gradient full stop. Existing developer identifiers and hosting +origins remain unchanged in this visual rollout. diff --git a/brand/generate.mjs b/brand/generate.mjs index 9177634bc..b7276d40a 100644 --- a/brand/generate.mjs +++ b/brand/generate.mjs @@ -43,6 +43,8 @@ const DEV_ROOT = path.resolve(SERVER_ROOT, '..'); const SAAS_ROOT = path.join(DEV_ROOT, 'atomic-saas'); const MARKS = { + place: path.join(BRAND_DIR, 'src', 'place-mark.svg'), + placeMono: path.join(BRAND_DIR, 'src', 'place-mark-mono.svg'), atomic: path.join(BRAND_DIR, 'src', 'atomic-mark.svg'), atomicMono: path.join(BRAND_DIR, 'src', 'atomic-mark-mono.svg'), canvas: path.join(BRAND_DIR, 'src', 'canvas-mark.svg'), @@ -147,7 +149,7 @@ const png = (to, size, variant = 'alpha') => ({ kind: 'png', to, size, variant } const TARGETS = [ { - mark: 'atomic', + mark: 'place', root: SERVER_ROOT, label: 'atomic-server: data-browser web app', dir: 'browser/data-browser/public/app_data/images', @@ -170,7 +172,7 @@ const TARGETS = [ png('mstile-310x150.png', [558, 270]), { kind: 'ico', to: 'favicon.ico' }, // Safari flattens pinned-tab icons to one ink — needs the mono lockup. - { kind: 'svg', to: 'mask-icon.svg', mark: 'atomicMono' }, + { kind: 'svg', to: 'mask-icon.svg', mark: 'placeMono' }, ], }, { @@ -325,7 +327,7 @@ const TARGETS = [ /* Sibling repos — skipped when the checkout is not present. */ { - mark: 'atomic', + mark: 'place', root: SAAS_ROOT, label: 'atomic-saas: portal', dir: 'portal/public', @@ -337,7 +339,7 @@ const TARGETS = [ ], }, { - mark: 'atomic', + mark: 'place', root: SAAS_ROOT, label: 'atomic-saas: marketing site', // Next.js App Router picks these up by filename convention — no tags. @@ -376,8 +378,16 @@ function build(markPath, file, outPath) { } } +// Optional repeatable --target= limits regeneration to a surface. +const selectedDirs = process.argv.slice(2).map(arg => { + if (!arg.startsWith('--target=')) throw new Error(`Unknown argument: ${arg}`); + const dir = arg.slice('--target='.length); + if (!TARGETS.some(target => target.dir === dir)) throw new Error(`Unknown target: ${dir}`); + return dir; +}); try { for (const target of TARGETS) { + if (selectedDirs.length && !selectedDirs.includes(target.dir)) continue; if (!existsSync(target.root)) { console.warn(` skip ${target.label} — no checkout at ${target.root}`); skipped += target.files.length; diff --git a/brand/src/place-mark-mono.svg b/brand/src/place-mark-mono.svg new file mode 100644 index 000000000..b40f68f60 --- /dev/null +++ b/brand/src/place-mark-mono.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/brand/src/place-mark.svg b/brand/src/place-mark.svg new file mode 100644 index 000000000..1a2ca9c44 --- /dev/null +++ b/brand/src/place-mark.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/browser/CHANGELOG.md b/browser/CHANGELOG.md index 5e2c3de2f..31d1745bd 100644 --- a/browser/CHANGELOG.md +++ b/browser/CHANGELOG.md @@ -4,8 +4,91 @@ This changelog covers all five packages, as they are (for now) updated as a whol ## UNRELEASED +- Fix: the integration proxy may live on a `.localhost` name. `proxyOrigin` + allowed plain http only for the bare `localhost` and `127.0.0.1`, so a proxy + at, say, `http://atomic.localhost:19090` was rejected, and because the value + is read during render that rejection replaced any page showing integrations, + the settings page included, with "Error loading resource". RFC 6761 gives the + whole `.localhost` TLD to loopback and browsers treat those names as secure + origins, so they are accepted now, `[::1]` with them. + +- Improve AI chat on phones: use the full screen width, keep the composer above the keyboard and the final response line visible as it opens, remove the bottom spacer, reduce padding, use the full message width, add the chat resource menu to its header, and move model selection and token usage into Chat options. Remove generated follow-up suggestions and rename Atomic Assistant to AI chat ([#1591](https://github.com/ontola/atomic-server/issues/1591)). + +- Fix: someone joining a drive through a browser invitation is told when the + pairing is not getting anywhere. The page showed "Connecting…" and "Waiting + for a peer" indefinitely: `WebRtcPeer`'s 60 second pairing timeout only + exists on a peer that has built an `RTCPeerConnection`, and the guest is the + one waiting for an offer, so it had no timer at all. After 60 seconds without + a peer the page now says so and points at what the inviter has to do. The + attempt keeps running, so a slow pairing that later succeeds still does. +- Fix: the editor's slash menu no longer reaches through an unmounted renderer. + `onStart` positions the menu again on the next animation frame, which can + land after the suggestion was destroyed. + +- Fix: someone who opens a chatroom shared from another drive sees the messages + in it. The message list is a collection query, and a collection defaults its + drive scope to the viewer's active drive. A guest arriving through an invite + has their own drive selected, so the query went looking on the wrong drive and + answered with nothing, leaving "No messages yet" on a thread that had them. + The query now scopes to the drive the thread itself is stamped with, which + for a shared thread is the owner's. The same hook backs the comments panel + and the meeting chat, so those are fixed with it. Scoping to the thread's + subject instead, as this first did, fixed the guest's first read but broke + every later one: the local index is keyed by drive, a subject is not a key + in it, and the panel then stopped showing messages other people sent while + it was open. +- Fix: installing a plugin works again. Since the `Installation` class started + requiring `release`, the server refused the commit that creates one with + "Property .../properties/release missing", the outbox dropped it as terminal + and nothing was installed; both the integration store and a zip upload go + through `installRelease`, so neither worked. `store.newResource` signs the + genesis commit from the propvals it is handed and holds it until `save()`, + so a property set between those two calls is missing from the commit the + server validates. `release` is now one of the propvals. + +- Fix: opening an AI chat no longer risks taking the page to its error + boundary. `useEditor` replaces the tiptap editor when its dependencies change + and destroys the old one, which nulls its `commandManager` while its last + state stays readable, so `isEmpty` still answers and `commands` throws + ("Cannot read properties of null (reading 'commands')"). A prefill arriving + in that same breath is what "New automation" and "AI edit" do. Both effects + now check `isDestroyed`, and a prefill that is skipped is re-applied to the + editor that replaces it. + +- Fix: the authentication cookie is refreshed before the proof inside it + expires. `setCookieAuthentication` signed a proof once and stored it for a + day, and `checkAuthenticationCookie` only asked whether a cookie existed, so + a browser went on presenting the same proof for as long as the tab stayed + open. Since the server started refusing a proof older than five minutes, that + meant cookie-authenticated requests failed five minutes into every session, + with nothing re-signing. The cookie now lives no longer than the proof it + carries (`AUTH_PROOF_MAX_AGE_MS`), and the freshness check reads the signed + timestamp out of the cookie and reports an ageing proof as absent + (`AUTH_PROOF_REFRESH_MS`), which is what makes the request path install a + fresh one. + +- The data-browser no longer reports to Sentry from a dev server. Vite's hot + reload legitimately throws while swapping modules ("_s is not a function", + "Cannot access X before initialization", all with `@react-refresh` frames), + which is not a defect in anything shipped, and those arrived rated above + every real bug in the backlog. `initSentry` returns early when the resolved + environment is `development`; setting `VITE_SENTRY_ENVIRONMENT` still reports + from a local build on purpose. + +- Perf: creating a plugin on a drive that has no plugin schema yet no longer waits for nineteen round trips. `ensureSchema` writes the sixteen properties and three classes of `pluginSchema()` with one save each, and `ensureAll` awaited them one after another, which is most of the time between clicking "New plugin" and the page appearing, and enough to time the e2e suite out. The terms are independent resources under the same ontology and none reads another's subject, so the creates now go out together; the ontology's own list is still assembled in spec order. +- Fix: deleting a resource no longer leaves a "Resource with error" row in the sidebar. A `parent=` query keeps answering with a destroyed child for a moment (the answer was computed before the destroy landed, and `Collection.fetchPage` races the local index against the server's `/query`), and every reader that had not itself witnessed the delete put the row back — which is not cosmetic, because rendering the row asks the store for the resource and re-creates the entry the destroy removed. "This subject is destroyed" is now one fact on the `Store` (`isDestroyed` / `clearDestroyed`, the in-memory half of the tombstone `removeResource` already wrote to the local database) instead of a suppression set per reader: `Collection._removedSubjects` and `useChildren`'s `removedRef` are gone, and both read the store. A destroyed subject is never a member of a collection, incoming state for one is refused after the server ack as well as before it, and `getResourceLoading` answers for one from the tombstone instead of firing a request that can only 404. Only creating a resource again under the same subject lifts a tombstone; a stale answer no longer can. +- Toasts no longer cover the navbar's buttons when the navbar is at the bottom: the toast container is lifted by the navbar's height, so the sidebar toggle, search and context menu stay tappable while a toast is up. The sidebar's 3.8rem `OverlapSpacer`, beneath the App panel, is gone: it dated from the floating-navbar mode and guarded an overlap that cannot happen, since the sidebar's height already excludes the navbar ([#1565](https://github.com/ontola/atomic-server/issues/1565)). +- The navbar sits at the bottom by default on phones and tablets, so the sidebar toggle, the search button and the context menu stay within thumb reach. The signal is a touch-primary pointer rather than viewport width, so a landscape tablet also gets the bottom bar and a narrow desktop window does not. Desktop keeps the top bar, and a position picked in Settings is untouched ([#1565](https://github.com/ontola/atomic-server/issues/1565)). +- Fix: a local database that cannot be decrypted is no longer deleted on sight. `openClientDb` discards and recreates an undecryptable OPFS file only when the caller passes the new `discardUndecryptable`, and the data-browser passes it only when no wrapped key record exists for that agent — i.e. when the key is genuinely unrecoverable rather than merely absent from this page load. The old behaviour was unconditional, on the reasoning that the file is a cache whose contents are re-fetchable from the server; that is false for a local-only drive, whose only copy it is. Relatedly, `resolveDbKey` no longer invents a fresh key when an agent has a wrapped key record but no session key (an agent restored from a non-extractable keypair, where no secret enters JS). It returns null and no worker is started, so the store runs server-only until a sign-in with the agent secret or recovery code unwraps the real key — which is what the code's own comment already claimed it did. Minting a key in that state produced exactly the wrong-key open that triggered the delete, so a drive that existed only in the browser could be destroyed with no user action, while its key was still sitting in IndexedDB waiting to be unwrapped. New `discardUndecryptable` option on `ClientDbOptions` and the worker's `init` message, defaulting to off. +- Fix: `agentVaultProof` verifies that a live signature reproduces itself unless the signer positively declares itself deterministic. It used to double-check only signers that declared `signsDeterministically: false`, so one that said nothing was taken on trust — and a signer that randomizes (WebKit's WebCrypto does, for Ed25519) could have had a non-reproducible signature turned into the key its Cloud Vault backups are wrapped under. +- Fix: `@tomic/lib` writes the Loro `datatypes` tags in the export path shared by genesis and drain-time signing, after the user's pending ops are sealed into their own commit. The drain used to tag first, which folded a `set()` edit into the tag write's `atomic:system` commit — the canvas undo stack skips that origin, so the first edit of a `json`/reference property after a save could not be undone. +- Perf: a cold page load asks the local database (OPFS worker) for all the resources a render pass mounts in one round trip instead of one per `useResource`. `Store` coalesces the render-phase cache misses of a tick into a single `getResourcesWithSnapshots` call (chunked at 200 subjects), and a subject asked for twice while a read is pending or in flight shares that read. 50 mounted resources went from 50 worker messages to 1; the tri-state answer (`true` / `false` / no database to ask) and the "ask again once the database attaches" behaviour are unchanged. +- Fix: deleting a resource while offline no longer loses the delete. `Resource.destroy()` now goes through the durable `LocalOutbox` like every other write: the signed destroy commit is queued (`OutboxEntry.signedDestroy`, persisted in localStorage), the resource is removed locally at once, and the drain POSTs the envelope with the usual backoff and reconnect replay. Online, `await destroy()` still resolves after the server acknowledgement and rejects on a real refusal; offline it resolves with the delete queued. A resource created and deleted before either write reached the server is dropped without a POST, and a server answer that the resource is already gone counts as acknowledged instead of retrying forever. While a delete is queued, incoming state for that subject (a subscription push, a fetch that raced the delete, a stale OPFS row) no longer resurrects it. `Store.hasPendingDestroy(subject)` is new; `LocalOutbox` gains `setDestroyCommit`, `clearDestroy` and `discard`. +- Fix: the outbox decides whether a refused commit is terminal (drop it), benign (drop it quietly) or blocking (park it) from the server's structured error code first — the `ERROR` frame's `code` over WebSocket, or the `errorCode` property on the HTTP `/commit` error body — and only falls back to matching message text when the response carries no recognized code (older servers). Previously the store's "benign drop" check (`is_genesis: true, but the resource already exists`, `Commits cannot be edited`) matched message text only, so a wording change on the server would have turned a silent bookkeeping drop into an error toast per commit, and "Commits cannot be edited" had no code at all. New `ErrorCode.IMMUTABLE_COMMIT` (10) and `isBenignTerminalCommitError(message, code)` in `@tomic/lib`. - Local Thought connections install a folder after one access check and import in the browser without a preview dialog. Opening the folder or a table refreshes automatically, with five-minute refreshes while open, visible sync status, and local-edit preservation. - Fix: form inputs validate before writing. `InputString` and `InputURI` no longer put an invalid value into the resource while showing an error; all inputs share one validate-then-set hook (`useValidatedInput`) and surface the datatype's actual error message (e.g. "Not an integer") instead of a generic "Invalid value". `ResourceField` now accepts and forwards `commit` / `commitDebounceInterval`, and every input honours `commitDebounceInterval` (Markdown, Number, Boolean, Date, Timestamp, Resource, ResourceArray and FilePicker previously fell back to the 100 ms default). A required field whose value loads after the first render is now flagged correctly. +- Fix: `Resource.remove()` and `Resource.push()` emit `LocalChange` like `set()` does, so `useValue` / `useArray` re-render when a field is cleared or an item is appended. `useValue`'s setter clears a previously reported validation error when called with `undefined`. `useArray`'s `push` saves through the same debounced scheduler and error handling (`handleValidationError` / `store.notifyError`) as `set`, instead of an immediate `resource.save()` that only logged failures. `StoreContext` no longer defaults to a phantom `Store`: `useStore()` throws when no `` is mounted. +- `@tomic/lib`: one list of server-managed properties (`server-managed-props.ts`) replaces the three copies in `resource.ts` and `store.ts` that had drifted apart; the OPFS cold-load guard now also treats an inline `genesis` certificate as skeleton, not content. One serializer (`Resource.toClientDbJsonAd()`) writes the local-database row from both `Store.addResource` and `Resource.persistToClientDb`, and a durable save now records its write in the store's dedup stamp so the next ingress does not rewrite the same row. - Fork bar: "Review changes" opens the per-property diff (the original's current value against the fork's) and names the properties the original also changed since the fork, so a reviewer sees what a merge writes over instead of a count. - A dashboard is reachable from its table: "Add view" offers **Dashboard**, which creates an empty Dashboard as a child of the table and shows it as a tab (`view-kind: dashboard`, `view-dashboard`). Switching an existing tab to Dashboard does the same. The Dashboard stays a resource of its own, so a Drive page or a document can still embed it. - Fix: creating a second table column with a name that already exists in the drive's ontology (e.g. two "Status" columns) no longer mints a colliding property shortname that silently corrupts the ontology. A compatible existing property is reused instead; an incompatible one gets a disambiguated shortname (`status-2`) ([#1504](https://github.com/ontola/atomic-server/issues/1504)). @@ -16,6 +99,7 @@ This changelog covers all five packages, as they are (for now) updated as a whol - Fix: file previews and avatars wait for the local blob lookup before requesting the server, avoiding transient 404s for offline uploads. `useFileObjectUrl` accepts an optional network fallback URL and returns `undefined` while the local lookup is pending. - Fix: `@tomic/cli` `ad-generate ontologies` works with `did:ad:` ontology subjects. A DID is not an HTTP URL: the CLI needs `serverUrl` (the Atomic Server origin) and fetches `GET {serverUrl}/did?subject=…`. Pasting the address-bar form `https://host/did:ad:…` no longer fails with `Resource has wrong subject in @id` — that URL is an alias, and the resource's `@id` is the DID. `ad-generate init` writes `serverUrl`. +- Page transition animations are now **opt-in**. They still break outside Chromium on desktop (a card-to-page morph blows up into an overlay on Firefox and on Android Chrome), so they are off until every browser we support is verified ([#1563](https://github.com/ontola/atomic-server/issues/1563)). Settings > Accessibility gains "Enable page transition animations" in place of the old "Disable" checkbox, backed by a new `viewTransitionsEnabled` localStorage key (default `false`). The old `viewTransitionsDisabled` key is no longer read: reusing it would have left transitions on for anyone who had ever toggled the old checkbox back off. The transition machinery and CSS are untouched, so turning them back on is a default flip. - Fix: page transitions on Firefox no longer smear into a giant overlay or get skipped entirely. Snapshot sizing is scoped by `view-transition-class` (titles keep the height-based aspect-ratio rule; card→page morphs fill the group), title links that wrap a heading are `inline-block` so Firefox does not treat them as duplicate names (IB splits), and a failed or hung `startViewTransition` still navigates and skips the overlay instead of covering the page. ## [v0.41.0-beta.7] - 2026-09-12 diff --git a/browser/data-browser/AUTH_FLOWS.md b/browser/data-browser/AUTH_FLOWS.md new file mode 100644 index 000000000..a4db77c31 --- /dev/null +++ b/browser/data-browser/AUTH_FLOWS.md @@ -0,0 +1,68 @@ +# Account entry and unlock routes + +The portal session identifies the cloud account. The app's local agent unlocks +the workspace. Either can exist without the other; a portal URL or session must +not prevent signing in with an agent secret, including while offline. + +## Implementation + +- [GettingStartedFlow](src/views/getting-started/GettingStartedFlow.tsx): welcome, secret/passkey unlock, restore and post-unlock navigation. The unconditional portal redirect was here. +- [IdentityReconcileGate](src/components/IdentityReconcileGate.tsx): compares the portal account with the local agent and resolves identity conflicts. Stale asynchronous results previously redirected after sign-in. +- [SettingsAgent](src/routes/SettingsAgent.tsx): requires an unlocked agent before managing the backup/passkeys. +- [WelcomeRoute](src/routes/WelcomeRoute.tsx): validates the internal sign-in continuation parameters. +- [Portal App](../../../atomic-saas/portal/src/App.tsx): `checkAuth`, `enterApp` and `addPasskey` control session detection, dashboard routing and the handoff to app settings. + +## Routes + +| Entry / state | Destination and behavior | +| --- | --- | +| App root, local agent and drive available | Open the drive (`RootRoutes`). | +| App root without a local agent; sign-out; device lock | Welcome stays in the app. Sign in offers cached passkeys, recovery and agent-secret entry. | +| Welcome → Create account, hosted distribution | Explicit navigation to the portal for email verification. | +| Welcome → Create account, self-hosted | Local creation, unless the node disallows it. | +| Portal verification for an account without existing data | `/app/welcome?from_portal=true&email=…` opens identity creation. | +| Private drive opened without an agent | `/app/welcome?next=` opens sign-in; successful unlock returns to that drive. | +| Secret / passkey / recovery-code unlock, workspace present | Open the requested or personal drive. | +| Unlock, workspace absent | Try hosting and encrypted vault restore; if still absent, show Connect device. Do not open an empty workspace as if restored. | +| Portal Add passkey, no recovery backup | Register the portal passkey in the portal. | +| Portal Add passkey, recovery backup exists | Open `/app/agent` to manage the encrypted account backup. | +| `/app/agent` without a local agent | `/app/welcome?return_to=agent` opens sign-in, then returns to `/app/agent`. Managing a passkey does not require restoring all workspace data. | +| Portal account differs from the local agent, disposable local identity | Reconciliation opens `/app/welcome?step=signin`; preserve `return_to=agent` when coming from settings. | +| Same mismatch, local identity has a workspace | Ask before switching; choosing the account follows the unlock route above. | +| Sign-in explicitly selects a different secret | Release the conflicting portal session using the existing secret-sign-in handler. Outdated reconciliation results cannot navigate, bind an identity, or repoint the server. | +| Invitation for an existing account | `invite` opens recovery and resumes the invitation after unlock. Invitations and requested drives take precedence over settings continuation. | +| Portal `/signin`, valid existing session | Replace URL with `/dashboard` and load the account. | +| Portal `/signin`, anonymous | Keep the sign-in form. | +| Email link supplied | Show the existing link-confirmation step, then exchange that link; never fall back to an older session after rejection, including on reload. | +| Portal public pages, billing, device linking, invitations | Preserve their existing destinations rather than applying the generic sign-in redirect. | + +`return_to` accepts only the named value `agent`, never an arbitrary URL. +Welcome's Back buttons can explicitly return to the portal; merely rendering +welcome does not leave the app. + +## Failure mechanism and repair + +Welcome used to call `location.replace(portal + '/dashboard')` whenever its +step was `welcome`. Settings, lock, resource guards and reconciliation all use +that same screen, so returning to welcome could immediately undo the app entry. +Its hosted rendering branch also hid the sign-in controls behind a spinner. +Removing both behaviors makes local unlock reachable again. + +`IdentityReconcileGate` also applied results from three asynchronous reads after +the identity or route had changed. Effect cancellation and a +check against the current store agent now discard those results. Mounted tests +reproduce redirects after a newer sign-in, a workspace check completing after +entering welcome, and an old hosting result changing the new agent's server. + +## Verification and limits + +Mounted component tests cover hosted/self-hosted welcome, secret entry, +settings continuation with and without local data, requested-drive priority, +invitation continuation, new-account handoff, arbitrary return-URL rejection, +missing-data fallback and stale reconciliation. Helper tests cover session +logout races, hosting reconciliation and private-drive guards. + +Portal Chromium tests cover existing/anonymous sessions, reload, public pages, +and rejected/fresh email links. Their API responses are controlled fixtures. +These checks do not establish that production has deployed this code, or that +a real authenticator has successfully registered a new passkey on atomic.place. diff --git a/browser/data-browser/UI_COMPONENTS.md b/browser/data-browser/UI_COMPONENTS.md index 38577d6d0..10e12122e 100644 --- a/browser/data-browser/UI_COMPONENTS.md +++ b/browser/data-browser/UI_COMPONENTS.md @@ -27,12 +27,16 @@ This document might not be entirely up to date. If you need anything that is not ## Disclosure And Navigation UI +- `src/components/AtomicLink.tsx` - Resource and app links; overlays can provide `ResourceLinkNavigationContext` to dismiss after resource navigation, including activating the current resource. + - `src/components/Tabs.tsx` - Radix-based tabs with config-driven tab lists, panel children, rounded variant, and error styling. - `src/components/Collapse.tsx` - Animated expand/collapse wrapper, used in the Details component. - `src/components/Details.tsx` - Disclosure component similar to `
`, with a caret row or custom title control. - `src/components/ScrollArea.tsx` - Themed Radix scroll area; also exports `ScrollViewPort` for nested viewport needs. - `src/components/ChatMessagesContainer.tsx` - Stick-to-bottom scroll container for chat-like message lists (auto-scrolls on new content unless the user scrolled up). Used by the AI chat and ChatRoom views. - `src/components/RightPanel/RightPanel.tsx` - Resizable drawer docked to the right of the screen; combine with `RightPanelContext` so panels (AI sidebar, Comments) are mutually exclusive. +- `src/components/PanelLayout.tsx` - Shared animated width slot, transition timing and floating-panel backdrop for the left sidebar and right panels. Width transitions pause while resizing. +- `src/components/SideBar/SideBarPanel.tsx` - Collapsible sidebar section with a header that supports mouse, pen and touch height resizing. Uses a stable height preference key; header actions remain separate from the drag/toggle target. ## Resource Views diff --git a/browser/data-browser/index.html b/browser/data-browser/index.html index c1f811481..783d29e12 100644 --- a/browser/data-browser/index.html +++ b/browser/data-browser/index.html @@ -10,27 +10,27 @@ content="The easiest way to create, share and model Linked Atomic Data." name="description" /> - + @@ -70,7 +70,7 @@ href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet" /> - Atomic Data + Atomic Place