mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 11:15:01 +03:00
- 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/.
3.1 KiB
3.1 KiB
Working on AFFiNE Native Playground (for agents)
These rules apply at repository root on the darksky/native-playground branch and topic branches under darksky/np/**. Subdirectory AGENTS.md files (notably blocksuite/native-playground/AGENTS.md) state narrower rules beside the code they govern.
Branch & CI workflow
- Never merge to
canary. Integration lands ondarksky/native-playgroundonly. - PR-less CI on push: Push topic branches matching
darksky/np/**(ordarksky/native-playground) to trigger.github/workflows/native-playground.ymldirectly..github/workflows/build-test.ymlignoresdarksky/native-playgroundpull requests so unrelated legacy jobs stay silent. - Review council gate: Every topic branch requires at least 3 of 4 review council approvals before squash-landing onto
darksky/native-playground. - Performance regression gate: Any CI benchmark metric regressing by more than 10% against the rolling
N-3baseline is routed to the dedicated performance guardian before landing. - Cargo rustflags isolation: Root
.cargo/config.tomlinjects NAPI linker flags (-all_load,-undefined dynamic_lookup,-z nodelete) that Cargo concatenates into nested workspaces. Always build and testblocksuite/native-playgroundand the standalonecrates/workspace withCARGO_ENCODED_RUSTFLAGS=""in the environment. - Static gates and fast lanes:
node scripts/ci/check-l0-tier-a.mjs(no dependencies, under a second) guardscrates/layering and hygiene, thewaitForTimeout/.skipratchet inscripts/ci/l0-ratchet.json(counts may only go down; lower the ceiling with--update-baseline), and workflow references.native-playground.ymlalways runs it with the frozen server contract checks (scripts/oracle), thecrates/checks and thetools/parity-harnesschecks, and callsnp-web-fast.yml(lint, typecheck, Node-only Vitest projects) only when web sources change.
Engineering & testing principles
- Global optimum over band-aid patches: Favor clean structural refactoring and bold deletion over minimal-diff workarounds, defensive clutter, or over-abstraction. Delete obsolete helpers, structs, and files outright, and fold single-caller one-way fragments back into their caller when they add indirection without clarity.
- Test names match actual scope: Every test file and test function name must accurately reflect everything it asserts — never append unrelated assertions to a narrowly named test without renaming it to match.
- Table-driven tests: Group related scenarios (geometry/hit-testing, parsers, key sequences, IME cases) into concise table-driven loops rather than proliferating near-identical
#[test]functions.
Keeping rules true
- When a change makes any statement, path, command, or invariant in an
AGENTS.mdfile inaccurate, update thatAGENTS.mdin the same commit. - A new directory with rules of its own gets an
AGENTS.mdand a one-lineCLAUDE.mdcontaining@AGENTS.md. - Keep code, comments, workflows,
AGENTS.md, and commit messages free of internal process-journal jargon.