diff --git a/AGENTS.md b/AGENTS.md index 15417a7..bf6a2ec 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,8 @@ React provider, hook, type, documentation, and package-boundary work. - Documentation structure: `docs/README.md` - Documentation wording and source checks: `docs/style-guide.md` -- Check failures and CI expectations: `docs/project/check-failure-playbook.md` +- Branch and release operations: `docs/project/branch-policy.md`, + `docs/project/release-policy.md`, and `docs/project/release-runbook.md` - Public package overview: `README.md` - Provider and context behavior: `src/components/SocketProvider.tsx` and `src/components/context.ts` @@ -24,7 +25,7 @@ React provider, hook, type, documentation, and package-boundary work. - `docs/README.md` describes the documentation layout. - Agent-readable package context belongs in `docs/agents/` when the issue scope calls for that content. -- Maintainer planning and failure guidance live in `docs/project/`; do not treat +- Maintainer branch and release guidance live in `docs/project/`; do not treat these notes as public package guarantees. - Before changing public docs or examples, read `docs/README.md`, `docs/style-guide.md`, and any referenced source or tests. @@ -55,9 +56,9 @@ Use existing package scripts as executable conventions: - `npm run pack:dry-run` - `npm run prepack` -There is no automated example build script yet. If one is added, route failures -through `docs/project/check-failure-playbook.md` and keep fixes tied to -source-backed documentation or runnable examples. +There is no automated example build script yet. If one is added, keep failures +tied to source-backed documentation or runnable examples and route release +decisions through `docs/project/release-runbook.md`. Do not publish npm releases, rename packages, or move this package into a monorepo unless explicitly requested. diff --git a/docs/README.md b/docs/README.md index 05fd0c9..20d0d43 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,13 +11,12 @@ structure the public docs site exposes. pages, examples, migration notes, and React integration notes. - `docs/agents/`: LLM-readable package context, indexes, and structured metadata. -- `docs/project/`: maintainer-facing planning notes that should not be treated - as public package documentation. Start with - [`docs/project/README.md`](./project/README.md) for the internal-docs index, - then use `docs/project/socket-store-contract-map.md` for cross-package - contract work, `docs/project/store-creation-path.md` for the official store - creation decision, and `docs/project/release-order.md` for cross-repository - release order. +- `docs/project/`: maintainer-facing operations docs that should not be treated + as public package documentation. Use + [`docs/project/README.md`](./project/README.md), then the + [branch policy](./project/branch-policy.md), + [release policy](./project/release-policy.md), and + [release runbook](./project/release-runbook.md). Root files keep their existing roles: `README.md` is the concise package overview, `example/` contains runnable app code, and `src/` is the source of @@ -38,8 +37,8 @@ Public docs explain the supported React adapter contract: provider setup, hook behavior, schema-safe topic usage, subscription cleanup, React rendering expectations, examples, and non-goals. -Project docs may track verification playbooks, release decisions, and planning -context. Do not present project notes as package guarantees. +Project docs may track branch policy, release policy, and release operations. +Do not present project notes as package guarantees. Agent-facing docs should point to public docs, source files, examples, and metadata without duplicating complete API references. @@ -51,16 +50,11 @@ GitHub Pages deploys the VitePress output from `docs/public/` to the `npm run docs:build`, uploads only `docs/public/.vitepress/dist`, and publishes that artifact to . -Maintainer notes in `docs/project/` and local planning notes are outside the -VitePress source tree and are not deployed. If Pages is not enabled for the +Maintainer operations docs in `docs/project/` are outside the VitePress source +tree and are not deployed. If Pages is not enabled for the repository yet, an owner must configure Pages to use GitHub Actions as the source before the workflow can publish. -Use [`docs/project/README.md`](./project/README.md) as the entry point for -internal repository notes. If an accepted process or architecture rule needs a -single long-lived source of truth, record that need there and promote the rule -into a dedicated SPEC instead of repeating it across closeout notes. - To roll back a bad docs deployment, revert the commit that changed the public docs or workflow and let the `Pages` workflow deploy the reverted artifact. If the workflow itself is failing, disable Pages publication in repository settings diff --git a/docs/agents/agent-context.json b/docs/agents/agent-context.json index f5425bd..0e324f1 100644 --- a/docs/agents/agent-context.json +++ b/docs/agents/agent-context.json @@ -20,8 +20,8 @@ "covers": ["provider example", "store-direct example", "Next.js App Router example", "expected message flow"] }, { - "path": "docs/public/agents/index.md", - "covers": ["agent guide", "provider versus store-direct choice", "Next.js Client Component constraints", "socket-store contract links", "MCP docs-query evaluation"] + "path": "docs/agents/examples.md", + "covers": ["agent examples reference", "provider versus store-direct choice", "Next.js Client Component constraints"] }, { "path": "docs/public/nextjs/index.md", @@ -78,10 +78,11 @@ "test-d/", "example/", "docs/style-guide.md", - "docs/project/check-failure-playbook.md" + "docs/project/release-policy.md", + "docs/project/release-runbook.md" ], "examples": [ - { "name": "provider-backed React app", "path": "docs/public/examples/index.md#local-vite-provider-example", "source": "README.md" }, + { "name": "provider-backed React app", "path": "docs/public/examples/index.md#local-vite-app", "source": "README.md" }, { "name": "store-direct hook usage", "path": "docs/public/examples/index.md#react-router-loader-initial-snapshot", "source": "docs/public/guide/index.md" }, { "name": "Next.js App Router client island", "path": "docs/public/examples/index.md#next-js-app-router-client-island", "source": "docs/public/nextjs/index.md" }, { "name": "runnable Vite example", "path": "example/", "source": "example/README.md" } diff --git a/docs/project/README.md b/docs/project/README.md index fa79ea4..0fab5fd 100644 --- a/docs/project/README.md +++ b/docs/project/README.md @@ -1,44 +1,31 @@ -# Project Docs - -`docs/project/` is for maintainer-facing notes that explain repository -decisions, verification workflow, and historical closeout context. These files -are not part of the public package contract. - -## File Guide +--- +title: Project Docs +doc_type: index +status: active +owner: maintainers +applies_to: react-socket-store +last_reviewed: 2026-05-29 +--- -- `socket-store-contract-map.md`: cross-package contract inventory for adapter - work that depends on `socket-store`. -- `store-creation-path.md`: the accepted store creation path for public docs - and examples. -- `release-order.md`: cross-repository release-order guidance for maintainers. -- `check-failure-playbook.md`: how to triage local or CI failures without - weakening checks. -- `documentation-examples-closeout.md`: historical closeout note for the #10 - documentation and runnable examples umbrella. -- `agent-docs-mcp-closeout.md`: historical closeout note for the #13 agent - docs and MCP evaluation umbrella. - -## Keep, Update, Or Retire +# Project Docs -- Keep durable maintainer references such as contract maps, store creation - decisions, release order, and failure playbooks. -- Keep closeout notes only as historical reconciliation records. They should - say which umbrella issue they close and should not be treated as ongoing - policy documents. -- Move user-facing guidance back to `docs/public/`. -- Move agent-oriented package context back to `docs/agents/`. +`docs/project/` contains maintainer-only operations docs. These files are not +part of the public package contract. -## When A SPEC Would Be The Right SSOT +## Current Set -This folder intentionally avoids introducing a full SPEC or ADR system. If the -repository later accepts long-lived process or architecture rules that multiple -project notes must follow, those accepted rules should move into a dedicated -SPEC and these notes should link to it instead of restating them. +- [branch-policy.md](./branch-policy.md): branch families, maintenance branches, and backport + rules. +- [release-policy.md](./release-policy.md): release eligibility, adapter-specific release rules, and + cross-repository order rules. +- [release-runbook.md](./release-runbook.md): the step-by-step release and publish flow. +- [templates/policy-template.md](./templates/policy-template.md): template for future policy docs. +- [templates/runbook-template.md](./templates/runbook-template.md): template for future runbooks. -The clearest current SPEC candidates are: +## Rules -- cross-repository release-order policy -- accepted package-boundary rules between `react-socket-store` and - `socket-store` -- accepted store-creation and adapter-integration conventions once they stop - evolving as issue-by-issue docs work +- Keep this folder limited to active maintainer operations. +- Put supported adapter behavior in `docs/public/`, `docs/agents/`, or the + package root docs. +- Do not keep closeout notes, historical reconciliation docs, or one-off + decision memos here. diff --git a/docs/project/agent-docs-mcp-closeout.md b/docs/project/agent-docs-mcp-closeout.md deleted file mode 100644 index 6dde4bf..0000000 --- a/docs/project/agent-docs-mcp-closeout.md +++ /dev/null @@ -1,52 +0,0 @@ -# Agent Docs And MCP Evaluation Closeout - -This note reconciles umbrella issue #13 against the stacked stabilization PRs. -It is maintainer-facing status, not a public package contract. - -## Status - -Issue #13 is ready to close after the stacked dependency PRs merge in order. -No runtime behavior, package export, or npm release is required for this -closeout branch. - -## Dependency Coverage - -| Area | Covering PR | Status | -| --- | --- | --- | -| Public agent entrypoint | #86 | Ready | -| Structured agent context metadata | #87 | Ready | -| Public agent guide | #88 | Ready | -| socket-store public contract cross-links | #89 | Ready | -| MCP docs-query evaluation decision | #90 | Ready | - -## Acceptance Reconciliation - -- Agents can identify `SocketProvider` as the SPA convenience path from - `llms.txt`, `docs/public/agents/`, `docs/public/guide/`, and - `docs/agents/agent-context.json`. -- Agents can identify store-direct hooks as the recommended path for focused - client islands, data-loader flows, Next.js App Router code, and components - that already own or receive a store. -- Next.js guidance keeps `WebSocket`, `SocketStore`, `SocketProvider`, and - hook usage inside Client Components and limits Server Component handoff to - serializable snapshots. -- Agent-facing entrypoints link to canonical docs, examples, tests, source - files, and `socket-store` public contract docs instead of duplicating detailed - API contracts. -- The MCP decision is documented as a deferred yes/no docs-query evaluation over - existing public docs and metadata, not as runtime package functionality. -- Agent-facing docs explicitly exclude A2A protocol support from this package - scope. - -## Follow-Up - -Issue #59 remains blocked on an owner-confirmed public docs URL/path. Treat that -as separate public docs hosting work, not as a blocker for the #13 umbrella -reconciliation. - -## Future SSOT Need - -If the repository later accepts a durable policy for agent-facing docs, -cross-package agent boundaries, or MCP-as-docs-query evaluation, that accepted -policy should move into a dedicated SPEC instead of remaining only in this -closeout record. diff --git a/docs/project/branch-policy.md b/docs/project/branch-policy.md new file mode 100644 index 0000000..4580af1 --- /dev/null +++ b/docs/project/branch-policy.md @@ -0,0 +1,61 @@ +--- +title: Branch Policy +doc_type: policy +status: active +owner: maintainers +applies_to: react-socket-store +last_reviewed: 2026-05-29 +source_of_truth: docs/project/branch-policy.md +--- + +# Branch Policy + +`react-socket-store` uses trunk-based development. The goal is to keep `main` +close to releasable adapter behavior while allowing short-lived task branches +and, only when necessary, explicit maintenance branches. + +## Branch Roles + +- `main`: the default trunk branch. It should stay release-ready after every + merge. +- `codex/*`, `feature/*`, `fix/*`, and `docs/*`: short-lived work branches for + pull requests. +- `release/.`: protected maintenance branches for patch releases + on an existing minor line. +- `hotfix/*`: emergency fix branches for the currently affected release line. + +Do not introduce a long-lived `dev` branch. + +## Normal Development Flow + +1. Branch from the latest `main`. +2. Keep the change scoped to one issue or pull request purpose. +3. Merge only after CI passes and the adapter still matches the intended public + contract. +4. Delete short-lived branches after merge unless another open pull request is + stacked on them. + +## Maintenance And Backports + +- Create `release/.` only after a released minor line needs + supported patch maintenance. +- Backport only critical bug fixes, security fixes, or release-blocking + compatibility fixes. +- If the same fix also belongs on `main`, land or cherry-pick it there as well. + +## Cleanup Rules + +Automatic cleanup may delete merged, inactive short-lived branches in these +families: + +- `codex/*` +- `feature/*` +- `fix/*` +- `docs/*` + +Automatic cleanup must not delete: + +- `main` +- `release/*` +- active `hotfix/*` +- branches used as the base for an open stacked pull request diff --git a/docs/project/check-failure-playbook.md b/docs/project/check-failure-playbook.md deleted file mode 100644 index 23ecab4..0000000 --- a/docs/project/check-failure-playbook.md +++ /dev/null @@ -1,83 +0,0 @@ -# Check Failure Playbook - -Use this playbook when a local check or CI job fails. Prefer fixing the root -cause over weakening a rule, skipping a test, or narrowing CI coverage. - -## Current Checks - -- `npm run lint`: runs public import checks, ESLint conventions, production - typecheck, and type-level tests. -- `npm run lint:imports`: rejects imports or docs examples from generated - `socket-store/dist/*` paths. -- `npm run lint:eslint`: enforces TypeScript import conventions, unused - variable checks, and React Hooks rules for `src/` and runtime tests. -- `npm run typecheck`: compiles package source with `tsc --noEmit`. -- `npm run type-test`: compiles `test-d/` type assertions. -- `npm test`: runs runtime hook tests with Vitest. -- `npm run build`: emits ESM and CJS package output into `lib/`. -- `npm run docs:build`: builds the public VitePress docs from `docs/public/`. -- `npm run pack:dry-run`: validates package contents without publishing. -- `npm run prepack`: runs lint, tests, and build before packaging. - -CI runs `npm run lint`, `npm test`, `npm run build`, `npm run docs:build`, and -`npm run pack:dry-run` against React 18 and React 19. - -## Failure Response - -Start with the first failing command. Rerun it locally, copy the exact command, -and fix the failing contract at its source. - -- For `lint:imports`, replace deep `socket-store/dist/*` imports or docs - examples with public package-root imports. -- For `lint:eslint`, fix the TypeScript or React Hooks issue. Keep hook - dependency arrays accurate; do not silence `react-hooks/exhaustive-deps` - unless the code is restructured and the reason is documented in code. -- For `typecheck`, fix source types, exported types, or React component - signatures. Do not loosen strict compiler settings to pass one call site. -- For `type-test`, update `test-d/` only when the public type contract changed - intentionally. Otherwise fix the exported type. -- For `npm test`, fix implementation or test setup according to the failing - runtime behavior. Do not delete assertions to preserve existing behavior. -- For `npm run build`, fix source, TypeScript config, or package output paths. - Build failures should not be bypassed with manual `lib/` edits. -- For `docs:build`, fix broken public docs links, VitePress config, or - source-backed documentation in `docs/public/`. -- For `pack:dry-run`, fix `package.json` metadata, `files`, or generated - package output so consumers receive the intended files. - -## Docs Build Failures - -Keep docs build failures tied to source-backed documentation: - -- Fix broken links by pointing to canonical docs, source files, or runnable - examples. -- Remove placeholder pages instead of making empty pages pass. -- Correct unsupported behavior claims using `docs/style-guide.md`. -- Keep public docs distinct from `docs/project/` maintainer notes. - -## Example Failures - -The runnable app currently lives in `example/`, but package CI does not yet run -an example build or dev server. - -When an example check is added or an example fails manually: - -- Fix provider setup, hook usage, or socket-store integration in `example/`. -- Keep examples directly adaptable from source; do not duplicate large example - files into docs. -- Identify whether the failure belongs to `react-socket-store` hook/provider - behavior or core `socket-store` WebSocket behavior. -- If the failure exposes missing automated coverage, add a package check or - test instead of relying only on manual instructions. - -## Unrelated Failures - -If a failure is unrelated to the current change, do not hide it. Report: - -- The command that failed. -- The relevant error summary. -- Why it is unrelated to the current diff. -- Whether the PR is blocked until it is fixed. - -If the unrelated failure blocks CI for the PR, stop and fix it only when the fix -is within the issue scope or explicitly approved. diff --git a/docs/project/documentation-examples-closeout.md b/docs/project/documentation-examples-closeout.md deleted file mode 100644 index a2bc024..0000000 --- a/docs/project/documentation-examples-closeout.md +++ /dev/null @@ -1,48 +0,0 @@ -# Documentation And Runnable Examples Closeout - -This note reconciles umbrella issue #10 against the stacked stabilization PRs. -It is maintainer-facing status, not a public package contract. - -## Status - -Issue #10 is ready to close after the stacked dependency PRs merge in order. -No additional runtime behavior is required in this closeout branch. - -## Dependency Coverage - -| Area | Covering PR | Status | -| --- | --- | --- | -| Runnable local WebSocket example | #77 | Ready | -| Canonical examples index and agent pointer | #78 | Ready | -| Provider guide | #79 | Ready | -| Store-direct hook guide | #72 | Ready | -| Next.js App Router client boundary guide | #71 | Ready | -| Compatibility table and migration notes | #80 | Ready | -| Core package responsibility split | #81 | Ready | - -## Acceptance Reconciliation - -- README and public guides use `SocketStore`, `createMessageHandler`, - `SocketProvider`, `useSocket`, `useListen`, and `useSend` from current public - package entrypoints. -- `docs/public/guide/` documents direct store construction as the current store - creation path and marks `createSocketStore` as unavailable. -- `example/` includes a local WebSocket echo server and documented run commands. -- `docs/public/examples/` lists the canonical provider, store-direct, and - Next.js examples with setup, message flow, cleanup, and copy-paste notes. -- `docs/public/compatibility/` and `docs/public/migration/` distinguish - `react-socket-store` adapter ownership from `socket-store` core ownership. -- `docs:build` is part of the package verification set and CI expectations in - `docs/project/check-failure-playbook.md`. - -## Follow-Up - -Issue #58 tracks public docs snippet verification. Treat that as the remaining -hardening work for executable README and `docs/public` examples, not as a -blocker for the #10 umbrella reconciliation. - -## Future SSOT Need - -If documentation conventions, example-shape requirements, or release-order -dependencies become durable cross-cutting rules, move those accepted rules into -a dedicated SPEC instead of continuing to spread them across closeout notes. diff --git a/docs/project/release-order.md b/docs/project/release-order.md deleted file mode 100644 index 399f61e..0000000 --- a/docs/project/release-order.md +++ /dev/null @@ -1,50 +0,0 @@ -# Cross-Repository Release Order - -This note defines the release order for stabilization work that spans -`socket-store` and `react-socket-store`. It does not define npm publish -automation, provenance, protected environments, or GitHub Release mechanics; -those remain blocked on `socket-store` #57. - -## Required Order - -1. Merge and release the required `socket-store` public contract first. -2. Verify the `socket-store` package is available from npm at the version the - adapter will consume. -3. Update `react-socket-store` to depend on that public `socket-store` version - and consume only package-root exports. -4. Run the adapter checks from `docs/project/check-failure-playbook.md`, - including docs build and package dry run. -5. Release `react-socket-store` only after the public docs name the required - `socket-store` version and migration notes. - -Adapter-only docs, examples, hook tests, and React cleanup fixes may release -without a new `socket-store` release when they do not require new core behavior, -new core types, or a different package dependency range. - -## Migration Note Requirements - -Before any adapter release that raises the required `socket-store` contract, -public migration notes must include: - -- the minimum compatible `socket-store` version -- whether the adapter dependency range changed -- any import changes, especially package-root imports replacing generated - `socket-store/dist/*` paths -- any hook, provider, subscription cleanup, or schema typing changes visible to - React consumers -- any removed or deferred behavior that should not be treated as supported - -If no consumer migration is required, say that explicitly in -`docs/public/migration/` and keep the compatibility table current. - -## Compatibility And Rollback - -The main compatibility risk is publishing `react-socket-store` against core -behavior or public core types that are not yet available from npm. Roll back by -restoring the previous adapter dependency range and examples, then release a -patch after the package contents and docs build pass. - -If a bad core release is published, do not publish a dependent adapter release -until the core package has a corrected npm version. If an adapter release is -already published against a bad core version, follow the guarded release and -deprecation policy once `socket-store` #57 defines it. diff --git a/docs/project/release-policy.md b/docs/project/release-policy.md new file mode 100644 index 0000000..fad6e90 --- /dev/null +++ b/docs/project/release-policy.md @@ -0,0 +1,75 @@ +--- +title: Release Policy +doc_type: policy +status: active +owner: maintainers +applies_to: react-socket-store +last_reviewed: 2026-05-29 +source_of_truth: docs/project/release-policy.md +--- + +# Release Policy + +## Purpose + +Define when `react-socket-store` changes are release-relevant and which adapter +release rules maintainers follow. + +## Rules + +### Stable Branch + +- `main` is the default release branch. +- Every merge to `main` should keep the adapter releasable. +- Do not create long-lived integration branches such as `dev`. + +### Release-Relevant Changes + +Treat these as release-relevant: + +- runtime or type changes under `src/` +- packaging or export changes in `package.json` +- public docs changes that alter supported adapter usage or guarantees +- runnable example changes that alter supported setup or behavior +- dependency-range changes for `socket-store` + +Maintainer-only notes under `docs/project/` are not release-relevant by +themselves. + +### Versioning + +- Use semver. +- Prefer `patch` for compatible bug fixes, packaging fixes, and docs-contract + corrections. +- Prefer `minor` for additive adapter API, new supported React flows, or new + documented integration paths. +- Use `major` for breaking hook, provider, packaging, or migration-contract + changes. + +### Cross-Repository Order + +- If a release depends on a new `socket-store` public contract, release + `socket-store` first. +- Do not publish the adapter until the required `socket-store` version is + available on npm. +- Public migration notes must state the minimum compatible `socket-store` + version whenever the adapter dependency floor changes. + +### Maintenance Branches + +- Create `release/.` only after a shipped minor line needs + supported patch maintenance. +- Backport only critical bug fixes, security fixes, or release-blocking + compatibility fixes. + +### Prereleases + +- Publish stable releases from `main` by default. +- Use prerelease tags only when maintainers intentionally need external testing + of unreleased adapter behavior. + +## Review Questions + +- Does the change alter what adapter consumers can rely on? +- Does the change depend on a `socket-store` version that is not yet published? +- Does the change require migration or compatibility notes? diff --git a/docs/project/release-runbook.md b/docs/project/release-runbook.md new file mode 100644 index 0000000..d839cab --- /dev/null +++ b/docs/project/release-runbook.md @@ -0,0 +1,59 @@ +--- +title: Release Runbook +doc_type: runbook +status: active +owner: maintainers +applies_to: react-socket-store +last_reviewed: 2026-05-29 +source_of_truth: docs/project/release-runbook.md +--- + +# Release Runbook + +## Purpose + +Describe the required steps for cutting and publishing a `react-socket-store` +release. + +## Preconditions + +- The release target is `main` or an approved `release/.` branch. +- If the adapter depends on a new `socket-store` contract, that `socket-store` + version is already published on npm. +- The package version and migration notes match the intended release. + +## Release Flow + +1. Confirm the target branch is clean and ready to release. +2. Verify any required `socket-store` dependency update is already merged and + published. +3. Run the manual `Publish` workflow from the branch being released. +4. Approve the `npm-publish` environment when prompted. +5. Confirm npm, the git tag, and the GitHub Release all show the same version. + +## Required Checks + +Before publish, the branch must pass: + +- `npm ci` +- `npm run lint` +- `npm run test` +- `npm run build` +- `npm run docs:build` +- `npm run pack:dry-run` + +## If A Check Fails + +- Fix the root cause before continuing. +- Rerun the narrow failing command locally first, then the broader release set + as needed. +- Do not weaken checks, skip tests, or rely on local generated output to push a + release through. + +## Publish Notes + +- Publish runs through GitHub Actions, not ad hoc local commands. +- The workflow publishes to npm only when the current package version is not + already published. +- The workflow creates the `v` tag and matching GitHub Release if they + do not already exist. diff --git a/docs/project/socket-store-contract-map.md b/docs/project/socket-store-contract-map.md deleted file mode 100644 index d580769..0000000 --- a/docs/project/socket-store-contract-map.md +++ /dev/null @@ -1,73 +0,0 @@ -# socket-store Contract Map - -This map records which `socket-store` contracts `react-socket-store` relies on -before later API, testing, and documentation work continues. - -## Sources Checked - -- `src/index.ts` -- `src/types.ts` -- `src/components/SocketProvider.tsx` -- `src/components/context.ts` -- `src/components/hooks/` -- `tests/hooks.test.tsx` -- `test-d/hooks.test-d.tsx` -- Installed `socket-store@0.0.2` package root and generated declarations -- Local `socket-store/main` docs at `docs/guide/api.md` - -## Public Core Dependencies - -| Adapter dependency | Current adapter use | Public core mapping | Status | -| --- | --- | --- | --- | -| `SocketStore` | Re-exported from `react-socket-store` root and used by README examples. | Public `socket-store` root export in npm `0.0.2`; generic contract documented on local `socket-store/main`. | Public, but typed contract is stronger on local main than the current npm release. | -| `createMessageHandler` | Re-exported from `react-socket-store` root and used by README examples. | Public `socket-store` root export in npm `0.0.2`; schema-aware handler contract documented on local `socket-store/main`. | Public. | -| `send({ key, data })` | `useSend` and `useSocket` call `store.send({ key, data })`. | Public behavior on `SocketStore`; adapter-facing `SocketStoreSender` exists on local `socket-store/main`. | Public behavior; adapter should import the core adapter type after release ordering is settled. | -| `getState(key)` | `useListen` uses it as the `useSyncExternalStore` snapshot getter. | Public behavior on `SocketStore`; adapter-facing `SocketStoreStateGetter` exists on local `socket-store/main`. | Public behavior; unknown-key runtime behavior still needs adapter tests. | -| `subscribe(key, listener)` | `useListen` subscribes per topic and uses a returned function when present. | npm `0.0.2` declares `void`; local `socket-store/main` documents `Unsubscribe`. | Gap until the adapter depends on a core release with `Unsubscribe`. | -| Topic schema types | `react-socket-store` defines local `SocketSchema`, `TopicKey`, `TopicState`, and `TopicPayload`. | Local `socket-store/main` exports equivalent schema and adapter contract types. | Temporary duplication; align after cross-repository release planning. | -| `onConnect` and `onMessage` | Included in `SocketStoreLike`, but hooks do not call them directly. | Public methods on npm `0.0.2` `SocketStore`; local main treats lifecycle as core-owned. | Adapter surface can likely narrow to send/getState/subscribe once core adapter types are consumed. | - -## Runtime Assumptions - -- Unknown topic keys: React hooks currently assume `getState(key)` and - `subscribe(key, listener)` are valid for the provided key. The npm `0.0.2` - runtime throws by property access for unknown `getState` keys and allows - subscriptions to unknown keys. Local `socket-store/main` documents runtime - unknown-key reads as not guaranteed. Cover this in #30 before documenting a - stronger adapter guarantee. -- Duplicate handler keys: The adapter does not inspect handler arrays. It - assumes `socket-store` owns duplicate-key validation. Local - `socket-store/main` documents duplicate handler keys as constructor errors. -- Send behavior: `useSend` sends the selected topic and payload without runtime - validation. The type relationship is local to `react-socket-store` today. - Local `socket-store/main` exports schema-aware send contracts, but the adapter - should not rely on them until the package dependency is released. -- Subscribe cleanup: `useListen` supports both core shapes by treating a missing - unsubscribe as a no-op cleanup. This preserves compatibility with npm - `0.0.2`, but real cleanup depends on a core contract that returns - `Unsubscribe`. -- Listener timing: `useListen` assumes `subscribe` notifies after state updates - and `getState` returns the latest snapshot. Existing React tests use a fake - store for this behavior; #30 should verify the same behavior against a real - or faithful core store fixture. - -## Gaps And Follow-Ups - -- #29 should confirm there are no deep `socket-store/dist/*` dependencies and - document any temporary internal dependency. Current source imports only the - package root. -- #30 should add adapter contract tests for real core behavior: unknown keys, - duplicate keys, send, subscribe notification, unsubscribe cleanup, and hook - unmount cleanup. -- #31 should turn this map into user-facing responsibility and compatibility - docs once the core release boundary is known. -- #32 should define release order so `react-socket-store` does not publish - against core adapter types or unsubscribe behavior that are unavailable on - npm. - -## Working Rule - -Until #32 resolves the cross-package release order, new adapter code should keep -using the local `SocketStoreLike` surface and public package-root imports only. -Do not import generated `socket-store/dist/*` paths or claim runtime behavior -that is not backed by either current tests or the local core contract docs. diff --git a/docs/project/store-creation-path.md b/docs/project/store-creation-path.md deleted file mode 100644 index fd193a1..0000000 --- a/docs/project/store-creation-path.md +++ /dev/null @@ -1,26 +0,0 @@ -# Store Creation Path - -## Decision - -The official store creation path for `react-socket-store` docs is direct -construction with the public `SocketStore` class: - -```ts -const store = new SocketStore(webSocket, messageHandlers, options); -``` - -`createSocketStore` is not a public export of the current adapter package and -should not be shown as the primary path. - -## Import Guidance - -- Adapter quick starts may import `SocketStore` and `createMessageHandler` from - `react-socket-store` because the adapter root re-exports both public core - helpers. -- Core-only docs may import them from `socket-store`. -- Do not import from generated `socket-store/dist/*` paths. - -## Follow-Up - -If a factory API is added later, it needs its own API issue, tests, and -cross-package release plan before docs present it as supported. diff --git a/docs/project/templates/policy-template.md b/docs/project/templates/policy-template.md new file mode 100644 index 0000000..a3d4c7e --- /dev/null +++ b/docs/project/templates/policy-template.md @@ -0,0 +1,37 @@ +--- +title: Policy Template +doc_type: template +status: active +owner: maintainers +applies_to: react-socket-store +last_reviewed: 2026-05-29 +template_for: policy +--- + +# Policy Title + +## Purpose + +State what decision boundary or maintainer rule this policy defines. + +## Scope + +- State which repository, branch family, workflow, or release line it applies + to. +- State what is explicitly out of scope. + +## Rules + +### Rule Area + +- Write short, enforceable rules. +- Prefer current-tense statements over narrative history. + +### Exceptions + +- Record only real exceptions that maintainers may need to apply. +- State who can approve them when relevant. + +## Review Questions + +- Add 2-4 short questions maintainers can use during review. diff --git a/docs/project/templates/runbook-template.md b/docs/project/templates/runbook-template.md new file mode 100644 index 0000000..37cd065 --- /dev/null +++ b/docs/project/templates/runbook-template.md @@ -0,0 +1,34 @@ +--- +title: Runbook Template +doc_type: template +status: active +owner: maintainers +applies_to: react-socket-store +last_reviewed: 2026-05-29 +template_for: runbook +--- + +# Runbook Title + +## Purpose + +State which maintainer operation this runbook executes. + +## Preconditions + +- List the required branch, workflow, permissions, or prior approvals. + +## Steps + +1. Write the operational sequence in order. +2. Keep each step concrete and verifiable. +3. Link to scripts or workflows only when they are the actual source of + execution. + +## Required Checks + +- List the checks or validations that must pass before completion. + +## Failure Handling + +- State what to stop, rerun, or escalate when a step fails. diff --git a/docs/style-guide.md b/docs/style-guide.md index d0ce6e7..9c52259 100644 --- a/docs/style-guide.md +++ b/docs/style-guide.md @@ -29,20 +29,6 @@ Before documenting a guarantee, inspect the relevant source or tests: - `tests/` and `test-d/` for runtime and type expectations. - `example/` for runnable React setup and cleanup behavior. -## Referencing socket-store - -`react-socket-store` is the React adapter. It should reference `socket-store` -for core WebSocket topic-store behavior instead of restating the full core API. - -- Link to the `socket-store` README or API contract for `SocketStore`, - `createMessageHandler`, protocol adapters, socket lifecycle, and core errors. -- Keep React docs focused on provider setup, hook behavior, render timing, - subscription cleanup, and schema-safe hook typing. -- Do not claim ownership of core protocol parsing, reconnect behavior, - persistence, or server behavior. -- Import examples and type references from public `socket-store` package - entrypoints, not generated `socket-store/dist/*` paths. - ## Examples Examples must be runnable or directly adaptable from runnable files. Include the @@ -66,3 +52,26 @@ Do not describe future docs tooling, protocol adapters, or runtime integrations as available unless shipped source, tests, or runnable examples prove that support. Accepted issues may justify future or deferred wording, not availability claims. + +## Package Boundaries + +`react-socket-store` is the React adapter. It should reference `socket-store` +for core WebSocket topic-store behavior instead of restating the full core API. + +- Link to the `socket-store` README or API contract for `SocketStore`, + `createMessageHandler`, protocol adapters, socket lifecycle, and core errors. +- Keep React docs focused on provider setup, hook behavior, render timing, + subscription cleanup, and schema-safe hook typing. +- Do not claim ownership of core protocol parsing, reconnect behavior, + persistence, or server behavior. +- Import examples and type references from public `socket-store` package + entrypoints, not generated `socket-store/dist/*` paths. + +## Snippet Verification + +Public TypeScript and TSX fences in `README.md` and `docs/public/` are compiled +by `npm run docs:snippets`. + +Use `no-verify` only for explicit pseudocode, signatures, or partial excerpts +that are intentionally not standalone programs. Keep those exceptions rare and +reviewable. diff --git a/llms.txt b/llms.txt index cdb49f3..6c219c5 100644 --- a/llms.txt +++ b/llms.txt @@ -14,8 +14,8 @@ Canonical docs: `docs/public/api/index.md` - Provider, store-direct, and Next.js App Router examples: `docs/public/examples/index.md` -- Agent guide for choosing Provider, store-direct, and Next.js patterns: - `docs/public/agents/index.md` +- Agent-facing examples reference: + `docs/agents/examples.md` - Next.js client-boundary guidance: `docs/public/nextjs/index.md` - Package ownership, compatible socket-store version, and release order: @@ -26,8 +26,6 @@ Canonical docs: `docs/README.md` - Documentation wording rules and source checks: `docs/style-guide.md` -- Agent examples reference: - `docs/agents/examples.md` Source and example entrypoints: