This file helps coding agents (and humans) work productively and safely in this repository. It complements—not replaces—the detailed rules under .cursor/rules/.
- Workspace: the root
simfinity-workspacepackage is private. All five publishable libraries, their declarations, licenses and package READMEs live underpackages/. - Examples:
examples/barber/{mongodb,postgres,frontend}are independent private npm applications with their own lockfiles, outside thepackages/*workspaces. The two backends consume released Simfinity runtime packages at exact version 3.5.9; the Next.js frontend is shared. - Packages:
@simtlix/simfinity-jsis the MongoDB/Mongoose facade;@simtlix/simfinity-coreowns the shared GraphQL runtime;@simtlix/simfinity-sqlowns driver-free relational planning/runtime;@simtlix/simfinity-postgresis the PostgreSQL 15+ plugin and compatible facade;@simtlix/simfinity-mcpgenerates MCP tools from a GraphQL schema. - Runtime: Node.js
>=18.18.0for library consumers. Use Node.js 24 for development and CI; documentation requires Node.js 22 or later. - Peers: every package uses
graphql^16. The Mongo facade alone has amongoose^8 peer; MCP has an optional@modelcontextprotocol/sdkpeer. PostgreSQL depends on SQL,pgand core, without MongoDB, Mongoose, or MCP.
| Topic | Rule file |
|---|---|
| Development workflow and release completion | .cursor/rules/simfinity-development-workflow.mdc |
| Architecture, core flow, global state | .cursor/rules/simfinity-architecture.mdc |
| Coding style, imports, errors, schema transforms | .cursor/rules/simfinity-coding-standards.mdc |
| Internal APIs / functions | .cursor/rules/simfinity-core-functions.mdc |
| Auth plugin, rules, expressions | .cursor/rules/simfinity-auth-module.mdc |
| Field extensions / introspection | .cursor/rules/simfinity-extensions.mdc |
| Tests | .cursor/rules/simfinity-testing.mdc |
| README / docs updates | .cursor/rules/simfinity-documentation.mdc |
| Barber applications and their CI | .cursor/rules/simfinity-barber-examples.mdc |
If something is ambiguous, prefer the matching .mdc file over this summary.
- Do not use
graphql-middleware’sapplyMiddlewareor@graphql-tools/utilsmapSchemaon a Simfinity schema — they rebuild the schema and duplicate globally injected introspection types. Use Envelop plugins and in-place resolver wrapping instead (see architecture rule). - Imports: static ES imports belong at the top; match existing style (single quotes, semicolons, trailing commas in multiline constructs). Preserve MCP's lazy optional-SDK loading and the explicit import-order test fixtures described in the rules.
- Behavior changes: update tests under
tests/and public docs (README.md) when the public API or documented behavior changes. - Package boundaries: core and SQL must remain driver-free; PostgreSQL must not import MongoDB, Mongoose or MCP. Keep GraphQL semantics in core, relational planning/record/session orchestration in SQL, and physical SQL/DDL/codecs/driver operations in engine plugins. Backend selection is fixed for each runtime; do not add runtime switching.
- Compatibility:
packages/mongodbstill publishes as@simtlix/simfinity-js. Preserve its entry points andsrc/deep imports, and their sibling.d.tsdeclarations, inside the published archive. Keep shared helper/error identities and update package declarations for public API changes. - Example boundaries: install and test Barber apps in their own directories. Keep them private, preserve registry dependencies and separate Compose projects, and do not add them to library workspaces or npm release tooling. Native database code stays in each backend; the frontend treats GraphQL IDs as opaque strings.
- Mongo reference integrity:
createMongoAdapter({ referentialIntegrity: 'transactional' })is opt-in and fixed at startup; default'off'stays compatible. Awaitadapter.initialize()after schema creation and database connection. Preserve target-document locks, snapshot/majority transactions, incoming-reference checks and rollback of supplied sessions on integrity violations. Native model/driver writes remain outside that guarantee; seedocs/guide/mongodb-integrity.md. - Publication is part of completion: when a task includes releasing a library change, the responsible contributor or agent must ensure both its
vX.Y.Ztag and published GitHub release exist, and verify successful package publication and the applicable documentation deployment. A merged PR or version bump is not a completed release.
This is a repository-wide rule for contributors and coding agents, not a local assistant preference. Follow the development and publication contract and the Cursor workflow rule.
Implement scoped changes on a branch, update the relevant documentation and tests, and merge through a reviewed PR with passing checks. When publication is requested or is already part of the agreed task, carry the work through the release workflow without asking again for the same authorization:
- Prepare the intended version with
node scripts/release-packages.js version <version>and validate it withnode scripts/release-packages.js check. Keep all five packages, their exact internal dependencies and the private root aligned. Reuse a correctly prepared unpublished version instead of inventing another bump. - After merge, create the annotated
vX.Y.Ztag on the exact validated commit inmasterand push it to GitHub. Ensure the matching GitHub release is published: the tag-triggered workflow can create it, or the contributor can publish the release in GitHub. Both must exist before completion. - Wait for Release Simfinity to finish. Verify npm and GitHub Packages for all five packages, the expected npm distribution tags and archive integrity, the GitHub release assets, and the stable documentation deployment. Prereleases use
nextand do not deploy the stable site. - Report the version, tag/release and workflow links, and verification results. If any step fails, resolve the cause and retry the original run; never move an existing release tag or describe a partial release as published. If access or another external dependency blocks completion, state exactly what remains.
Publication intent is required: ordinary edits, merges, and version changes do not authorize or trigger a release on their own. Documentation, CI, repository rules, and example-only changes do not need a library version just to land in the repository. Use the documentation-only deployment flow when website publication is requested. Publish packages through GitHub Actions/OIDC, not a local npm login; manual release-workflow dispatch is preview-only.
Run from the repo root after substantive edits:
npm run lint
npm testUse npm run test:watch while iterating; npm run test:coverage when coverage matters.
- For package boundaries, dependencies, exports or declarations:
npm run test:packageschecks extracted-archive quality, isolated packed applications, strict TypeScript consumers and MongoDB deep imports/resolution aliases. The core consumer also compiles every public core subpath (namespace, named, default and type imports) under NodeNext, Node16, Bundler and Node10, checking each member's exact type against the root and the export names both ways; it also checks the root's runtime value exports both ways (coreRootValues) and that the root error classes are theauthclasses. The MongoDB consumer compiles the legacysrc/deep imports under the same four resolutions with exact type equality.tests/core-subpath-types.test.jschecks the export map,typesVersions, declared names and re-exported types without packing, and the MongoDBsrc/sibling declarations; the archive quality check requires everyexportstypestarget to be in the archive. Keep quality tooling in root development dependencies only. - For dependency changes:
npm run test:securityaudits the root lockfile including development dependencies; CI and release validation require it. Audit independent documentation/example applications separately. MongoDB requires Mongoose^8.24.2; retain the update-casting security regression. - For database behavior: run the full suite with disposable database URIs, as described in the testing rule.
npm run test:integrationcovers onlytests/integration/; additional MongoDB regression suites live directly undertests/. - For documentation:
npm run docs:installandnpm run docs:build. - For Barber changes: follow
examples/barber/README.mdand.github/workflows/barber.yml. Root lint and Vitest excludeexamples/; run each affected app'snpm run test:security, its app checks, and the shared HTTP/browser contract against both databases for shared behavior changes. Use only disposable example databases for data-changing checks. - For release metadata:
node scripts/release-packages.js check. Release tooling aligns the private root version, all five package versions and exact internal dependencies; the root itself is never published.
- Implementation:
packages/core/src/owns the shared runtime and helpers;packages/mongodb/src/owns the MongoDB facade/adapter and compatibility shims;packages/sql/src/owns relational planning and runtime;packages/postgres/src/owns the plugin, SQL compilation, codecs and physical schema lifecycle;packages/mcp/src/owns MCP generation and transports. - Tests:
tests/covers core, both adapters, MCP and release tooling;tests/contracts/andtests/fixtures/hold shared fixtures. See the testing rule for MongoDB collection suppression in tests without a database. - Documentation:
README.mdis the repository overview;packages/*/README.mddescribes each published package;docs/builds the public website independently of the runtime packages. - Barber examples:
examples/barber/contains both backends, the shared frontend, per-stack Compose files, and HTTP contracts. The dedicatedbarber.ymlworkflow owns their dependencies and checks. PostgreSQL schema exports go to ignoredexamples/barber/postgres/generated/. - Release tooling:
release.ymlresponds tov*tag pushes and published GitHub releases: validate the existing tag against aligned versions andmasterhistory, package/database tests, npm OIDC + GitHub Packages, verified registry availability, GitHub release assets and stable Pages deployment. Version changes and merges do not publish; manual dispatch only previews.publish.ymlis reusable, not a separate manual publication step. Usescripts/release-packages.js version <version>in a reviewed PR; do not publish from a local login.release-state.jsprevents superseded retries from moving current releases backward;verify-published.jschecks npm visibility and integrity. npm trusts callerrelease.ymlwith environmentnpm-release, restricted tov*tags. Pages allowsv*release tags andmasterfor documentation-only deployments. Seedocs/resources/contributing.md.
- Keep changes scoped to the task; avoid drive-by refactors.
- Extend existing patterns rather than introducing parallel abstractions.
- For GraphQL types in examples/tests: use
extensions.relationon relationship fields; useextensions.readOnlywhere appropriate. - Keep the root free of backup READMEs and local
.tgz/.zipoutput. Generate temporary archives outside the repository. Archives underdocs/public/are intentional website downloads; check links and checksums before changing them.