diff --git a/AGENTS.md b/AGENTS.md index a49ae6d..e5021bd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,7 +52,7 @@ pnpm install --frozen-lockfile pnpm check ``` -Use `pnpm exec vitest run ` for a focused existing test. Run `pnpm check:architecture`, `pnpm build` and `pnpm verify:dist` as needed; run `pnpm verify:package` when the packed-consumer gate is implemented. Check the manifest for available scripts. Report checks you could not run; packed-consumer verification belongs to release-candidate work. +Use `pnpm exec vitest run ` for focused tests. Run `pnpm check:architecture`, `pnpm build` and `pnpm verify:dist` as needed. `pnpm verify:package` checks the built archive and independent consumers; `pnpm check` includes it. Report checks you could not run. - Add positive, negative and boundary tests for every behavior change. Use independently derived golden vectors, seeded permutation/duplicate properties, advance/rebuild equivalence, calendar fold/gap/leap-day cases, correction/deletion replay, eligibility separation, ranking ties and resource-limit tests as relevant. - Use synthetic fixtures and private-data canaries, never actual learner records, credentials or restricted product material. Keep tests reproducible; do not weaken assertions, skip cases or relax architecture guards to obtain a pass. @@ -62,5 +62,5 @@ Use `pnpm exec vitest run ` for a focused existing test. Run `pnpm ch - Prioritize nondeterminism, incorrect time arithmetic, invalid lifecycle acceptance, deleted-history resurrection, practice-to-credit leakage, policy/prefix mismatch, resource-bound bypasses, unsafe diagnostics, dependency violations and weakened gates. Include file/line, triggering condition, impact and a testable correction. - PRs must identify the ticket where applicable, requirement coverage, changes, tests and outstanding limitations. Do not mark tickets complete without required review, merge and acceptance evidence. -- The maintainer has authorized publishable manifest metadata for the first candidate. Keep publication separately gated; a public manifest is not permission to publish. Preserve Apache-2.0 and copyright notices. Verify ownership and contributor rights before release. RV-I04 requires the exact packed ESM/types artifact, explicit archive/export allowlists, and independent offline Node/TypeScript and browser consumers. Host integration and registry publication are separate gates. +- Obtain maintainer approval for each publication. Preserve Apache-2.0 and copyright notices, and verify source and contributor rights. Follow [release policy](docs/releasing.md): check the exact ESM/types archive, explicit archive/export allowlists and independent offline Node/TypeScript and browser consumers. Host integration requires separate acceptance. - No merge, tag, publication, deployment, maintainer signing, relicensing or repository ownership/visibility change without explicit maintainer authorization. diff --git a/CHANGELOG.md b/CHANGELOG.md index b28255a..83dec50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ # Changelog -Notable changes to Retention are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the planned package uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +Notable changes to Retention are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the package uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.0.1] - 2026-11-29 + ### Added - Repository development instructions, contribution and security policies, issue and pull request templates. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d0a8c6..d95f264 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -Retention welcomes reproducible bug reports, documentation corrections and technical proposals. Discuss public contract or architecture changes before implementation. Follow the [security policy](SECURITY.md) for confidential reports. +Retention welcomes reproducible bug reports, documentation corrections and technical proposals. Open an issue before changing a public contract or the architecture. Follow the [security policy](SECURITY.md) for confidential reports. ## Development @@ -12,11 +12,11 @@ pnpm install --frozen-lockfile pnpm check ``` -Use a focused branch and add reproducible positive, negative and boundary tests. The check runs architecture, TypeScript, Biome, Vitest and distribution verification. See [development](docs/development.md) and [repository instructions](AGENTS.md). +Use a focused branch and add reproducible positive, negative and boundary tests. The check covers architecture, TypeScript, Biome, Vitest, the build and independent packed consumers. See [development](docs/development.md) and [repository instructions](AGENTS.md). ## Pull requests -Explain the change and link the relevant issue or ticket. Record the requirements covered, tested commit, checks and anything you could not run. Use synthetic data and preserve the independent deterministic core. Contract changes require maintainer approval. +Explain the change and link the relevant issue. Record the tested commit, checks and anything you could not run. Use synthetic learner data and keep private material out of public changes. Preserve the independent, deterministic core and its zero runtime dependencies. Contract changes require maintainer approval. ## Source rights diff --git a/README.md b/README.md index 9fc7317..cf33228 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,24 @@ # Retention -[![CI](https://github.com/0xbuffdev/retention/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/0xbuffdev/retention/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/0xbuffdev/retention/blob/main/LICENSE) +[![CI](https://github.com/0xbuffdev/retention/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/0xbuffdev/retention/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/%400xbuff%2Fretention)](https://www.npmjs.com/package/@0xbuff/retention) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/0xbuffdev/retention/blob/main/LICENSE) [![Node.js](https://img.shields.io/badge/node-%3E%3D24-blue)](https://github.com/0xbuffdev/retention/blob/main/package.json) -Retention is a review-scheduling engine for learning applications. It uses past learning observations and a review policy to decide what is due, when to revisit it and when to recommend further practice. +Retention is a review-scheduling engine for learning applications. It uses a review policy and a history of learning observations to calculate when concepts are due for review, when learners need more practice and which reviews to prioritize. -Use it in a flashcard app, to revisit mathematical concepts or to reinforce programming skills. Retention works without a server, database, model provider or account. Applications retain ownership of their learning records and assessment decisions. - -Retention has no runtime dependencies. The first release candidate is `@0xbuff/retention@0.0.1`. Registry publication is subject to maintainer approval. +Use it in flashcard apps or learning tools for mathematics and programming. Retention works offline, has no runtime dependencies and gives the same result for the same policy, history and clock. Applications own the learning records and any official assessment decisions. ## Installation -Use Node.js 24 or later and ESM. After publication, install from npm: +Retention requires Node.js 24 or later and ESM. Browser applications can use the ESM entry with an ES2022-compatible environment. ```sh -npm install @0xbuff/retention@0.0.1 +npm install @0xbuff/retention ``` -Before publication, install the verified candidate tarball with `npm install /path/to/0xbuff-retention-0.0.1.tgz`. +Pin the version you have tested when deploying an application. ## Quick start -Schedule a flashcard from a successful practice observation. Supply your own policy and clock; the example uses a fixed clock one day after the observation. +Schedule a review for a successfully recalled concept. This example uses elapsed days and evaluates the history one day after the observation. ```ts import { @@ -69,116 +67,66 @@ if (!due.ok || due.value[0]?.dueAtMs !== day) { console.log(due.value); ``` -The recommendation is due exactly one day after the observation. The application can present the queue without granting credit or changing the learner's official records. - -## How it works - -Suppose a learner successfully recalls a concept on Monday. A review policy can schedule the next attempt for Tuesday, then increase the interval after each successful review. If the learner struggles, the policy can schedule an earlier retry or recommend additional practice. - -For example, with intervals of 1, 3, 7, 16 and 35 elapsed days, a learner who passes each review when due follows this schedule: - -| Retrieval succeeds on | Next review | -| --------------------- | ----------------------------------------- | -| Day 0 | Day 1 | -| Day 1 | Day 4 | -| Day 4 | Day 11 | -| Day 11 | Day 27 | -| Day 27 | Day 62 | -| Day 62 | After the configured maintenance interval | - -Practicing early does not advance an existing interval. A missed review follows the configured retry, restart and support rules. Choose intervals and maintenance rules appropriate to the material. This example is not a universal learning standard. +The concept is due one day after the observation. The application can present the returned queue to the learner. -## Capabilities +## Features -- Configurable spaced retrieval, retry intervals and maintenance reviews. -- Support recommendations and delayed retrieval probes. -- Due-review ranking across concepts, with optional priority weights and relationships. -- Elapsed-time or local-calendar scheduling using explicit timezone rules. -- Replay of duplicated, reordered, corrected, revoked or deleted observations. +- Configurable review intervals, retries, maintenance and support recommendations. +- Delayed retrieval probes and deterministic due-review ranking. +- Elapsed-time or local-calendar scheduling with explicit timezone rules. +- History replay with duplicate detection, corrections, revocations and deletion controls. - Optional advisory readiness based on independently admitted evidence. -Given the same validated history, policy, algorithm revision and clock, Retention produces the same result. Retention does not inspect answers, authenticate learners, issue grades, certify mastery or deliver notifications. - ## Architecture -The application records practice, supplies a policy and calls Retention with an explicit clock. Retention reconciles the history and calculates review projections. The application decides how to present and store the results. - ```mermaid flowchart LR H["History, policy, clock"] --> R["Reconcile"] - R --> S["Schedule and rank"] + R --> P["Practice schedule"] R --> C["Optional readiness"] - S --> A["Application"] - C --> A -``` - -### Replay - -Review histories can arrive out of order. An application may also need to correct a previous result or remove a learner's data. Retention validates the scope, schema and limits, then uses stable event identities and a durable sequence to reconcile corrections, revocations and deletions. It orders surviving observations and excludes future observations before rebuilding the practice and optional candidate projections. Invalid inputs return typed errors. - -```mermaid -flowchart LR - H["Scoped history"] --> V["Validate and deduplicate"] - V --> C["Apply lifecycle controls"] - C --> R["Replay active observations"] + P --> Q["Review result"] + C --> Q + Q --> D["Rank due reviews"] ``` -Identical duplicate events have no effect. Conflicting identities and invalid correction chains produce typed failures. A correction replaces the original observation and contributes no extra success. Deletion controls suppress affected history during replay; the application remains responsible for physical erasure and preventing obsolete histories from returning. - -Full replay is the reference calculation. The advance operation verifies the previous projection identity and complete event prefix before rebuilding. Policy changes require explicit replay. - -### Readiness and evidence - -Practice observations and admitted evidence can influence due dates and support recommendations. Only host-admitted evidence enters the separate advisory readiness calculation under an eligibility policy. +The host supplies the complete history, policy and clock. Retention validates the input, applies lifecycle controls and replays surviving observations. Ranking selects due concepts from the resulting projection. ```mermaid flowchart LR - P["Practice"] --> S["Review schedule"] + P["Practice"] --> S["Practice schedule"] E["Admitted evidence"] --> S - E --> C["Eligible-only readiness"] + E --> C["Candidate readiness"] K["Eligibility policy"] --> C ``` -An eligibility policy might require three fresh successes in at least two sessions over a minimum span of 24 hours. Only qualifying admitted observations start and extend that streak. A local study tool can omit this policy entirely. - -Retention cannot establish whether evidence is authentic. The application admits evidence and makes any official assessment or credit decision independently. - -## API - -| Operation | Purpose | -| ------------------- | ------------------------------------------------------------------------- | -| `validatePolicy` | validate scheduling and optional eligibility policy. | -| `validateEvents` | validate scoped events and detect identity conflicts. | -| `rebuildReview` | Reconstruct review projections from complete history. | -| `advanceReview` | Verify the prior identity and event prefix, then rebuild with new events. | -| `evaluateReadiness` | Calculate advisory readiness from reconciled eligible evidence. | -| `scheduleDue` | Select and rank due concepts. | -| `explainReview` | Return structured reasons for a recommendation. | - -See [due ranking](https://github.com/0xbuffdev/retention/blob/main/docs/priority.md), [policy validation](https://github.com/0xbuffdev/retention/blob/main/docs/policies.md), [event validation](https://github.com/0xbuffdev/retention/blob/main/docs/events.md) and [replay and readiness](https://github.com/0xbuffdev/retention/blob/main/docs/replay.md) for implemented behavior and limitations. - -The [review scheduling specification](https://github.com/0xbuffdev/context/blob/main/repos/retention/specs/0001-review-scheduling.md) defines the event schemas, policy fields, transition rules, resource limits and error behavior. +Only admitted credited evidence can qualify for candidate readiness. Retention cannot authenticate evidence, grant credit or certify mastery. The host handles persistence, authorization, erasure and notifications. See the [architecture guide](https://github.com/0xbuffdev/retention/blob/main/docs/architecture.md). ## Documentation -See the [documentation homepage](https://docs.0xbuff.com/docs/retention) and the repository guides for [API usage](https://github.com/0xbuffdev/retention/blob/main/docs/api.md), [integration](https://github.com/0xbuffdev/retention/blob/main/docs/integration.md) and [release verification](https://github.com/0xbuffdev/retention/blob/main/docs/releasing.md). +| Guide | Contents | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------ | +| [API](https://github.com/0xbuffdev/retention/blob/main/docs/api.md) | Public operations and results | +| [Policies](https://github.com/0xbuffdev/retention/blob/main/docs/policies.md) | Review intervals, time arithmetic and eligibility | +| [Events](https://github.com/0xbuffdev/retention/blob/main/docs/events.md) | Observations, lifecycle controls and validation | +| [Replay](https://github.com/0xbuffdev/retention/blob/main/docs/replay.md) | History reconstruction, readiness and explanations | +| [Due ranking](https://github.com/0xbuffdev/retention/blob/main/docs/priority.md) | Priority weights, concept relations and queue ordering | +| [Integration](https://github.com/0xbuffdev/retention/blob/main/docs/integration.md) | Application responsibilities, failures and privacy | +| [Architecture](https://github.com/0xbuffdev/retention/blob/main/docs/architecture.md) | Module boundaries and data flow | ## Development -Install Node.js 24+ and pnpm 11.2.2, then run: - ```sh +git clone https://github.com/0xbuffdev/retention.git +cd retention corepack enable pnpm install --frozen-lockfile pnpm check ``` -The check covers architecture, TypeScript, Biome, Vitest, distribution verification and independent offline package installation. CI also exercises the packed library in Chromium. See [development](https://github.com/0xbuffdev/retention/blob/main/docs/development.md), [contributing](https://github.com/0xbuffdev/retention/blob/main/CONTRIBUTING.md) and the [security policy](https://github.com/0xbuffdev/retention/blob/main/SECURITY.md). - -See the [source architecture](https://github.com/0xbuffdev/context/blob/main/repos/retention/architecture.md) for the repository layout, module dependencies, build configuration and testing conventions. The [implementation tickets](https://github.com/0xbuffdev/context/blob/main/repos/retention/tickets.md) track progress toward the first release, including independent Node.js and browser consumer checks. +Use Node.js 24 or later and pnpm 11.2.2. The full check covers architecture, typechecking, Biome, tests, the build and independent offline package consumers. CI also tests the installed package in Chromium. -To contribute before the first release, review the [architecture decision](https://github.com/0xbuffdev/context/blob/main/repos/retention/adr/0001-deterministic-scheduling.md) and [implementation plan](https://github.com/0xbuffdev/context/tree/main/repos/retention), then use the repository's [issue tracker](https://github.com/0xbuffdev/retention/issues) for questions or proposed changes. +See the [development guide](https://github.com/0xbuffdev/retention/blob/main/docs/development.md), [contribution guidelines](https://github.com/0xbuffdev/retention/blob/main/CONTRIBUTING.md), [security policy](https://github.com/0xbuffdev/retention/blob/main/SECURITY.md) and [release policy](https://github.com/0xbuffdev/retention/blob/main/docs/releasing.md). Report bugs or propose changes through the [issue tracker](https://github.com/0xbuffdev/retention/issues). ## License -Licensed under [Apache-2.0](LICENSE). See [source rights](https://github.com/0xbuffdev/retention/blob/main/docs/source-rights.md) for provenance and publication requirements. +[Apache-2.0](https://github.com/0xbuffdev/retention/blob/main/LICENSE). See [copyright and attribution](https://github.com/0xbuffdev/retention/blob/main/COPYRIGHT.md). diff --git a/SECURITY.md b/SECURITY.md index a5d3909..f70f919 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,13 +4,13 @@ Report vulnerabilities involving malformed event or policy acceptance, cross-sco ## Supported versions -Retention has no published release yet. Maintainers prioritize reproducible reports against the current source. No fixed response time, backport schedule or bug bounty is promised. +Maintainers prioritize reproducible reports against the latest published version and current source. See [releases](https://github.com/0xbuffdev/retention/releases) for published versions. There is no fixed response time, backport schedule or bug bounty. ## Reporting a vulnerability Use GitHub's [private vulnerability reporting](https://github.com/0xbuffdev/retention/security/advisories/new) if enabled. Otherwise, open a non-sensitive issue requesting a confidential reporting route. Do not publish exploit details, credentials, learner records or protected evidence. -Include the affected commit or version, a minimal synthetic reproduction, what you expected to happen, what happened and the impact. Allow maintainers to investigate before disclosing details publicly. +Include the affected version or commit, a minimal synthetic reproduction, the expected and observed behavior, and the impact. Allow maintainers to investigate before disclosing details publicly. ## Integration responsibilities diff --git a/docs/architecture.md b/docs/architecture.md index e28b381..96bb653 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,28 +1,51 @@ # Architecture -Retention is a standalone review-scheduling engine. The engine takes an explicit policy, clock and bounded history for one scope and returns advisory projections without side effects. Consumers own admission, persistence, authorization and official decisions. +Retention calculates review projections from a policy, a clock and a bounded history for one scope. Its seven public operations are described in the [API guide](api.md). The package root also exports TypeScript contracts. Internal modules are not public entry points. -## Current layout +```mermaid +flowchart LR + H["History, policy, clock"] --> V["Validate"] + V --> R["Reconcile"] + R --> S["Practice schedule"] + R --> C["Optional readiness"] + S --> P["Review result"] + C --> P + P --> D["Due ranking"] + P --> E["Explanation"] +``` -- `src/index.ts`: explicit validation, replay, readiness, ranking and explanation operations and contract types. -- `src/contracts/` and `src/errors.ts`: versioned policy and event shapes and result envelopes. -- `src/validation/`: bounded own-data shape checks, scheduling and eligibility policy validation, and scoped event validation. -- `src/time/`: checked elapsed days and explicit calendar segments, without runtime timezone data. -- `src/events/`: canonical identity, ordering, indexed correction chains and deletion resolution. -- `src/replay/`: full-history reconciliation, canonical watermark, public rebuild, advance and readiness orchestration. -- `src/scheduling/`: practice transitions and interval arithmetic. -- `src/priority/`: due selection, bounded features, relation graph checks and deterministic ranking. -- `src/explanation/`: fixed reason codes and lifecycle explanations. -- `src/readiness/`: internal eligible-only qualification and candidate streak aggregation. -- `tests/unit/` and `tests/fixtures/`: policy, time, event, lifecycle, qualification, identity and export-boundary tests. -- `scripts/`: architecture, distribution and independent packed-consumer checks. -- `tests/consumer/`: independent package consumer fixtures compiled against the installed archive. -- Root configuration and CI: strict TypeScript, Vitest, tsdown, Biome and frozen pnpm dependencies. +Reconciliation validates event identities, applies controls in durable sequence order and sorts surviving observations for replay. The scheduling layer computes due dates and support recommendations. Candidate readiness uses only surviving credited evidence and the optional eligibility policy. Ranking checks a compatible current projection; explanation reads reason codes without rerunning the scheduler. -## Replay and projection layers +## Module boundaries -The internal replay layer validates and reconciles events. Public orchestration calculates practice schedules and eligible-only readiness separately from that result. Due ranking consumes compatible projections. Time arithmetic consumes explicit calendar rules or elapsed milliseconds. Explanations are structured and do not run the scheduler. +| Module | Responsibility | +| ------------------------------------ | --------------------------------------------------------- | +| `src/index.ts` | Explicit public exports | +| `src/contracts/` and `src/errors.ts` | Versioned data shapes and safe diagnostics | +| `src/validation/` | Closed schemas, input bounds and compatibility checks | +| `src/time/` | Checked elapsed and local-calendar arithmetic | +| `src/events/` | Canonical identity, ordering and lifecycle resolution | +| `src/replay/` | Reconciliation, watermark and public replay orchestration | +| `src/scheduling/` | Practice transitions and interval arithmetic | +| `src/readiness/` | Eligible-only qualification and streak aggregation | +| `src/priority/` | Relation validation and deterministic due ranking | +| `src/explanation/` | Fixed reason codes and lifecycle explanations | -Keep lower layers independent of public orchestration and the root entry. No runtime dependencies, hidden clocks, randomness, locale services, network or filesystem. Do not add empty directories or speculative exports. +The core is synchronous and does not mutate caller inputs. Lower layers do not import public orchestration or the root entry. Time arithmetic uses the supplied clock and calendar profile, without reading the environment or system timezone data. The runtime has no external dependencies, filesystem or network access. -The [canonical architecture](https://github.com/0xbuffdev/context/blob/main/repos/retention/architecture.md), [specification](https://github.com/0xbuffdev/context/blob/main/repos/retention/specs/0001-review-scheduling.md) and [tickets](https://github.com/0xbuffdev/context/blob/main/repos/retention/tickets.md) contain the target layout and contract; these planning documents may require organization access. Policy, time, event validation, reconciliation, scheduling, candidate aggregation, public replay, explanations and due ranking are implemented. +## Data and authority + +```mermaid +flowchart LR + H["Host history"] --> R["Reconcile"] + R --> P["Practice and credited observations"] + R --> E["Credited evidence"] + P --> S["Practice projection"] + E --> C["Candidate projection"] +``` + +Practice and admitted evidence both influence the practice schedule. Only credited observations can satisfy the eligibility policy. A candidate result is advisory. The host authenticates evidence and scope, maintains complete history, handles storage and physical erasure, rejects stale generations and makes official decisions. + +## Integration + +Use the [integration guide](integration.md) to connect Retention to an application. See [events](events.md), [policies](policies.md), [replay](replay.md) and [due ranking](priority.md) for the behavior of each operation. The [development guide](development.md) covers the test suites, build and architecture checks. diff --git a/docs/development.md b/docs/development.md index de70a1f..9488eda 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,6 +1,6 @@ # Development -Use Node.js 24+ and pnpm 11.2.2, as pinned in the package manifest. All five development dependencies stay outside the runtime package. +Use Node.js 24 or later, pnpm 11.2.2 and the locked TypeScript toolchain. Runtime dependencies must remain empty. From a clean clone: ```sh corepack enable @@ -18,12 +18,15 @@ pnpm check | `pnpm test:watch` | Watch tests during development. | | `pnpm build` | Build ESM and declarations and verify distribution. | | `pnpm verify:dist` | Check existing distribution and root exports. | +| `pnpm verify:package` | Check the archive and independent installed consumers. | | `pnpm check` | Run quality checks, build and packed consumer verification. | -CI runs the same commands on Ubuntu and Windows. The export-boundary test checks that the entry point exposes only implemented operations. Update its expected export list as approved operations are implemented; do not remove the boundary test. +The quality workflow runs on Ubuntu and Windows. The export-boundary test checks that the entry point exposes only implemented operations. Update the expected export list when maintainers approve an API change. Keep the boundary test. -The source build targets ES2022, with no Node ambient types or DOM APIs. Test and build tools may use Node APIs. The root export map must match emitted files. The build emits only ESM and declarations, without source maps. Do not edit generated distribution files. +The source build targets ES2022 without Node ambient types or DOM APIs. Test and build tools may use Node APIs. The build emits ESM and declarations without source maps. Keep the export map in sync with those files and do not edit generated output. -The build targets ES2022. CI checks Node.js 24 on Ubuntu and Windows, and runs a packed consumer in the installed Chromium browser on Ubuntu. See exact run evidence for browser versions; older Chromium, Firefox and Safari versions have not been established by these checks. +## Installed-package checks -Run `pnpm verify:package` after building to verify the exact tarball and independent offline Node/TypeScript consumer. Set `RETENTION_BROWSER` to a Chromium executable on Linux to exercise the browser consumer too. See [release policy](releasing.md) for evidence and approval gates. +The verifier checks the archive inventory and digest, installs the package offline in a temporary project, compiles a TypeScript consumer and the README quick start, and runs both against the installed package. The Ubuntu CI job also exercises the installed library in Chromium. Consult the release evidence for the tested browser version; older Chromium versions, Firefox and Safari have not been verified by these checks. + +Run `pnpm verify:package` after building to verify the exact tarball and independent offline Node/TypeScript consumer. Set `RETENTION_BROWSER` to a Chromium executable on Linux to exercise the browser consumer too. See the [release policy](releasing.md) for release verification and [contributing](../CONTRIBUTING.md) for proposed changes. diff --git a/docs/events.md b/docs/events.md index 2fb085b..71e9818 100644 --- a/docs/events.md +++ b/docs/events.md @@ -25,7 +25,22 @@ if (result.ok) { } ``` -All six version-one event variants are supported: practice, credited retrieval, correction, revocation, event deletion and scope deletion. Credited observations require complete evidence metadata. A correction contains replacement evidence; controls have no outer session or outcome. Scope deletion has an inclusive cutoff strictly before the control's sequence. +## Event shapes + +Every event requires `schemaVersion: 1`, `kind`, `scopeId`, `eventId`, `sequence` and `atMs`. All variants except scope deletion also require `conceptId`. + +| Kind | Additional fields | +| ------------------------------ | ----------------------------------------------------------------------------------------------- | +| `practice_observation` | `sessionId`, `outcome`; optional `fresh`, `hints`, `ladder` | +| `eligible_credited_retrieval` | Credited evidence, `creditDecisionId`, `decisionVersion: 1` | +| `credited_decision_correction` | `supersedesDecisionId`, `replacementDecisionId`, `decisionVersion`, `replacement`, `reasonCode` | +| `credited_decision_revocation` | `supersedesDecisionId`, `reasonCode` | +| `review_event_deletion` | `targetEventId` | +| `review_scope_deletion` | `throughSequence` | + +Credited evidence requires `sessionId`, `outcome`, `fresh`, `hints`, `ladder` and `eligibilityPolicyVersion`. Practice outcomes are `pass`, `fail` or `not_observed`; credited outcomes are `pass` or `fail`. A correction carries its evidence in `replacement` and uses a decision version of at least 2. Lifecycle reconciliation checks the exact successor version. Controls have no outer session or outcome. Scope deletion has an inclusive cutoff strictly before the control's sequence. + +## Validation and limits The validator accepts plain inert JSON data with closed schemas. It copies records, normalizes negative zero and freezes the result, including replacement data. Identifiers are case-sensitive ASCII with at most 128 characters; reason codes are nonempty strings of at most 256 UTF-16 code units. Sequences are nonnegative safe integers, timestamps are bounded integer milliseconds, and hints and ladder values range from zero to 1000. @@ -37,4 +52,4 @@ Validation does not resolve credit targets or correction chains, apply deletion Neither validation nor reconciliation authenticates evidence or proves history completeness. The host certifies complete relevant history and owns evidence admission, durable sequencing, authorization, storage and physical erasure. Bound serialized inputs before materializing them; the validator is not a sandbox for proxies or hostile JavaScript. -See the [review scheduling specification](https://github.com/0xbuffdev/context/blob/main/repos/retention/specs/0001-review-scheduling.md) for the complete contract. +See [replay](replay.md) for lifecycle behavior and the [API guide](api.md) for the supported operations. diff --git a/docs/releasing.md b/docs/releasing.md index 35e7e35..950b552 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,10 +1,10 @@ -# Release policy +# Releasing Retention -The first candidate is `@0xbuff/retention@0.0.1`. The manifest targets public npm access. No automatic publication workflow is configured. +Retention is published as [`@0xbuff/retention`](https://www.npmjs.com/package/@0xbuff/retention). Releases use Semantic Versioning. Pin tested versions before 1.0.0. Maintainers publish approved archives through npm; CI does not publish automatically. -## Verify the candidate +## Prepare a release -From a clean checkout with Node.js 24 and pnpm 11.2.2: +Update the package version and move the relevant Unreleased changelog entries into a dated section. Review the changes, contributor rights and required notices. From a clean checkout with Node.js 24 and pnpm 11.2.2: ```sh corepack enable @@ -12,14 +12,30 @@ pnpm install --frozen-lockfile pnpm check ``` +## Verify the candidate + The package check packs the built files with npm, checks the exact archive allowlist and integrity, and installs the tarball offline outside the checkout. It compiles and executes a TypeScript consumer and the README quick start against the installed root export. It rejects unexpected files, runtime dependencies, install hooks and external module imports. On Linux with Chromium or Google Chrome installed, set `RETENTION_BROWSER` to the browser executable before running the checks. CI exercises the same installed module in Chromium over a loopback-only HTTP server, with a content security policy blocking external resources. Record the actual browser version. Browser compatibility claims are limited to tested versions. -CI retains the tested tarball and an evidence record (source SHA, archive SHA-256 and SHA-512 integrity, runtime versions, file list and consumer checks). The artifact is the candidate; rebuilding later creates a new candidate requiring verification. +CI retains the tested tarball and `evidence.json` for the exact commit and workflow attempt. The archive must contain seven files: + +- `package.json`, `README.md`, `CHANGELOG.md` +- `LICENSE`, `COPYRIGHT.md` +- `dist/index.js`, `dist/index.d.ts` + +Compare the source SHA, archive SHA-256, npm SHA-512 integrity, byte count, file list and consumer results. Download both CI archives and check that their digests match. Publish the archive that passed these checks. A new build produces another candidate and requires its own verification. ## Release approval -Before accepting a candidate, review all library acceptance cases, the exact source, the package artifact, security and source rights. Record verified runtime versions and limitations. Confirm ownership and contributor rights, license and notices, registry scope access and version availability. The maintainer must authorize publication separately. CI never publishes, tags or signs a release. +Before accepting a candidate, review the changed behavior, applicable acceptance tests, exact source, package contents and security. Record verified runtime versions and limitations. Confirm ownership and contributor rights, license and notices, registry scope access and version availability. Obtain explicit maintainer approval for the source commit, successful CI run and verified archive digest before publishing. CI never publishes, tags or signs a release. + +Applications are responsible for testing admission, authorization, grade invariance, deletion, delivery and stale-generation rejection in their own integrations. + +## Publish and verify + +Publish the approved tarball through an authenticated npm account with public access and scripts disabled. If npm stages the package, inspect the staged version and approve it with the required authentication. Do not rebuild or republish while approval is pending. After publication, compare `npm view @0xbuff/retention@ dist.integrity` with the candidate evidence, then install the exact version in a temporary consumer outside the checkout and import the root API. Keep the verified source commit, artifact digest and registry integrity in the release record. Tag the source of the published artifact, not a subsequent documentation-only commit. + +## Correct a published release -Host admission, authorization, grade invariance, deletion, delivery and stale-generation tests belong to a later integration. +Published versions cannot be overwritten. If a release is defective, notify consumers and publish a reviewed correction. Obtain maintainer approval for deprecation or dist-tag changes. Follow the [security policy](../SECURITY.md) for confidential reports. diff --git a/docs/source-rights.md b/docs/source-rights.md index 75877bb..b78d05b 100644 --- a/docs/source-rights.md +++ b/docs/source-rights.md @@ -1,7 +1,9 @@ # Source rights and licensing -Retention uses Apache-2.0. See [LICENSE](../LICENSE) and [COPYRIGHT.md](../COPYRIGHT.md) for the terms and notices. The maintainer authorized public package metadata for the candidate. Publication and source-rights verification remain separate. +Retention is licensed under Apache-2.0. See [LICENSE](../LICENSE) and [COPYRIGHT.md](../COPYRIGHT.md) for the terms and notices. -Maintainers must verify source ownership, contributor rights and third-party notices before release. Keep provenance records for contributions. Do not import private application code, learner records or protected evidence. +The maintainer [confirmed source and contributor rights and preservation of required notices](https://github.com/0xbuffdev/retention/pull/10#issuecomment-7259756593) for version 0.0.1 on November 29, 2026. + +Maintainers must verify source ownership, contributor rights and required third-party notices for each release. Keep provenance records for contributions. Do not import private application code, learner records or protected evidence. See [contributing](../CONTRIBUTING.md) and [releasing](releasing.md).