Commit Graph
24 Commits
Author SHA1 Message Date
DarkSky 2cca599c4a test(server): count MCP reconcile work and check image updates 2026-12-03 16:07:08 +09:00
DarkSky e11104d658 perf(server): remove duplicate block extraction in MCP list rewrite
Move the editable block reconciler of `mcp.rs` into the new module
`mcp/reconcile.rs` and remove redundant work from it:

- Return early when a sequence has no old blocks and no new blocks.
  Leaf list items no longer allocate an empty nested reconcile state.
- Use one `visited` set for all exact-index extractions.
- The flavour phase now calls `apply_block_update_in_place` directly.
  An old block that the exact phase did not take cannot be equal to an
  unassigned new block, so the second extraction is unnecessary.
  The image update in `mutate_doc_body_delta` keeps the equality check.

Add test-only work counters. A unit test rewrites 500 and 2,000 list
items and makes sure that each old block is extracted once, that one
sequence runs, that all block IDs stay the same, and that the work is
linear.

The 2,000-item integration test no longer measures wall-clock time.
It now makes sure that the 2,000 list block IDs stay the same, that all
items are in order, and that the size guard rejects a body above 1 MiB.
2026-12-03 13:25:50 +09:00
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 f46af9a696 feat(server): add DynamicBlobStorage hot reload for copilot.storage 2026-11-27 02:47:56 +09:00
DarkSky 49a37caf3d feat(server-blob): upgrade assetpack crates and add precomp2 config toggle
Upgrade assetpack-core to 0.4.2 (default-features = false, file-transform),
assetpack-transform-precomp2 to 0.4.4 (precomp2 0.3.4), brotli to 9, and
zstd to 0.14, and drop the direct lzma-rust2 dependency.

Refactor AssetpackBlobStorage onto sqlx SqlitePool, FileTransformConfig::fast,
FileReader, and TransformDecoderRegistry with zero-clone chunk reads, separate
read/write/transform semaphores, manifest-only promote_object, and Unix-second
object/cache timestamps. Add config.precomp2 (default true), reject precomp2 on
fs configs in both validation and startup parsing, document v0.27.5 coexistence
in docs/rollout-coexistence.md, and cover real 0.1.0 interop, PCF2 segment
bombs, and 16000x16000 PNG regressions.
2026-11-26 14:22:39 +09:00
DarkSky 99791c3bc0 chore(backend): upgrade y-octo to 0.4.2 and harden sync boundaries
- Upgrade `y-octo` to `0.4.2` (`y-octo-core 0.1.1`) in `packages/backend`
  and add `y-octo-core` to `server-sync` and `server-domain` for write-boundary
  v1 scanning.
- Reject new zero-length struct updates in `server-sync::storage::validate_doc_update`
  and `server-domain::workspaces::create_workspace_with_init` via
  `y_octo_core::decoder_v1::decode_update_v1` while keeping persisted
  historical zero-length reads intact.
- Align workspace lifecycle root-doc decoding to `WORKSPACE_LIFECYCLE_MIGRATION_READ_LIMITS`
  (`max_structs = 16_000_000`), propagate `ReadError::ResourceLimit` before
  committing `storage_reconciliation_checkpoints`, and preserve the
  `[affine-doc:resource_limit]` marker in `server-domain::doc_sharing`.
- Keep `ReadError::IncompleteSnapshot` fallback to `Doc::try_from_binary_v1`
  in `server-sync` and `server-domain` while enforcing `ReadLimits`.
- Add regression tests for cross-frame zero-length poisoning, workspace init
  zero-length rejection, legacy zero-length recovery, multi-client clock gaps,
  alias `ResourceLimit` markers, and lifecycle `ResourceLimit` rollback plus retry.
2026-11-26 05:42:25 +09:00
DarkSky 70173e6565 feat(backend): add billing GraphQL resolvers, SPI, and disposition handler 2026-11-25 21:40:22 +09:00
DarkSky 8c9f4512d5 feat(backend): add public HTTP surfaces and maintenance workers
Implement static asset hosting (Selfhost and Front canary Web Mobile shell), SSR document renderer with ACL-backed preview exposure, HTML head/avatar OG metadata, and iterative bounded Markdown rendering skipping affine:surface and edgeless notes, worker proxy (image-proxy and 2 MiB link-preview) with bounded cache and shared Redis Hash Lua/memory throttling with SHA-256 tracker hashing, telemetry collection with shared version/throttle guards, per-method invalid origin messages, and bounded param flattening, GraphQL CR comment depth pre-scan hardening, and periodic background maintenance workers with slash-separated advisory locks and pending-updates backlog gauge.
2026-11-25 18:55:14 +09:00
DarkSky 69bacafdad feat(http): wire multipart blob routes, storage hot-reload, and boot_storage 2026-11-25 18:55:14 +09:00
DarkSky 51c7cd31a5 feat(server): add workspace MCP credentials, GraphQL resolvers, and stateless JSON-RPC transport 2026-11-25 14:10:29 +09:00
DarkSky 55adbc6080 feat(server): add calendar sync service, GraphQL resolvers, and webhook REST routes 2026-11-25 14:10:29 +09:00
DarkSky 3304aaa4cf feat(server): add calendar provider adapters, crypto, iCal parser, and OAuth state store 2026-11-25 14:09:03 +09:00
DarkSky c043f6c7ac feat(server): add security challenges, signing key rotation, and UserType.token
Implement single-transaction security challenges (email verification, password change/set, email change with percent-decoding and realtime user-updated fan-out), admin session signing key rotation/deletion with strict verify_until boundary and parent token TTL policy, UserType.token, Query.error, and GraphQL strict throttling.
2026-11-25 10:01:21 +09:00
DarkSky 2f41f8977c feat(server): add login OAuth/OIDC, PostgreSQL captcha, and strict throttling
Implement OAuth/OIDC preflight, atomic runtime_states claim (3h TTL), bounded TTL discovery/JWKS caching, ring/p256 JWT verification across RS/PS/ES algorithms, Apple args secret normalization, PostgreSQL-backed Hashcash and Turnstile captcha, and request-level strict throttling.
2026-11-25 09:56:04 +09:00
DarkSky ed2852614d feat(server): add admin console workspace, dashboard, shared-link, and mail-delivery queries
- Add AdminService in server-domain for workspace listing, counts, details, member/shared-link lookups, workspace updates, dashboard metrics, shared-link pagination, and mail-delivery aggregates.
- Expose adminWorkspaces, adminWorkspacesCount, adminWorkspace, adminUpdateWorkspace, adminDashboard, adminAllSharedLinks, and adminMailDeliveries in server-http GraphQL.
- Update packages/backend/AGENTS.md with AdminService and admin console query documentation and extend integration tests.
2026-11-25 09:24:01 +09:00
DarkSky f218b68e4b feat(server): add admin user management, config validation, doc analytics, and realtime topic tests
- Implement admin user CRUD, feature updates, batch import, enable, and recreate-for-ban transaction semantics in UserService.
- Derive ServerConfigType oauthProviders and OAuth/Captcha feature flags dynamically from app_configs and resolve availableUpgrade on demand via safe_fetch.
- Add appConfigMetadata and dry-run validateAppConfig with secret redaction and env-only key rejection.
- Add workspaceRolePermissions and DocType analytics/lastAccessedMembers with Doc.Read and Doc.Analytics permission checks.
- Wire WorkspaceService to EventBusPublisher for single notification.count.changed emission on invite, accept, and approve flows and add integration tests.
2026-11-25 09:21:34 +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 42a52df55c fix(server-domain): box partial cleanup on DeleteUserError 2026-11-24 23:58:11 +09:00
DarkSky af0d124d5d feat(server): add lockless compaction CAS, search projection v6, and server-search
Refactor document compaction and search projection to remove cross-workspace lock contention and hold zero locks during CRDT merges.

Document compaction and user deletion changes:
- Replace single-transaction compaction with lock-free reads, owned-permit blocking CRDT merges, and short strict-CAS write transactions.
- Retry compaction on snapshot or update CAS mismatches and PostgreSQL 40P01 deadlocks.
- Replace full-table pending update grouping with a rotating primary-key loose index scan and per-batch quota cache.
- Delete owned personal workspaces in individual short transactions with post-lock Team verification and partial cleanup returns.

Connection, rate-limit, and test harness changes:
- Set default statement and idle transaction timeouts on dedicated PostgreSQL session connections.
- Run deferred invite rate-limit effects only after rejected invite transactions roll back cleanly.
- Pass prebound SMTP sinks in parity-harness replay tests to eliminate ephemeral port races.

Search projection v6 and pure-Rust runtime changes:
- Add search_projection_v6.sql with per-workspace advisory locks, post-lock mode re-checks, and a 30s pre-expiry dual-lock bridge.
- Skip steady-state workspace_states updates during ordinary document snapshot writes to remove hot-row contention.
- Validate forward-compatible contiguous prefixes in native_schema_migrations during rolling upgrades.
- Add pure-Rust server-search (disabled by default) with committed marker-XID fences, deferred GC progress retention, repeatable-read ACL snapshots, and GraphQL resolvers.
2026-11-24 23:36:03 +09:00
DarkSky fe911cf25e fix(license): propagate schedule confirmation error in sync_workspace_seats
Return a DomainError when installed_licenses.validated_at fails to update after remote seat synchronization.
2026-11-24 18:41:18 +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