docs/REPOSITORY.md

Repository guide

This guide covers contributor setup, the code map and checks

Contribution policy is in Contributing. Maintainer access and permission commands are in contribution administration

Quick start

  1. Install the Node.js version recorded in projects/.node-version
  2. Install pnpm through its official installation guide. The workspace's devEngines setting then downloads and switches to the recorded pnpm 12 release automatically
  3. From projects/, run pnpm install --frozen-lockfile
  4. Run pnpm check from the same directory to validate contribution tooling, the SDK, release tooling and website
  5. Find code through the project areas, with public API documentation in SDK source comments and user guides in projects/web/content/guides/

Project areas

LocationPurpose
SDKThe Fluxer-native JavaScript SDK, with the package identity in its manifest
Website (projects/web/)The public website and documentation, combining handwritten guides with a generated public API reference, with its own manifest (projects/web/package.json) and rules (AGENTS.md)
Release toolingChangesets planning, immutable candidates, registry reconciliation and exact-source GitHub announcements
DocumentationRepository Markdown documents, including the public README and this guide
AreaEntry points and ownership
Public APIThe 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 transportClient, 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 processesShard planning assigns guilds to shards. Supervisor manages its child processes and coordinates Identify requests, global rate-limit pauses and member requests across them
Resource operationsResource-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 failuresAPI errors, input validation, field text and Effect failures own rejection classification, safe metadata, request-only text normalization and cause preservation
Events and gateway requestsEvents, 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 traversalCache 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 workflowsMember search, message search and message cleanup combine operations with bounded work. Permissions and role hierarchy provide checks, not action authorization
Files and transfersMultipart, 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 toolsHelpers, colors, text and builders produce local values. Commands, arguments and help use existing subscriptions, without owning delivery
Diagnostics and timersLogging 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, supply the website's runnable first-bot examples and are the bot files that fluxerly init writes. 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. Every example exports its options as bot and starts only when Node.js runs it. The packed-consumer check compiles the repository examples, requires each bot.js to match its bot.ts and imports each one into createTestBot. 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

FilePurpose
AGENTS.mdRepository-specific instructions for coding agents
projects/package.jsonPrivate workspace root and accepted pnpm major
projects/pnpm-workspace.yamlIncludes the SDK, release tooling and website in one workspace, and holds the security overrides for parents that pin a vulnerable dependency, each with its reason, and the dependency patches in projects/patches that an override needs
projects/pnpm-lock.yamlShared, generated dependency lockfile for the workspace
projects/.node-versionOne development Node.js version source
.gitattributesShared Git text and line-ending rules
.github/CODEOWNERSReview ownership for the repository, workflows and release tooling
SECURITY.mdSupported versions and private vulnerability reporting
LICENSEApache-2.0 license for the SDK, website code and art, 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

CommandPurpose
pnpm install --frozen-lockfileInstall the recorded dependency graph
pnpm buildCompile the SDK with TypeScript 7 and build its documentation website
pnpm --filter @neontechspace/fluxerly formatFormat SDK source, tests and configuration with Prettier
pnpm --filter @neontechspace/fluxerly format:checkCheck SDK formatting without writing files
pnpm --filter @fluxerly/release formatFormat release tooling source and tests with Prettier
pnpm --filter @fluxerly/release format:checkCheck release tooling formatting without writing files
pnpm format:scriptsFormat shared workspace scripts under projects/scripts/ with Prettier
pnpm format:check:scriptsCheck shared workspace scripts formatting without writing files
pnpm lintLint SDK code and tests, release tooling, workspace scripts and the website's scripts, source and tests with Oxlint, check SDK Effect code with @effect/tsgo, report unused files and exports across the workspace (SDK, website, release tooling and root scripts) with Knip, check spelling with CSpell, verify repository and canonical agent Markdown links with docs-links.mjs, enforce SDK transport-seam network isolation with network-isolation.mjs, and fail on em dashes across repository, SDK, release, script and website files or on SDK failure mappings that bypass the shared mapping helpers. Oxlint warnings do not fail the check
pnpm --filter @neontechspace/fluxerly exec effect-tsgo patch --typescriptShow 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 checkRun every check group except public: Contribution tooling tests, workspace script lint, formatting, unused checks, repository em-dash scans and Markdown link validation, release tooling types, lint, formatting, unused checks and tests, SDK formatting, lint, network isolation, unit tests, build, examples, public-client surface, types and packed consumers, and website lint, unused checks, build, types, tests and search ranking. check.mjs starts each step as soon as the steps it reads from pass, so independent steps run side by side. It prints each result with its time, then the output of every failed step. With CHECK_RESULTS_FILE set, it also writes each result, time and first error line as JSON, which the workflows' job summary action turns into a table of checks with the commands that reproduce failures
node scripts/check.mjs sdk webRun only the named groups of pnpm check: contributions, release, sdk, web, or public for the deployed site, side by side in the same way. The web and public groups expect a built SDK
pnpm verify:deepRun the deeper fuzz, model-based property and chaos suites with 500 cases per target. Set FLUXERLY_FUZZ_SEED and FLUXERLY_MODEL_SEED to replay a seed. The weekly Deep verify workflow runs this command on a fixed schedule
pnpm --filter @neontechspace/fluxerly test:public-contractCheck paired client namespace names, runtime keys, structural parameter/result parity and JSDoc presence
pnpm --filter @neontechspace/fluxerly test:npmCheck npm installation of the packed SDK and required Effect peer
pnpm docs:devBuild the SDK, generate its public reference and start local Astro development
pnpm docs:dev:skip-buildGenerate the public reference from the existing SDK build and start local Astro development, without rebuilding the SDK
pnpm --filter fluxerly-docs test:browserCheck the built website in Chromium on every screen size. Add --quick for a few screens of each kind, or --changed for only the parts and pages that the files changed since HEAD left main can reach, as changed.mjs works them out. --base=<commit> compares with that commit instead of main, as CI does with a pull request's base or the commit a push started from. The full run belongs to the Screens workflow, after each push to main that changes what the website builds from
pnpm --filter fluxerly-docs check:ui --changedDuring website work: Stop at once when the changed files reach nothing on the website, otherwise build the site, then run the Astro type check, the website tests and test:browser --changed side by side. Without --changed, check:ui runs every step in turn and every screen
pnpm --filter fluxerly-docs test:versionsCheck version switching, using made-up releases
node release/upstream.jsCompare the reviewed repository pin with the upstream OpenAPI document, the gateway documentation folder, parameterized rate-limit buckets, individual Fluxer source files whose rules the SDK copies (sourceFacts) and whole Fluxer source folders (sourceTrees, covering the Gleam and Rust gateway, schemas, constants, limits and errors). Each watched folder in sourceTrees or voice is hashed recursively by Git object ID through a single Git tree listing (falling back to folder listings when truncated), so newly added, removed, renamed or edited files under those folders are caught automatically and listed by file name without failing on renames. A release test fails when SDK source cites a Fluxer gateway, schema, constants, limits, errors or voice note file that neither sourceFacts nor sourceTrees covers. The pin also lists the folders inside the repository root and inside Fluxer's three package folders, as folders. A new one whose name mentions a voice term, such as voice, RTC, media or WebTransport, is reported for review without counting as drift, so Fluxer's new voice system shows up within days of appearing, before any watched path can name it. The report keys enum names, bit flags and parameters by value or name, and labels additions gated by a Fluxer experiment. Add --update with the reviewed commit to record it. That also records the sha256 of every docs file the website's endpoint map reads at that commit, as endpointDocs, which the build checks each file against. It then regenerates the REST route types that client.rest.call checks, which node sdk/scripts/rest-routes.js also does alone. That generator reads the OpenAPI document and the endpoint docs files through the shared content-addressed cache in ignored projects/release/.cache/upstream/sha256/ (seeding from any verified legacy projects/web/.cache/fluxer/ copy on read), applies the reviewed corrections, each citing Fluxer source lines, and fails on a correction the new pin makes wrong or unnecessary, or a schema form it cannot type. A contract test fails while the generated file is stale. 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, including the HTTP API objects its events carry, read from the endpoint docs files and checked against their endpointDocs hashes. It then regenerates the raw event's payload types and their runtime list of documented dispatch types offline from that fixture, applying the reviewed corrections, each citing Fluxer source lines, and failing on a correction the new pin makes wrong or unnecessary, which node sdk/scripts/gateway-types.js also does alone, and a contract test fails while either generated file is stale. The fixture generator fails for a documented event without a recipient scope in the scope list, which the SDK keeps because Fluxer's event index no longer lists scopes, and for a listed event that is no longer documented. 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 drift workflow, which runs on Monday, Wednesday and Friday, instead uses --baseline <file> --record <file> --comment <file> to compare with the hashes last reported by a successful scheduled or manual run on the default branch. Each observation records the repository pin its run used, and the pin comes first: The run compares with that observation only while the pin is unchanged, and with the repository pin when the pin has moved since, when the observation records no pin, or when it is unavailable or invalid. The job summary and the posted report name the baseline and why it was chosen. The command keeps a copy of each upstream file in ignored projects/release/.cache/upstream/, named by its Git object ID (alongside sha256/ copies seeded on --update and read by the endpoint map and REST route generator), and downloads a file only when a fresh listing of its folder names an ID it has no copy of. The two fixture generators and the upstream source contract checks read through the same copies and never remove any. The workflow restores and saves that folder, and also retains it for 90 days as the upstream-source artifact of each run. When the cache no longer has the folder, the workflow restores it from the last reported run, whether or not that run's observation becomes the baseline. When the repository pin moves, the posting job automatically closes any open bot-authored "Fluxer upstream changes to review" issue from an older pin. When a watched document changed, a commit touched a watched Fluxer path or a new voice-related folder appeared, it appends the report as a comment on the open issue for the current pin, or opens a fresh issue tagged with the current pin. A listed commit is for review and is not proof of bot impact. The job summary also reports what differs from the repository pin. A red run means the check itself broke, such as a failed read, a missing watched path or a failed post, never that Fluxer changed. The observation is retained only after the post, so a failed run repeats its changes in the next run
pnpm --filter @neontechspace/fluxerly test:upstream:guild-featuresOpt-in current Fluxer toggle-set and cloning-guard source comparison, requiring authenticated gh. No provider requests or mutations
pnpm --filter @neontechspace/fluxerly test:upstream:gatewayOpt-in current Fluxer Gleam and Rust gateway contract comparison (opcodes, close codes, limits, visibility delete shape, reaction debounce and permission counts), requiring authenticated gh. Add -- --pinned to verify against the repository pin. No provider requests or mutations

