docs/REPOSITORY.md
Repository guide
This guide covers contributor setup, the code map and checks. The SDK is a prerelease with no stable version yet
Contribution policy is in Contributing. Maintainer access preparation and permission commands are in contribution administration
Quick start
- Install the Node.js version recorded in projects/.node-version
- Install pnpm through its official installation guide. The workspace's
devEnginessetting then downloads and switches to the recorded pnpm 12 release automatically - From projects/, run
pnpm install --frozen-lockfile - Run
pnpm checkfrom the same directory to validate contribution tooling, the SDK, release tooling and website - Find code through the project areas, with public API documentation in SDK source comments and user guides in
projects/web/content/guides/
Project areas
| Location | Purpose |
|---|---|
| SDK | The Fluxer-native JavaScript SDK, with the package identity in its manifest |
Website (projects/web/) | The documentation website, combining handwritten guides with a generated public API reference, and its own manifest (projects/web/package.json) |
| Release tooling | Changesets planning, immutable candidates, registry reconciliation and exact-source GitHub announcements |
| Documentation | Repository Markdown documents, including the public README and this guide |
| Area | Entry points and ownership |
|---|---|
| Public API | The default and Effect entry points re-export the public surface. Client interfaces and their member documentation live in default and Effect API modules, bound once through the operation table. Public resource modules define their types and operation errors. The default testing and Effect testing entry points expose test clients and fixtures, implemented over an in-memory transport in internal/testing/ |
| Client and transport | Client, gateway, REST and instance discovery own lifetime, recovery, admission and endpoint trust. Their parts live in the matching client/, gateway/ and rest/ folders. Transports are the only network seam, and decoders and protocol codes are shared. Rate limits use resource-partition metadata, not fixed provider limits |
| Sharding and processes | Shard planning assigns guilds to shards. Supervisor manages its child processes and coordinates Identify requests, global rate-limit pauses and member requests across them |
| Resource operations | Resource-named modules in internal/ validate requests and project REST/gateway data. Shared REST owns scheduling. Application is bot-token read-only, while OAuth owns explicit token operations with application-owned consent, storage and refresh coordination |
| Validation and failures | API errors, input validation, field text and Effect failures own rejection classification, safe metadata, request-only text normalization and cause preservation |
| Events and gateway requests | Events, presence, counts and member chunks own bounded delivery and cleanup. Gateway requests shares local admission between count and member requests, without retaining rosters or counts |
| Retention and traversal | Cache and resource-specific cache modules control what is kept, resolve conflicting updates and invalidate stale values. Pagination, collectors and reaction collectors limit retained data and clean up after use |
| Resource workflows | Member search, message search and message cleanup combine operations with bounded work. Permissions and role hierarchy provide checks, not action authorization |
| Files and transfers | Multipart, transfer sources, uploads, attachment refresh and response JSON own framing, byte validation, plans and bounded reads. REST owns scheduling, credentials and transfer execution |
| Optional local tools | Helpers, colors, text and builders produce local values. Commands, arguments and help use existing subscriptions, without owning delivery |
| Diagnostics and timers | Logging provides safe diagnostics and opt-in measurements. Logical scheduling manages timers tied to SDK work, separate from host watchdogs and protocol wall time. Scheduled tasks run application work from client.schedule on those timers within the client's lifetime |
Use SDK tests for behavior checks and packed consumers for package-boundary checks.
SDK tests are grouped by area: support/ holds shared fixtures, unit/ local helpers, client/ lifetime, transport, sharding and supervision, resources/ one folder per client namespace, events/ delivery and collectors, logging/ diagnostics, contract/ the public API shape baseline, runtime export inventory, public-client contract, OpenAPI response conformance and gateway documentation field coverage, packaging/ packed and npm consumer checks, perf/ opt-in measurements and live/ sandbox harnesses and their local tests.
The standalone bot examples ship with the package and supply the website's runnable first-bot examples. They use the public SDK runner without companion files. The other folders under examples are repository-only examples that do not ship with the package. The packed-consumer check compiles them and requires each bot.js to match its bot.ts.
The build emits ignored files under projects/sdk/dist/, which must not be edited by hand
For shared error changes, start at REST classification and cause preservation. Operation error constructors live with their public resource types, not only in errors.ts. Message failures have their own module. Use local validation checks, provider rejection checks and combined cleanup failures for their distinct boundaries. For client lifetime changes, network checks cover startup and closure, recovery checks cover retry/resume, and supervisor child failures cover process ownership
The SDK import rule uses package-private #sdk/* aliases across source areas, with short sibling imports kept relative.
The SDK manifest maps these aliases to compiled output by default. TypeScript's NodeNext build resolves that output mapping back to source.
The test compiler configuration and Vitest configuration enable the fluxerly-source condition to select source directly.
Built-process and packed-consumer checks use default resolution, without that condition.
Source-module identity tests guard against accidentally testing stale output. Packed checks verify the shipped mapping, runtime target and public declaration preservation
See technology choices for tooling and support policy, and SDK contracts for cross-cutting implementation constraints
Shared files
The development workspace root is projects/, separate from the repository root. Run shared pnpm commands from that directory
| File | Purpose |
|---|---|
| AGENTS.md | Repository-specific instructions for coding agents |
| projects/package.json | Private workspace root and accepted pnpm major |
| projects/pnpm-workspace.yaml | Includes the SDK, release tooling and website in one workspace |
| projects/pnpm-lock.yaml | Shared, generated dependency lockfile for the workspace |
| projects/.node-version | One development Node.js version source |
| .gitattributes | Shared Git text and line-ending rules |
| .github/CODEOWNERS | Review ownership for the repository, workflows and release tooling |
| SECURITY.md | Supported versions and private vulnerability reporting |
| LICENSE | Apache-2.0 license for the SDK, website code, and authored documentation |
See technology choices for the development Node pin, pnpm selection and update procedure, and consumer support for the separate consumer Node floor and its support policy
Placement and scope
- Keep project-specific dependencies and tooling in the project that uses them
- Keep shared development tooling in projects/, not at the repository root
- Reserve the repository root for repository-wide documents and settings
- Place ignore rules where needed, preferring project scope without adding an ignore file to every internal module
- Add source, test, and output directories when their contents or tooling require them
- Update this guide when project responsibilities or navigation change
The workspace root, website and SDK manifests are private packages. SDK releases publish a separately staged package under the public package identity, following the registry publication contract
Development checks
Run these commands from projects/ using the development Node version
| Command | Purpose |
|---|---|
pnpm install --frozen-lockfile | Install the recorded dependency graph |
pnpm build | Compile the SDK with TypeScript 7 and build its documentation website |
pnpm --filter @neontechspace/fluxerly format | Format SDK source, tests and configuration with Prettier |
pnpm --filter @neontechspace/fluxerly format:check | Check SDK formatting without writing files |
pnpm lint | Lint SDK code and tests, release tooling and website scripts with Oxlint, check SDK Effect code with @effect/tsgo, report unused SDK files and exports with Knip and check spelling with CSpell. Oxlint warnings do not fail the check |
pnpm --filter @neontechspace/fluxerly exec effect-tsgo patch --typescript | Show Effect diagnostics and fixes in an editor that uses the workspace TypeScript 7. It replaces the local compiler, so pnpm build then also prints Effect suggestions. Run the same command with unpatch to restore it |
pnpm check | Check SDK formatting, lint, build, public-client surface, types, runtime and packed consumers, then release tooling types, lint and tests, and website script lint, build, types and tests |
pnpm --filter @neontechspace/fluxerly test:public-contract | Check paired client namespace names, runtime keys, structural parameter/result parity and JSDoc presence |
pnpm --filter @neontechspace/fluxerly test:npm | Check npm installation of the packed SDK and required Effect peer |
pnpm docs:dev | Build the SDK, generate its public reference and start local Astro development |
pnpm docs:dev:skip-build | Generate the public reference from the existing SDK build and start local Astro development, without rebuilding the SDK |
pnpm --filter fluxerly-docs test:browser | Check the rendered development documentation in Chromium |
pnpm --filter fluxerly-docs test:versions | Check Stable history and rolling prerelease documentation using isolated release fixtures |
pnpm --filter fluxerly-docs test:snapshots | Build every imported release snapshot and check its served pages |
node release/upstream.js | Compare the reviewed repository pin with the upstream OpenAPI document, the gateway documentation folder and parameterized rate-limit buckets. The report keys enum names, bit flags and parameters by value or name, and labels additions gated by a Fluxer experiment. Add --update to record a reviewed commit, then run node sdk/scripts/openapi-examples.js to regenerate the OpenAPI example fixture from the new pin. The OpenAPI conformance test fails until the fixture matches the pin, and then decodes every example through the SDK. A rejected example needs an SDK fix, or a server fact with upstream evidence when Fluxer's server cannot send it. Then run node sdk/scripts/gateway-docs.js to regenerate the gateway documentation fixture. The gateway field check fails until it matches the pin, and then requires every documented field of each handled dispatch to be exposed or listed with a reason in its ledger. The daily drift workflow instead uses --baseline <file> --record <file> to compare with the previous run's retained hashes and record the current ones, falling back to the repository pin with a reported reason when the previous observation is unavailable or invalid. It fails only when a watched document changed, not on a new commit alone. A run compared with a previous observation also reports what differs from the repository pin, without failing on it |
pnpm --filter @neontechspace/fluxerly test:upstream:guild-features | Opt-in current Fluxer toggle-set and cloning-guard source comparison, requiring authenticated gh. No provider requests or mutations |
Formatting runs only within the SDK and respects its .gitignore, excluding build output and local sandbox files. The website and repository documents are outside these formatting commands. Technology choices record the Prettier settings
Local networking checks use owned loopback fixtures, not Fluxer credentials or live sessions
Local SDK test runs use half the available threads, at most four, because they share the machine with other work. CI runners use every thread. Test files that start child processes run as a second stage with one worker fewer, so their child processes cannot saturate the host. An explicit VITEST_MAX_WORKERS value sets the limit for local investigation without skipping tests or changing their deadlines
The wire fuzz check sends seeded mutations of valid Fluxer payloads through REST reads and gateway dispatches of both APIs, with a small fixed case count in pnpm check.
For a deeper local run, FLUXERLY_FUZZ_ITERATIONS sets the cases per target and API. A failure names its seed, and FLUXERLY_FUZZ_SEED with at least as many cases replays it, for example FLUXERLY_FUZZ_SEED=7 FLUXERLY_FUZZ_ITERATIONS=3000 pnpm exec vitest run tests/client/wire-fuzz.test.ts --maxWorkers=1 from projects/sdk/
When changing runtime compatibility, run the packed-consumer check on the SDK manifest's engines.node minimum as well as the development runtime.
Use pnpm --filter @neontechspace/fluxerly test:package after building with the development runtime.
The check reports its actual Node version and uses that executable for its isolated consumers.
The npm consumer check runs the exact SDK development-only npm CLI pin on that same Node executable.
It does not depend on npm being bundled with the Node installation or install npm for SDK users
Package and npm checks reuse pnpm's cache but may fetch missing public registry metadata or dependencies for their isolated consumers. A frozen workspace install does not guarantee the metadata needed to resolve a standalone consumer is cached. Dependency installation scripts are disabled for isolated SDK consumers, and the checks remove their own temporary packages after success or failure
The default SDK checks cover the socket transport through the SDK's own gateway tests and check that the built SDK lets the process exit naturally. Lint rules keep network access inside the transport seam
The public-client contract compares every paired default/native surface, including clients, returned handles, namespaces and helper values, with one strict type comparator after normalizing the default signal option, local lookups and result wrappers. Explicit exceptions cover API-specific callback and lifetime contracts. It also checks member names, direct runtime keys and paired comments. A mutation fixture runs the same comparator and verifies that a dropped optional option, a dropped result field and a dropped parameter fail. The binder check uses the same comparator for members derived from the operation table. It does not establish behavioral parity, assess comment accuracy, or cover every standalone client or type-only export
The semantic baseline records, for both public entry points, every Client, OAuthClient and WebhookClient member and namespace operation read from source, with operation signatures, union variants, field types, optionality and nullability.
The baseline test also requires each Default*Options type to match its native options type apart from an optional signal.
After reviewing an intentional public shape change, update the baseline from the SDK directory with pnpm exec vitest run tests/contract/conformance-fields-inventory.test.ts -u and review the generated diff.
The runtime export inventory checks the exact value exports of each public entry point, from source and from the packed package
The upstream guild-feature check pins one current Fluxer commit per run and fails on changed values or unrecognized source structure. It detects source changes but does not verify hosted behavior. The live feature-toggle check verifies changes and restoration against the hosted service
Run pnpm --filter @neontechspace/fluxerly test:rest:queue to compare JSON queue-byte budgets through both built APIs.
The benchmark uses isolated processes and controlled HTTP responses. It varies only the public rest.queuedJsonMaxBytes client option.
It reports rejection, timeout, latency and process-memory observations. It does not measure hosted service limits or select a default automatically
After building the SDK, run pnpm --filter @neontechspace/fluxerly exec node tests/perf/performance-logging.js for logging-overhead measurements, or pnpm --filter @neontechspace/fluxerly exec node tests/perf/performance-local.js for cold import/client lifecycle, cache-workload and retention measurements.
Both are opt-in, use controlled responses without credentials and emit JSON Lines with input hashes, environment, raw samples and descriptive summaries.
Run them serially without concurrent builds or test workers. The optional --smoke flag checks harness correctness with reduced work, not performance.
These measurements are local evidence, not hosted throughput claims or mandatory CI speed thresholds
Live sandbox checks
Opt-in checks against the designated Fluxer sandbox are excluded from pnpm check and CI.
The live check guide covers their setup, authorization levels, outside effects and recovery after a failed run
Release and documentation operations
Use releasing for registry verification, manual workflow inputs and external setup.
Release candidates stage the SDK through package preparation, under the registry publication contract.
Use documentation maintenance for generated reference ownership, published version channels and Preview delivery.
Each workflow job that runs Node, including through the job summary action, first installs Node and pnpm with the pinned upstream pnpm/setup action from projects/, which reads projects/.node-version, so no workflow script runs on the runner image's Node. JavaScript actions such as checkout still run on the Node bundled with the runner.
Jobs that check the SDK's Node floor pass the engines.node minimum from the SDK manifest as runtime instead, and a workflow test keeps those copies equal to the manifest.
The action installs the locked dependencies unless a job that runs only dependency-free scripts disables it.
There is no separate setup-node step.
Action references use full commit SHAs, and a new SHA must be on the repository's Actions allowlist before a workflow can run, as described in technology choices