diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..800dd71 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Test + +on: + pull_request: + push: + branches: [main, 'feat/**'] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Supply parity reads the original worker from its pinned commit. + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: npm test + - run: npm run bundle:check + - run: python3 scripts/adr-governance.py + - run: git diff --check diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..b946427 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,50 @@ +# API agent rules + +- Read `README.md`, `worker/index.js`, `worker/pricing.mjs` 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 is not supply cleanup. +- Inventory owns pricing collection, calculations and authoritative maths tests. + The API reads one saved envelope with bounded, basic validation; it does not + execute the model, recompute hashes/examples, validate producer evidence or call + pricing providers. Valid saved prices and saved currency medians never expire; + preserve observation, currency, generation and publication dates separately. + Only pricing accesses pricing storage. Missing or invalid pricing returns 503 + without breaking supply or removing its RPC requests. +- Keep root discovery JSON and thin `llms.txt` on shared descriptions and links. + Distinguish hosted information from client-run network access. Prepared pricing + and discovery additions are not verified public availability. +- Build permission is not permission to deploy, change DNS, create resources, + mutate secrets, incur costs, publish data or accept decisions. Keep credential + values out of source, fixtures and logs; document secret names only. No laptop + deploys or personal credentials. The public hostnames serve the same Worker, + not isolated staging; never use deployment workflows as local verification. +- Follow the approved work packet and the local checks in `README.md`. Run + `python3 scripts/adr-governance.py` before ADR handoff, reporting its documented + limits for uncommitted/new drafts. Local success is not CI evidence; ADR CI + is wired in `.github/workflows/test.yml` but not yet executed. Do not weaken tests or change verification + mechanisms without explicit approval. +- Keep ADRs Proposed until human acceptance. Put build contracts in specs and + sequencing in plans; implementation permission is not acceptance or release. + + + + + + +## 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..c1269bd 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ -# ANT Supply API +# Autonomi API Public supply data for the Autonomi Network Token (ANT), served at **https://api.autonomi.com**. CoinMarketCap and CoinGecko poll the two plain-text endpoints below; anything may read the JSON ones. Runs as a Cloudflare Worker named `api` (`worker/index.js`) in the Autonomi Cloudflare account. **This repository is the source of truth** — see [How this is deployed](#how-this-is-deployed). +Pricing and `/llms.txt` are prepared additions, not verified public availability. +Root JSON and `/llms.txt` use one shared description/link source, carried forward +from the prior pricing draft. They distinguish this hosted information service +from local antd REST/gRPC clients, MCP tools and direct-network clients. No new +upload, retrieval or MCP endpoint is hosted here. + **Stale-over-error:** if the Arbitrum RPC is unavailable, the supply endpoints serve the last good figure (from in-memory or Cache API fallback) with an `X-Stale: true` header instead of a 500 — a slightly stale number beats an error for CMC/CoinGecko. A 500 only occurs if no figure has ever been computed. ## Endpoint contract @@ -15,9 +21,53 @@ Runs as a Cloudflare Worker named `api` (`worker/index.js`) in the Autonomi Clou | `GET /api/total-supply` | `text/plain` | **Bare integer string**, e.g. `1200000000` | | `GET /api/circulating-supply` | `text/plain` | **Bare integer string**, e.g. `342278929` | | `GET /api/supply` | `application/json` | Detailed breakdown (see below) | +| `GET /api/pricing` | `application/json` | Dated Inventory upload-pricing record and diagnostic publication metadata | +| `GET /llms.txt` | `text/plain` | Thin directory of hosted information, local clients and setup links | The two plain-text endpoints return a bare number with no JSON wrapper — this is the format CoinMarketCap and CoinGecko require and **must not change**. All endpoints send `Access-Control-Allow-Origin: *`. Supply endpoints accept `GET`/`OPTIONS` only (405 otherwise, including `HEAD`). +### Dated upload pricing + +`GET /api/pricing` reads binding `PRICING_KV`, key `pricing:v1`, exactly once. +The JSON envelope is `{record, data_revision, payload_sha256, published_at}`. +The record has schema version `1`, kind `upload-pricing-reference` and fixed +calculation version **string** `"2"`. It includes native storage/gas rates, saved +ANT/USD and ETH/USD medians, independent storage/recent-gas/fallback-gas/FX +settings and actual observation windows, gas basis per method, three dated +examples, source dates/URLs, assumptions, exclusions and CLI guidance. + +Inventory owns collection, exact arithmetic and example correctness. The API +checks required shapes, supported model identity/parameters, positive decimal +rates, real ordered dates and settings/window relationships. Unknown extra +fields are ignored. It does not execute the model, reproduce aggregation or +coverage evidence, recompute examples/hashes, query Git or call pricing providers. +The revision (40 hex characters), payload hash (64 hex characters) and publication +date describe publication; they are not observation dates or proof of freshness. + +Valid network prices and saved FX **never expire**. Averaging durations are not +expiry limits. Keep source data-as-of, saved currency window/sample dates, +generation and publication dates distinct. These are historical estimates from +returned observations, not exhaustive network averages, live quotes or guaranteed +prices. Use `ant file cost ` for a file-specific estimate, not a guaranteed +final upload price. Independent windows can change without changing the fixed +billing model; old records keep their own dates, settings and explanations. + +The entire KV lookup/body read is bounded to two seconds and 65,536 UTF-8 bytes. +Missing binding/key, read failure or invalid data returns +`503 {"error":"pricing_unavailable"}` without touching supply providers. +`OPTIONS` returns 204; other methods return +`405 {"error":"method_not_allowed"}` (`HEAD` has no body). Every pricing response +has `Cache-Control: no-store`, CORS `*`, `X-Content-Type-Options: nosniff` and +Allow/CORS methods `GET, OPTIONS`. No pricing cache, TTL or expiry header is added. +Only the pricing path accesses pricing KV; supply and health retain their original +responses, methods, caches, wallet accounting, RPC order and fallback behavior. + +**Not configured for publication:** `wrangler.jsonc` and the deployment workflow +are unchanged. No KV namespace binding/ID, route or secret is added by this work; +without the separately approved binding/data setup pricing returns 503. The two +[API Proposed ADRs](docs/adr/README.md) remain Proposed; local implementation is +not acceptance or release approval. + ### Circulating supply definition `circulating = 1,200,000,000 − Σ(excluded wallet balances)`, read live from the ANT contract on Arbitrum One (`0xa78d8321B20c4Ef90eCd72f2588AA985A4BDb684`) via public RPC endpoints (a fallback list in `worker/index.js`, tried in order because public RPCs rate-limit Cloudflare's shared egress IPs), cached for 60 seconds. Excluded wallets: @@ -50,14 +100,52 @@ Changing this list is a change to the published circulating supply figure — tr - **Config as code.** Worker code, routes, and settings live in this repo (`wrangler.jsonc`). The Cloudflare dashboard is for looking, not editing — dashboard changes are invisible to git and overwritten by the next deploy. - **Deploys run from GitHub Actions** (`.github/workflows/deploy.yml`) on every merge to `main`, using a scoped Cloudflare API token stored as the repo secret `CLOUDFLARE_API_TOKEN`. No laptop deploys, no personal credentials. -- **Staging**: every deploy also serves at https://api.autonomi.workers.dev (note: `workers.dev` sits behind Cloudflare bot protection and may 403 some non-browser user agents; the production hostname is the contract). CI also runs a public-contract test against `api.autonomi.com`, including automation user-agents, so a zone bot-protection change that would block machine clients fails the build. +- **Same service, two hostnames**: https://api.autonomi.workers.dev is the same deployed Worker as https://api.autonomi.com, not an isolated staging service. The existing deployment workflow calls it staging and runs public smoke checks; do not use that workflow or either public host as the local pricing gate. `workers.dev` may 403 some non-browser user agents; the production hostname remains the supply contract. - **Production domain** (`api.autonomi.com`) is declared in `wrangler.jsonc` — enabling/changing it happens via a reviewed commit. ## Secrets None. The Worker reads public RPC endpoints and holds no credentials. If a secret is ever added, set it via `wrangler secret put` / Actions secrets and document its **name only** here. -## Local development +## Local checks and development + +On Node 22, from a checkout containing the original supply commit: + +```bash +node --test tests/pricing.test.mjs tests/supply.test.mjs tests/discovery.test.mjs +npm run bundle:check +git diff --check +``` + +`npm test` runs the same focused tests. Supply tests read the original Worker at +[`b8c5fb5`](https://github.com/WithAutonomi/api/commit/b8c5fb557049d0163b99c29f23708ec02ced7255) +from local Git and compare exact responses, provider requests, cache effects and +errors against this branch under identical injected I/O. They also check that +supply/health source sections are byte-identical. No public provider is contacted. +The pricing fixture is a byte-for-byte copy of the reduced Inventory `pricing.json` +prepared for this rebuild, preserving the real September 8 rates/dates and original +record provenance. Test envelope metadata is synthetic, not publication evidence. +Tests do not replay historical FX medians or duplicate Inventory's maths suite. + +`bundle:check` uses pinned Wrangler **4.127.0** (the existing deployment tooling +version), with metrics disabled, through `versions upload --dry-run`. It only +compiles/checks into ignored `.wrangler/bundle`; it does not upload or deploy. +`npx` may download that tool and its dependencies; no audit-driven upgrades or +runtime dependencies are introduced. Never omit `--dry-run` for validation. + +Ordinary no-publish CI is `.github/workflows/test.yml`, job `test`, on pull requests +and main/feature pushes. It requires no Cloudflare credentials and runs these same +checks. CI on the actual branch is green of record; no branch push or CI result is +claimed by local preparation. The existing deploy/public-smoke workflow is unchanged. + +Root `AGENTS.md` and the pinned `scripts/adr-governance.py` are installed. Run +`python3 scripts/adr-governance.py` for ADR handoff; its committed-diff checks do not +fully validate uncommitted/new drafts (see `docs/adr/README.md`). ADR CI is wired in +`.github/workflows/test.yml` but not yet executed. Integrated clean-context, adversarial and Craft reviews belong +to the Inventory → API → website checkpoint, not a waiver. Implementation is +prepared, not Done. + +Existing interactive development command (not part of the no-publish gate): ```bash npx wrangler dev # local simulator on http://localhost:8787 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..ab6f1f3 --- /dev/null +++ b/docs/adr/ADR-0001-adopt-architecture-decision-records.md @@ -0,0 +1,64 @@ + + + +# ADR-0001: Adopt Architecture Decision Records + +- **Status:** Proposed +- **Date:** 2026-09-14 +- **Decision owners:** Jim Collinson and API maintainers +- **Reviewers:** API maintainers (pending) +- **Supersedes:** none +- **Superseded by:** none +- **Related:** [Pinned team standard](https://github.com/WithAutonomi/adr-standard/tree/27c8ffb5790d99f3f042c68e4e5d4b8fa8bad408); [local guidance](README.md) + +## Context + +Adding pricing requires durable reasoning about authority and public contracts without +losing the existing supply guarantees. + +## Decision Drivers + +- Inspectable decisions, shared conventions and human ownership. + +## Considered Options + +1. Chat and change descriptions: rejected because reasoning scatters. +2. Informal notes: rejected because acceptance remains ambiguous. +3. Pinned team-standard records: chosen without a new dependency. + +## Decision + +Use the local template and numbered ADR filenames. New decisions remain Proposed +until an authorized human accepts them after engineering review; build permission +and passing checks are not acceptance. + +Accepted records are immutable, including status and pointers. A replacement records +`Supersedes:` in its new ADR; never modify the Accepted original. + +ADRs hold decisions, alternatives, consequences and validation. Build contracts belong +in specifications; sequencing belongs in plans. Reuse the pinned minimal mechanics, +not optional tools or deployment workflows. + +## Consequences + +### Positive + +- Reasoning and replacement history remain reviewable. + +### Negative / Trade-offs + +- Human review costs time; automated checks cannot prove approval. + +### Neutral / Operational + +- Adoption changes no runtime contract and remains Proposed. + +## Validation + +Review decision coverage and unchanged Accepted records. Use the installed pinned +validator, respecting its documented limits for uncommitted/new drafts. Local +installation and a local pass do not establish CI enforcement or human acceptance. + +## 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-dated-inventory-pricing-without-supply-changes.md b/docs/adr/ADR-0002-serve-dated-inventory-pricing-without-supply-changes.md new file mode 100644 index 0000000..6858bc0 --- /dev/null +++ b/docs/adr/ADR-0002-serve-dated-inventory-pricing-without-supply-changes.md @@ -0,0 +1,67 @@ + + + +# ADR-0002: Serve dated Inventory pricing without supply changes + +- **Status:** Proposed +- **Date:** 2026-09-14 +- **Decision owners:** Jim Collinson and API maintainers +- **Reviewers:** API maintainers (pending) +- **Supersedes:** none +- **Superseded by:** none +- **Related:** [Shared specification (sibling worktree)](../../../pricing-slim-site/planning/pricing-slim-spec.md); [supply baseline](https://github.com/WithAutonomi/api/blob/b8c5fb557049d0163b99c29f23708ec02ced7255/worker/index.js) + +## Context + +Serve dated estimates from returned observations, not guaranteed quotes or exhaustive +network coverage. Inventory owns collection, calculations and authoritative maths tests. + +## Decision Drivers + +- One pricing authority; thin serving; unchanged supply. + +## Considered Options + +1. Request-time collection/calculation: duplicates Inventory and provider failures. +2. Separate service: unnecessary operational overhead. +3. Isolated reader in the existing Worker: chosen. + +## Decision + +`/api/pricing` reads one Inventory-published record envelope from KV, a key-value store. +The shared specification defines its storage and HTTP contract. Revision, hash and +publication metadata are diagnostic only. + +Apply bounded, basic validation: required shapes, supported calculation, positive rates, +real ordered dates and internally consistent adjustable windows. Ignore unknown fields. +Do not validate producer evidence, recompute hashes/examples, execute the model or call providers. + +Valid saved pricing never expires. Observation, currency, generation and publication dates +stay distinct and unchanged; averaging windows do not impose expiry. Missing or invalid +data makes pricing unavailable, not fabricated. + +Only pricing accesses pricing storage. Preserve every supply behavior, provider/fallback +and the unchanged health response. Root/llms share truthful discovery descriptions. + +## Consequences + +### Positive + +- Independent data updates; failures isolated from supply. + +### Negative / Trade-offs + +- Shared deployment needs regression protection; dated data may be old. + +### Neutral / Operational + +- API trusts Inventory's derivation, not a duplicated evidence system. + +## Validation + +Test indefinite age, changed/mismatched windows, unavailable records, one-key isolation, +zero pricing provider calls, supply/health baseline parity and discovery consistency. + +## 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..3f54e1a --- /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, then the preserved API draft. Template and licensing +notices are unchanged; this README and TOOLING adapt integration notes for this repository. +No third-party package or `.adr-kit.yaml` is required by this baseline. + +The pinned `scripts/adr-governance.py` and root `AGENTS.md` are installed alongside +these documents. ADR CI is wired in `.github/workflows/test.yml` but not yet executed. Uncommitted/new drafts +need manual review as explained below; a local pass is not full draft validation or CI evidence. +The unchanged NOTICE describes the source kit, not the subset installed in this worktree. + +## 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 `python3 scripts/adr-governance.py`. With a usable base it checks + Accepted records changed against that base, subject to the limits below. +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.