Formatting runs across the SDK (respecting its .gitignore to exclude build output and local sandbox files), the release tooling JavaScript modules under projects/release/ and the shared workspace scripts under projects/scripts/, all sharing projects/sdk/.prettierrc.json. The website and repository Markdown documents remain outside these formatting commands. Technology choices record the Prettier settings

Use Compatibility reviews for a requested review of Fluxer's source history or the compiler toolchain, beyond the automatic drift checks

Local networking checks use owned loopback fixtures, not Fluxer credentials or live sessions

Local SDK test runs scale dynamically from os.availableParallelism() via concurrency.mjs, staying gentle on 2 to 4 core machines (1 worker on 2 to 3 cores, 2 on 4 cores) and capping multi-core hosts near 65% CPU (up to 16 unit workers). Unit tests run in Vitest worker threads, while test files that start child processes run as a second stage in forked processes with fewer workers so their child processes cannot saturate the host. CI runners use every thread. Explicit VITEST_MAX_WORKERS or FLUXERLY_MAX_CONCURRENCY values override 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. Oxlint rules and the AST check in network-isolation.mjs keep direct network imports and global fetch/WebSocket access inside the transport seam

No offline test can reach a Fluxer host. The SDK, example, packaging, website, release tooling and contribution suites load a guard that refuses such a request before it connects and fails the test even when the code under test catches the error. The live test commands, which talk to Fluxer on purpose, don't load it. Child processes a test starts don't inherit it unless the test passes it on

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 options type that both entry points export under one name to match apart from the default API's 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, full-cache shutdown 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 preparation stages the SDK through package preparation, under the registry publication contract. Use documentation maintenance for generated reference ownership, published versions and deployment. 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. Each job's run summary lists the checks the job ran with their results, then the next action for that result. Its checks input names the steps worth listing, results expands a step that ran check.mjs into one row per check, and details, next, failure, command and reproduce add the rest. A workflow test keeps those step ids real 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