From 68a7e3decfc1bc2e00d48d4c0c77a9200f98d2b9 Mon Sep 17 00:00:00 2001 From: Jim Collinson <13061030+JimCollinson@users.noreply.github.com> Date: Wed, 9 Sep 2026 19:49:14 +0100 Subject: [PATCH 1/4] Add supply preservation checks and pricing contracts --- .github/workflows/ci.yml | 29 ++ .github/workflows/deploy.yml | 12 + AGENTS.md | 43 +++ README.md | 18 + ...001-adopt-architecture-decision-records.md | 73 ++++ ...icing-while-preserving-supply-contracts.md | 85 +++++ docs/adr/LICENSE-APACHE | 190 +++++++++++ docs/adr/LICENSE-MIT | 21 ++ docs/adr/NOTICE | 24 ++ docs/adr/README.md | 76 +++++ docs/adr/TEMPLATE.md | 55 +++ docs/adr/TOOLING.md | 64 ++++ docs/specs/pricing-api.md | 123 +++++++ planning/STATE.md | 27 ++ scripts/adr-governance.py | 130 +++++++ tests/fixtures.mjs | 96 ++++++ tests/helpers.mjs | 143 ++++++++ tests/supply-cache.test.mjs | 322 ++++++++++++++++++ tests/supply-contract.test.mjs | 165 +++++++++ tests/supply-rpc.test.mjs | 226 ++++++++++++ 20 files changed, 1922 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 AGENTS.md create mode 100644 docs/adr/ADR-0001-adopt-architecture-decision-records.md create mode 100644 docs/adr/ADR-0002-serve-inventory-pricing-while-preserving-supply-contracts.md create mode 100644 docs/adr/LICENSE-APACHE create mode 100644 docs/adr/LICENSE-MIT create mode 100644 docs/adr/NOTICE create mode 100644 docs/adr/README.md create mode 100644 docs/adr/TEMPLATE.md create mode 100644 docs/adr/TOOLING.md create mode 100644 docs/specs/pricing-api.md create mode 100644 planning/STATE.md create mode 100644 scripts/adr-governance.py create mode 100644 tests/fixtures.mjs create mode 100644 tests/helpers.mjs create mode 100644 tests/supply-cache.test.mjs create mode 100644 tests/supply-contract.test.mjs create mode 100644 tests/supply-rpc.test.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dcdd274 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: [feat/pricing-publication-v1] + pull_request: + +permissions: + contents: read + +jobs: + checks: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: actions/setup-node@v4 + with: + node-version: '22.22.3' + + - name: Supply preservation tests (offline) + run: node --test tests/*.test.mjs + + - name: Validate ADRs + run: python3 scripts/adr-governance.py diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca8fbf9..b0d9c67 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,6 +11,18 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: '22.22.3' + + - name: Supply preservation tests (offline) + run: node --test tests/*.test.mjs + + - name: Validate ADRs + run: python3 scripts/adr-governance.py - name: Deploy Worker uses: cloudflare/wrangler-action@v3 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e410523 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,43 @@ +# API agent rules + +- Read `README.md`, `worker/index.js`, `wrangler.jsonc` and `docs/adr/` before + changing behavior. The Worker and current endpoint contracts take precedence + over historical Vercel deployment instructions. +- Preserve supply URLs, bare-number responses, detailed JSON types, wallet + accounting, rounding, methods/preflight/errors, CORS, caching, provider fallback, + last-good behavior and health contracts. Pricing work is additive, not supply cleanup. +- Inventory owns pricing data and calculations. The API only validates and serves + the published record. Access pricing storage only on the pricing path; missing + pricing configuration must not break supply. Do not remove supply RPC requests + under the pricing-only prohibition on provider lookups. +- Keep root discovery JSON and thin `llms.txt` on shared descriptions and links. + Verify capability and documentation claims; distinguish hosted information from + client-run network access. Do not advertise unimplemented routes as live. +- Build permission is not permission to deploy, change DNS, create resources, + mutate secrets, incur costs, publish data or accept decisions. Follow the approved + work packet; stop for separate approval at those boundaries. Keep credential + values out of source, test fixtures and logs. Preserve the current rollback arrangement. +- Run `python3 scripts/adr-governance.py` before ADR handoff. CI and tests are + separately reviewed mechanisms, not settings to weaken to obtain a pass. +- Write ADRs in plain language, aiming for 500 words or fewer. Put concrete build + contracts in specs and sequencing in plans. + + + + + + +## Architecture Decision Records + +Before changing architecture, protocols, storage formats, cryptography, network behaviour, public +APIs, data models, or operational invariants, inspect `docs/adr/`. + +If the change creates or alters an architectural decision, draft or update a **Proposed** ADR using +`docs/adr/TEMPLATE.md` and the `ADR-NNNN` filename convention. + +Never edit an Accepted ADR; create a superseding ADR instead. Never mark an ADR Accepted +autonomously: acceptance requires human engineering review and debate. + +During review, check ADR correctness, rejected alternatives, evidence, consequences, and +immutable-Accepted compliance. See `docs/adr/TOOLING.md` for authoring guidance and the review +standard. diff --git a/README.md b/README.md index 133f130..da663c6 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,24 @@ None. The Worker reads public RPC endpoints and holds no credentials. If a secre npx wrangler dev # local simulator on http://localhost:8787 ``` +## Testing + +With Node **22.22.3**, run `node --test tests/*.test.mjs`, then +`python3 scripts/adr-governance.py` for decision-record validation. No dependency +installation is needed for these checks. The tests import the unchanged Worker +with controlled RPC, Cache API and clock fixtures; they make no real network +calls. Fixtures are synthetic, never deployment data. Node's typeless-module +warning is expected with the existing package configuration. + +These are preservation tests, not new supply policy: they record current method, +rounding, provider and stale-cache behavior, including malformed-reply quirks and +cache failures that can still return 500. They exercise the Worker directly, not +Cloudflare's HTTP transport (which may strip a HEAD response body). +`.github/workflows/ci.yml` runs the checks read-only for the pricing feature +branch and pull requests, with no deployment or cloud credentials. The existing +deployment workflow runs the same checks before deploying and retains its live +post-deployment probes; offline tests do not replace those probes. + ## Legacy `/api/*.js` are the original Vercel serverless functions this Worker replaced (identical behaviour, verified byte-for-byte at migration). They are kept for reference until the Vercel project is retired, then removed. diff --git a/docs/adr/ADR-0001-adopt-architecture-decision-records.md b/docs/adr/ADR-0001-adopt-architecture-decision-records.md new file mode 100644 index 0000000..5cc5877 --- /dev/null +++ b/docs/adr/ADR-0001-adopt-architecture-decision-records.md @@ -0,0 +1,73 @@ + + + +# ADR-0001: Adopt Architecture Decision Records + +- **Status:** Proposed +- **Date:** 2026-09-09 +- **Decision owners:** Jim Collinson and API maintainers +- **Reviewers:** API maintainers (review pending) +- **Supersedes:** none +- **Superseded by:** none +- **Related:** [Team ADR standard, pinned source](https://github.com/WithAutonomi/adr-standard/tree/27c8ffb5790d99f3f042c68e4e5d4b8fa8bad408) + +## Context + +This API serves supply contracts used by CoinGecko and CoinMarketCap. Adding pricing +creates decisions about data authority, failure isolation and public interfaces. +The README describes current behavior but does not preserve the reasons and rejected +alternatives behind architectural changes. + +## Decision Drivers + +- Protect established consumer contracts. +- Keep decisions and their evidence inspectable beside the code. +- Preserve human ownership across agent-assisted work. + +## Considered Options + +1. Rely on chat and change descriptions. Rejected: reasoning becomes scattered. +2. Keep informal notes only. Rejected: acceptance and replacement remain ambiguous. +3. Use the pinned team-standard ADR mechanics locally. Chosen: shared conventions + without a new package or governance system. + +## Decision + +Maintain decision records in `docs/adr/` using the local template and numbered +filenames. Architectural changes add or update a Proposed record explaining the +decision, alternatives, consequences and validation. + +New records remain Proposed until an authorized human maintainer accepts them after +engineering review. Agent drafts, branch-build permission and successful checks are +not acceptance. + +Accepted records are immutable. A replacement records `Supersedes:` in the new ADR; +the old record, including its status and supersession fields, is not edited. + +ADRs contain durable decisions, not build specifications or delivery plans. Concrete +contracts and execution details belong in separate linked documents. + +## Consequences + +### Positive + +- Decisions remain reviewable and replacements preserve their history. + +### Negative / Trade-offs + +- Explicit records require maintenance and human review. +- The inherited validator is a best-effort backstop, not proof of human approval. + +### Neutral / Operational + +- Existing documented API contracts remain authoritative; adoption does not change them. + +## Validation + +Run `python3 scripts/adr-governance.py`. Reviewers check decision coverage, rejected +alternatives, evidence and unchanged Accepted records independently of the script's +documented limits in `docs/adr/README.md`. + +## Notes for AI-assisted work + +AI tools may help draft this ADR, but **must not mark it Accepted without human review**. Accepted ADRs are immutable: create a new superseding ADR rather than editing an Accepted ADR. diff --git a/docs/adr/ADR-0002-serve-inventory-pricing-while-preserving-supply-contracts.md b/docs/adr/ADR-0002-serve-inventory-pricing-while-preserving-supply-contracts.md new file mode 100644 index 0000000..94bc56e --- /dev/null +++ b/docs/adr/ADR-0002-serve-inventory-pricing-while-preserving-supply-contracts.md @@ -0,0 +1,85 @@ + + + +# ADR-0002: Serve Inventory pricing while preserving supply contracts + +- **Status:** Proposed +- **Date:** 2026-09-09 +- **Decision owners:** Jim Collinson and API maintainers +- **Reviewers:** API maintainers (review pending) +- **Supersedes:** none +- **Superseded by:** none +- **Related:** [Pricing API specification](../specs/pricing-api.md); [Supply contract baseline](https://github.com/WithAutonomi/api/blob/b8c5fb557049d0163b99c29f23708ec02ced7255/worker/index.js) + +## Context + +The API serves token supply and a JSON directory. Adding indicative pricing must +preserve supply consumers and avoid duplicating Inventory's calculations. + +## Decision Drivers + +- Preserve CoinGecko and CoinMarketCap contracts. +- Keep collection and calculation separate from serving. +- Make pricing failures explicit without affecting supply. +- Explain hosted information and actual network-access interfaces truthfully. + +## Considered Options + +1. Collect or calculate prices on API requests. Rejected: duplicates Inventory and + makes provider failures part of serving. +2. Introduce a separate pricing service. Rejected: adds deployment and routing + maintenance without demonstrated need. +3. Add an isolated published-record reader to the existing Worker. Chosen. + +## Decision + +Inventory owns the pricing record and calculation. `/api/pricing` serves the exact +validated, committed record published by Inventory to Cloudflare KV, a key-value +store. Pricing requests do not contact providers or recalculate prices. Data updates +do not require API code deployments. + +The reader validates record structure, supported versions, revision metadata, +integrity and eligibility before serving. Missing, corrupt, unsupported or expired +native data makes pricing unavailable, not fabricated or indefinitely stale. +Currency-reference expiry is independent: otherwise-valid native data remains +servable with expiry disclosed; dated USD examples must not imply current prices. +Serving and caching never renew observation dates or rewrite the committed record. + +Pricing storage access and failures remain confined to the pricing path. Preserve +existing supply and health contracts: URLs, bodies and types, wallet accounting, +rounding, methods, preflight, errors, browser-access headers, caching and last-good +fallback. Keep supply RPC providers and fallback unchanged. Hosting, DNS and the existing +rollback arrangement are unchanged. + +Root remains JSON with existing keys and links plus verified descriptions and +documentation. Thin `llms.txt` renders the same descriptions and links, not separately +maintained facts or changing values. Explain hosted information is not an +upload/retrieval gateway; link verified client interfaces without advertising planned +services as live. + +Exact storage, HTTP, expiry and validation contracts belong in the specification. + +## Consequences + +### Positive + +- One pricing authority serves multiple consumers without request-time collection. + +### Negative / Trade-offs + +- Pricing and supply share a deployment; regression protection remains essential. +- KV propagation can delay visibility, and unavailable data leaves pricing unavailable. + +### Neutral / Operational + +- Retained pricing is not supply's indefinite last-good fallback policy. + +## Validation + +Compare all supply contracts with the cited baseline. Test pricing-only failures, +absence of provider calls, committed-byte fidelity, version/integrity rejection, +independent expiries, cache limits and root/llms consistency. Verify advertised links. + +## Notes for AI-assisted work + +AI tools may help draft this ADR, but **must not mark it Accepted without human review**. Accepted ADRs are immutable: create a new superseding ADR rather than editing an Accepted ADR. diff --git a/docs/adr/LICENSE-APACHE b/docs/adr/LICENSE-APACHE new file mode 100644 index 0000000..ceb6118 --- /dev/null +++ b/docs/adr/LICENSE-APACHE @@ -0,0 +1,190 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to the Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +Copyright 2024-2025 David Irvine + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/docs/adr/LICENSE-MIT b/docs/adr/LICENSE-MIT new file mode 100644 index 0000000..155356c --- /dev/null +++ b/docs/adr/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2025 David Irvine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docs/adr/NOTICE b/docs/adr/NOTICE new file mode 100644 index 0000000..d0e1091 --- /dev/null +++ b/docs/adr/NOTICE @@ -0,0 +1,24 @@ +adr-standard consumer kit + +Copyright (c) 2024-2025 David Irvine +Copyright (c) 2026 adr-standard contributors + +This consumer kit adapts an ADR governance harness originating in +WithAutonomi/ant-node commit 1e9dc01ffbd896f8c0c453808e87cfd73d688e8c and +reviewed directly in WithAutonomi/adr-workbench commit +88f34671f0bd1992b086ee8216eca2787c71071a. Accepted process authority is +adr-workbench ADR-0003 at commit 3b4463b9074e8bc48cfca755569995a4f26d7ee8. + +Adapted consumer files are AGENT-GUIDANCE.md, docs/adr/README.md, +docs/adr/TEMPLATE.md, docs/adr/TOOLING.md, scripts/adr-governance.py, and +.github/workflows/adr-governance.yml. Modifications add repository-neutral +wording, distribution guidance, and licensing/provenance notices while retaining +the inherited executable gate and consumer-workflow behaviour. + +This notice applies only to the ten-file consumer kit. In the source distribution +it is kit/NOTICE; direct installation places it at docs/adr/NOTICE. It does not +apply to or relicense the consumer repository as a whole. + +The consumer kit is available under the MIT License or Apache License 2.0, at the +recipient's option. See LICENSE-MIT and LICENSE-APACHE in this distribution (or +docs/adr/LICENSE-MIT and docs/adr/LICENSE-APACHE after installation). diff --git a/docs/adr/README.md b/docs/adr/README.md new file mode 100644 index 0000000..0f687e1 --- /dev/null +++ b/docs/adr/README.md @@ -0,0 +1,76 @@ + + + + + +# Architecture Decision Records + +This directory contains Architecture Decision Records (ADRs) for this repository. An ADR captures +a significant decision — its context, the options considered, the choice, and its consequences — +in a short document beside the code it shapes. A record evolves while it is Proposed; once +Accepted it is never rewritten — when a decision changes, a new record supersedes the old one, so +the trail of what was decided, and why, stays legible to people and AI agents alike. + +## Source and local integration + +Mechanics come from [WithAutonomi/adr-standard at +27c8ffb5790d99f3f042c68e4e5d4b8fa8bad408](https://github.com/WithAutonomi/adr-standard/tree/27c8ffb5790d99f3f042c68e4e5d4b8fa8bad408), +using the installed Inventory copy. The template, validator, licensing notices and eligible +agent-guidance fragment are unchanged; this README and TOOLING adapt the integration notes. +No third-party package or `.adr-kit.yaml` is required by this baseline. + +CI integration is maintained separately in this repository's workflows. Consult +`.github/workflows/ci.yml` and `.github/workflows/deploy.yml` for actual events and ordering. +Installing ADR files alone does not establish CI enforcement; no standalone +`adr-governance.yml` is installed here. + +## How this works + +1. Copy [`TEMPLATE.md`](./TEMPLATE.md) to the next `docs/adr/ADR-NNNN-short-title.md`. +2. Keep the status **Proposed** while the decision is developed, discussed, and reviewed. +3. Run the gate: `python3 scripts/adr-governance.py`. With a usable base it checks Accepted + records changed against that base — a best-effort backstop with documented limits. +4. This repository's authorised human accepts or rejects the decision — acceptance is a human + act, never a tool's or an agent's. +5. Never edit an Accepted ADR; create a new superseding ADR instead. + +## Rules + +1. Use `ADR-NNNN-short-title.md` names with four-digit numbers. +2. New ADRs start as **Proposed**. +3. **Accepted** ADRs are immutable. If a decision changes, create a **new** ADR that records + `Supersedes:` the old one; supersession is forward-only and the old Accepted record is not + edited. +4. Architectural changes add or update an ADR before merge. +5. Reviews check correctness, evidence, trade-offs, and compliance—not just presence. +6. Acceptance is a human gate and is never inferred or performed by this tooling. + +The template still carries an old-side `Superseded by:` field that cannot be filled after +acceptance without violating immutability. This baseline records the contradiction and does not +resolve it. + +## Template + +Use [`TEMPLATE.md`](./TEMPLATE.md). + +## Tooling + +See [`TOOLING.md`](./TOOLING.md) for authoring and AI-harness guidance. + +## What the governance gate actually does + +With a usable base, the script validates only the final diff's existing +`docs/adr/ADR-*.md` paths changed against that base; without a base it validates all +discovered ADRs. Duplicate-number checking always considers all discovered ADRs. +Uncommitted edits and untracked new files are not part of that committed diff. + +The gate checks the filename convention, an allowed status value, required sections, duplicate +numbers, and whether a changed file was Accepted at the selected base. It does not enforce lifecycle +transitions, human identity, or supersession. Files outside the fixed `docs/adr/ADR-*.md` discovery +pattern are not validated. Git/base failures can fail open, the canonical directory may be reached +through symlinks, and the gate and workflow can be modified in the same change they inspect. +Duplicate-number detection keys +`ADR-NNNN.md` and `ADR-NNNN-short-title.md` differently, so a bare-numbered file and a titled file +sharing a number can coexist undetected. + +These are known limits of this baseline, not promises of stronger enforcement. diff --git a/docs/adr/TEMPLATE.md b/docs/adr/TEMPLATE.md new file mode 100644 index 0000000..cc6600b --- /dev/null +++ b/docs/adr/TEMPLATE.md @@ -0,0 +1,55 @@ + + + + +# ADR-NNNN: + +- **Status:** Proposed +- **Date:** YYYY-MM-DD +- **Decision owners:** +- **Reviewers:** +- **Supersedes:** +- **Superseded by:** +- **Related:** + +## Context + +What problem, constraint, or architectural tension forced this decision? + +## Decision Drivers + +- +- +- + +## Considered Options + +1.