Commit Graph
9 Commits
Author SHA1 Message Date
DarkSky 9cd813275b refactor(server): isolate v0.27.5 compatibility code and track its exit
Move the userspace SessionRedis lock bridge and the lazy root doc lifecycle
migration into server-sync/src/legacy_compat. Mark every remaining
v0.27.5 compatibility point with a compat tag.

Add docs/post-cutover-ablation-backlog.md with the exit check and removal
scope of each tag. L0 Tier A gate 7 now checks that tags and entries match
one to one.
2026-11-27 05:48:02 +09:00
DarkSky 9603b4b762 feat(server): add SQL manifest, safe_fetch, route matrix, and client version guard
Add the server foundation contracts for SQL execution order, outbound SSRF
protection, deployment and role route isolation, and client version control:

- Add the ordered SQL manifest (`packages/backend/server-db/sql-manifest.json`)
  and check manifest coverage and SHA-256 digests in `check-l0-tier-a.mjs`.

- Add `server_domain::safe_fetch` with pinned DNS resolution, per-origin
  private network allowlist, redirect header filtering, cross-origin body
  replay blocking, and legacy error envelope mapping.

- Add `RouteMountMatrix` across `(DeploymentMode, dev_mode, ServerRole)` with
  modular REST and GraphQL route wiring and `ServerExtension` isolation.

- Enforce `client.versionControl` with cached `AppConfigService` snapshots,
  anonymous fast-path short-circuiting, npm semver range parsing, named guard
  coverage on public auth endpoints, and read-only cookie session resolution
  with TTR refresh.
2026-11-25 04:12:12 +09:00
DarkSky 1d6fd58258 feat(backend): add doc sharing, histories, comments, notifications, open-app, and license
Add Rust domain services, GraphQL resolvers, REST routes, and realtime RPC
handlers for public docs, grants, histories, comments, notifications, user
settings, Open-App sign-in, and self-hosted licenses.

- Add DocSharingService, public-docs routes, y-octo root-doc filtering, and
  realtime share-state and grants RPCs.

- Add DocHistoryService, snapshot recovery, update compaction, and expired
  record cleanup.

- Add CommentService, NotificationService, user settings, Open-App codes,
  SelfhostLicenseService, and BillingSpi.

- Run 9 deterministic Cloud E2E specs in CI, remove waitForTimeout calls,
  and add collaboration parity checks.
2026-11-24 17:25:29 +09:00
DarkSky ae1bd232db feat(server): add public API parity and cloud E2E cutover for affine-server
Add public-repo API parity to `affine-server` and run the core cloud
Playwright suite against the Rust all-in-one server.

- Add HS256 Bearer access tokens, native session exchange, refresh,
  revoke, and list REST endpoints, login preflight, profile updates,
  WebP avatar transcoding and safe removal, and a distributed-locked
  expired-session cleanup worker with background lease renewal.

- Unify workspace and per-document ACL evaluation (`acl.rs`), split
  REST and GraphQL modules, and add workspace member management,
  ownership transfer with readonly and quota invalidation guards, atomic
  invite links, `createWorkspace(init)` transactional root snapshots,
  `DocType`, `DocPermissions`, `createBlobUpload`, `calendarProviders`,
  and SocketIO realtime workspace access and config rooms.

- Extract reachable blob keys with `y-octo` bounded BFS under
  `REPEATABLE READ` snapshots with pre-merge budgets and bounded caching,
  check per-doc ACL and reserved doc isolation on source-scoped blob
  routes, paginate `readable-blob-manifest/v1` with SQL cursor pushdown,
  and reject legacy blob reads with `403 UNSUPPORTED_CLIENT_VERSION`.

- Keep fresh DB bootstrap on the default v1 sync protocol until
  activated, and accept both absent (v1) and active (v2) lifecycle
  checkpoints on existing databases.

