unlimited ai usage for affine

This commit is contained in:
2026-11-07 09:20:23 +00:00
parent 75aaa197aa
commit 84dd1616e7
6 changed files with 583 additions and 3 deletions
+70
View File
@@ -204,3 +204,73 @@ chat SSE endpoint also passed, including automatic profile routing.
Only the server now owns the imported rotating session; the local active
credential copy was removed after remote verification. Images and attachments
remain unsupported and are not advertised by the profile.
## AFFiNE managed trial counter versus provider limits
`currentUser.copilot.quota { limit used }` describes AFFiNE's managed AI trial,
not the connected ChatGPT account's remaining usage. It must not be presented as
an OpenAI allowance or an invoice. BYOK execution is authorized independently
from quota-backed managed routes and records usage as `byok_server`.
The pinned release has a legacy accounting edge case: deleted sessions retain
`messageCost`, while the BYOK exemption query joins usage billing units to live
message rows. Removing test conversations can therefore leave a misleading
managed-trial cost after their BYOK message rows disappear. The observed `8/10`
was explained by eight such retained units; the connected provider's request
history was tagged BYOK, not AFFiNE-managed usage.
Do not fix this by resetting usage, promoting a plan, granting unlimited quota,
or weakening server enforcement. The raw quota and all provider/quota errors
remain unchanged. A self-hosted UI should instead identify AI as self-hosted
and explain that provider and server limits may apply, without a managed-trial
progress bar, Free badge or AFFiNE upgrade action. Cloud quota presentation
continues to use the original managed allowance.
ChatGPT subscription access is already paid for by the account owner; it is not
unlimited. OpenAI still enforces the account's model, usage-window and app-access
limits. This connector does not add an API-key billing fallback.
### Verified self-hosted usage rollout
On 2026-11-06, frontend static package
`3s22k6a5p9731xmlr6x33icilcsfkzv2-affine-frontend-static-0.27.4` was copied to
`hectic-lab` and mounted over the unchanged backend's static directory. This
was a bounded systemd override, **not** a NixOS generation switch: the active
and boot generation remain `6rb81fr95gngs99x1dvjw9vzzd7snkn5`. A whole-host
build was interrupted rather than activating unrelated package updates.
The root-owned persistent drop-in is
`/etc/systemd/system.control/affine-native.service.d/99-frontend-static-rollout.conf`.
It resets `BindReadOnlyPaths` and supplies only the new static bind. This
control directory is used because NixOS's `/etc/systemd/system` points into
the immutable store. GC roots `affine-frontend-static-rollout` and
`affine-frontend-static-rollback` under `/nix/var/nix/gcroots` retain the new
bundle and the previous `hrg3dkcacg5drizifiinjx481k6k33d5` bundle.
Only `affine-native.service` restarted. The migration unit's active timestamp,
PostgreSQL, Redis and ChatGPT gateway process IDs and active timestamps stayed
unchanged. The running application's mount namespace was checked against the
new package's `index.html`; HTTPS `/info` remained healthy. An authenticated
headless browser verified the sidebar and account settings on desktop and a
Pixel 5 viewport: neutral self-hosted text, no trial count, progress bar or
billing action, in both English and Russian. This stable release serves the
responsive web application to mobile browsers; upstream's separate mobile shell
is canary-only. The separate
mobile component is covered by the source-level rendering check.
A real BYOK text probe succeeded after deployment. AFFiNE's raw managed quota
remained `{ limit: 10, used: 8 }` before and after; no accounting records or
provider limits were altered. Existing browser sessions need a hard refresh.
The drop-in survives reboots and NixOS generation rollbacks, and masks future
declarative frontend changes until removed. During the next reviewed NixOS
switch containing the desired `frontendPackage`, remove this exact drop-in,
run `systemctl daemon-reload`, and restart only `affine-native.service` so the
declared bind takes effect. Remove the temporary GC roots only after checking
that the active generation retains the desired package and rollback retention
is no longer needed. Do not use a broad `systemctl revert` operation.
To roll back this bounded rollout while the original generation remains active,
remove that exact drop-in, daemon-reload and restart `affine-native.service`.
Its declared unit still binds the previous `hrg3dkcacg5drizifiinjx481k6k33d5`
bundle. Confirm health and the effective bind before removing any GC root.