- Add `AFFINE_E2E_RUST_SERVER=1` Playwright support and a
  `cloud-e2e-rust-server` CI job, extend the live parity scenario to
  23 steps, and lower `waitForTimeout` usage from 336 to 312 (ratchet
  from 324 to 316).
2026-11-24 07:59:26 +09:00
DarkSky dece75f25a feat(server): add billing subject, rate limit SPI, and userspace mutex
Add `BillingSubject` to `AccessGrant` in `server-types` and re-export it from `server-spi`.
Remove the direct `entitlements` SQL query from `UserType::quota` in `server-http`.
Resolve personal storage quota from `AccessGrant.billing_subject` alone.

Add `RequestSource`, async `RateLimitPolicy`, and `CommunityRateLimitPolicy` to `server-spi` and `ServerExtension`.
Remove duplicate `AuthMailQuotaPolicy` from `server-domain`, add pure-Rust `contains_url_or_domain`, and add batch `invite_members_with_source`.
Wire `RateLimitPolicy` with on-demand `RequestSource` into `AuthService`, `WorkspaceService`, `server-http`, and `affine-server`.
Add `InvalidationHintV1::QuotaEntitlement` and `serve_with_extension_and_init` for startup hooks before serving requests.

Upgrade `RedisMutex` in `server-worker` with cached connections, lock-free connect, cancel-safe Lua lock retry, pre-commit fencing, and cancel-safe release.
Wire `server-sync` userspace writes (`MutexLock:userspace:<user_id>:<doc_id>`) to `RedisMutex` on `SessionRedis` with millisecond timestamps, upfront DB permits, lease renewal, and pre-commit fence rollback.
Handle empty-table insert conflicts via `ON CONFLICT DO NOTHING` with a `FOR UPDATE` merge fallback.

Update `packages/backend/AGENTS.md` and ignore pre-signed native license JSON in `.prettierignore` and `.oxlintrc.json`.
Extend `scripts/ci/check-l0-tier-a.mjs` to block non-test `entitlements` SQL queries in `server-http` and check documented Rust types.
Replace 22 active `waitForTimeout` calls in 12 local E2E specs with state assertions and lower `scripts/ci/l0-ratchet.json` from 358 to 336.
2026-11-23 20:24:28 +09:00
DarkSky c245d8e1f7 feat(server): add domain, mail, blob, sync services and writing rules
Add server-domain, server-mail, server-blob, and server-sync under packages/backend with y-octo 0.4.0.
Wire auth, blob, mail worker, and Socket.IO routes into server-http and affine-server.
Extend the parity harness and CSF frame audit checks.
Fix mail error redaction, expired terminal error codes, database clock reads in blob checks, and permission docs.
Add the STE writing skill and update AGENTS.md rules.
2026-11-23 16:04:20 +09:00
DarkSky b375374c7f refactor(server): move server crates under packages/backend and upgrade y-octo to 0.4.0
Move the server Rust workspace directly under packages/backend.
Exclude native and server from that workspace.
Move frame-audit to tools/frame-audit as a standalone crate.
Isolate packages/backend/native under the root workspace.
Upgrade y-octo to 0.4.0 in native-playground and remove the old removal workarounds.
Update CI workflows, static gates, and docs for the new paths.
2026-11-23 15:12:26 +09:00
DarkSky 82e166f49b test(parity): frozen v0.27.5 self-parity run, web build lane, fewer waitForTimeout
Parity harness:
- `compare` re-runs the comparison on a recorded report offline through
  the same protocol/database/effects path as live runs, and like `run`
  rejects scenarios without steps.
- `require` lists per-side checks (equals, length, contains); an unmet one
  is a difference at /require/<side><pointer>, so two sides failing the
  same way are never green.
- Timestamps also accept RFC 2822 HTTP dates (cookie Expires), with both
  sides in the same format.
- Socket.IO `record_events` limits which pushed events are reported;
  `wait_event` still sees all of them.
- scripts/run-v0275-self-parity.mjs boots two @affine/server instances of
  the checkout given by --server-root (the frozen baseline,
  darksky/before-stable-fix c2929acf2d) on
  leased PG16 clones, two Redis containers, two SMTP capture ports and
  separate HOMEs, in a run directory of its own; runs the data migrations,
  validate-cutover and workspace lifecycle activation; replays
  scenarios/v0275-self-parity.json (/info, GraphQL setup/auth/workspace/
  quota, Socket.IO join/push/load, a real test mail) and requires 0
  differences across protocol, all user tables, SMTP and Redis plus every
  requirement (doc accepted and stored, schema_baseline_0275 checkpoint,
  one mail, invalidation and event bus messages), then a tampered
  right-side DB row and GraphQL field reported at exactly their paths.
  Only a passing run writes --record, atomically, with the server SHA;
  cleanup failures fail the run; a temporary static manifest is removed.
- tests/v0275_self_parity.rs replays a committed recording of the frozen
  baseline, injects one change per dimension and checks that both sides
  losing the same results fail their requirements.

CI:
- np-web-build.yml builds @affine/web, @affine/mobile and @affine/admin on
  ubuntu-24.04 without Electron/Playwright/Sentry downloads, each bundle
  within eight minutes, and checks the bundle entry exists;
  native-playground.yml calls it only when frontend sources change.

Test debt:
- Delete the unused blocksuite std inline test helper and the unused
  selectVisibilitySelector; drop sleeps already covered by auto-waiting
  assertions and click(); poll getIndexCoordinate per animation frame.
  waitForTimeout ceiling 378 -> 370.
2026-11-23 13:58:04 +09:00
DarkSky 4a08e49642 feat(ci): add crates/ test harness workspace, shared frame audit and fast CI lanes
- crates/: standalone server-side Rust workspace (resolver 3, edition
  2024, own lock and toolchain 1.98.1)
  - frame-audit: the one serde-only FrameSnapshot schema and audit
    engine; native-playground's ui depends on it by path and re-exports
    it. The six structural rules keep their ids; evidence rules (first-
    line baseline, footer reverse wrap, divider placement, static cursor,
    overlay z-order via renderer hit-test probes, text truncation) report
    missing evidence instead of skipping, and concentric radii reject
    negative and step-limited radii. Old snapshots still load.
  - test-db-harness / affine-test-env: a marker-checked PostgreSQL test
    cluster (explicit URL or a reused machine-wide pgvector container),
    read-only migration-digest templates with Prisma bookkeeping,
    template clones under owner-token leases, and an orphan reaper. Clone,
    heartbeat, release and reap serialize per database on an advisory
    lock and re-check under it; every maintenance connection re-checks
    the cluster marker. Private Redis or a prefix-isolated URL. Images
    pinned to multi-arch digests; only private harness containers of the
    expected run, by full id, can be removed. run.json reports.
- scripts/ci/check-l0-tier-a.mjs: dependency-free gates for crates/
  layering and hygiene, a waitForTimeout/.skip ratchet with per-file
  ceilings, workflow references, pinned test images and .gitignore.
- native-playground.yml: resolve the change base to a commit SHA, call
  np-web-fast.yml (lint, typecheck, Node-only Vitest projects without
  Electron, browser or Rust-binary dependencies) when web sources
  change, and always run L0, the frozen server contract checks, crates/
  and the parity harness (fmt, clippy, tests against real services).
- Web lint and format: the frozen contract artifacts and
  blocksuite/native-playground (checked by its own lane) are ignored via
  .prettierignore, from which .oxlintrc.json is generated; the server
  contract and parity harness scripts are formatted and lint-clean.
- tools/parity-harness/rustfmt.toml keeps the default style there.
- Remove the copilot cron workflows and the skipped migration spec;
  ignore test-results/ and .artifacts/.
2026-11-23 13:58:04 +09:00