From 4b694e8a958c6687c68743d8b535e6236da7054f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 12:59:07 +0000 Subject: [PATCH 1/2] AGENTS.md, and the integration tier on a schedule AGENTS.md is the short map for whoever changes the repository next: what to read first (spec 000, CONTRIBUTING, the changelog), where things are, the commands, and the rules that are easy to break (prove it live, nothing private in the tree, a failure never reads as empty, a changelog migration line for every visible change). .github/workflows/integration.yml runs the integration tier weekly and on demand against the API-testing instance, from two repository secrets (SDK_TEST_URL, SDK_TEST_ACCESS_TOKEN). The URL is a secret because an instance's URL is its name; the same value is the allow-list that permits fixtures there. Without the secrets the run says so and passes. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm --- .github/workflows/integration.yml | 60 +++++++++++++++++++++ AGENTS.md | 89 +++++++++++++++++++++++++++++++ CONTRIBUTING.md | 5 ++ 3 files changed, 154 insertions(+) create mode 100644 .github/workflows/integration.yml create mode 100644 AGENTS.md diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..46f22d6 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,60 @@ +name: Integration + +# The integration tier (test/integration, spec 000 section 5) against the +# hosted instance set aside for API testing: weekly, and on demand from the +# Actions tab. CI proper runs the unit tier only; this is what notices that +# the server changed under the SDK. +# +# It needs two repository secrets, set by a maintainer: +# SDK_TEST_URL the testing instance's base URL +# SDK_TEST_ACCESS_TOKEN an access token for a member of that instance +# The URL is a secret because an instance's URL is its name and this +# repository is public (CONTRIBUTING.md); GitHub masks secret values in +# logs. The same value is passed as SDK_TEST_ALLOWED_INSTANCES, which is +# what permits writing fixtures there: any other hosted instance is refused +# by the tests themselves. Without the secrets the run says so and passes. +# +# The tier writes fixtures named "sdk-integration …" and deletes them by +# exact OID. Suites that recycle the app domain run on local instances only +# and skip here. + +on: + schedule: + - cron: "17 4 * * 1" # Mondays 04:17 UTC + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: integration + cancel-in-progress: false + +jobs: + integration: + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + SDK_TEST_URL: ${{ secrets.SDK_TEST_URL }} + SDK_TEST_ACCESS_TOKEN: ${{ secrets.SDK_TEST_ACCESS_TOKEN }} + SDK_TEST_ALLOWED_INSTANCES: ${{ secrets.SDK_TEST_URL }} + steps: + - name: Is a testing instance configured? + id: configured + run: | + if [ -n "$SDK_TEST_URL" ] && [ -n "$SDK_TEST_ACCESS_TOKEN" ]; then + echo "yes=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::No testing instance is configured (secrets SDK_TEST_URL and SDK_TEST_ACCESS_TOKEN); the integration tier did not run." + fi + - uses: actions/checkout@v7 + if: steps.configured.outputs.yes == 'true' + - uses: actions/setup-node@v7 + if: steps.configured.outputs.yes == 'true' + with: + node-version: 24 + cache: npm + - run: npm ci + if: steps.configured.outputs.yes == 'true' + - run: npm run test:integration + if: steps.configured.outputs.yes == 'true' diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..7247666 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,89 @@ +# AGENTS.md + +For a coding agent (or a person) about to change this repository. It says +where things are, what must stay true, and how to check your work. It is +kept short on purpose: the rules live in the documents it points to, and +this file must stay true as they change. If you change how the repository +works, change this file in the same pull request. + +## What this is + +`@versionone/agility-sdk`: a TypeScript client for the Digital.ai Agility +(VersionOne) API. No runtime dependencies. Node 22 or later and browsers; +ESM and CommonJS. It is published to npm and this repository is public. + +## Read first + +1. `specs/000-layers.md` — the invariants: the layers and which may import + which, one shape for every object, how rows are translated, the two test + tiers, what is never sent unbounded, one error type. A change to an + invariant changes that file in the same commit. +2. `CONTRIBUTING.md` — what may be committed to a public repository and how + to refer to things (no consumer project, hosted instance, session or + person is ever named in the tree, in a commit message or in a pull + request). +3. `CHANGELOG.md` — what each release changed, each change with the line a + consumer follows to migrate. +4. `README.md` — the public API as a consumer meets it. + +## Where things are + +``` +src/core HTTP transport, errors. Knows nothing about assets. +src/types The model. src/types/assets is GENERATED: never edit by hand. +src/wire One module per endpoint: its envelope and the translation to the model. +src/services What to do with assets: schema, resolve, guard, batch, attachments, fields. +src/client.ts The client: binds the layers. +src/index.ts The package's public exports. +test/unit Runs with nothing. A fake Transport answering what the server answers. +test/integration The same modules against a real instance. Writes fixtures. +scripts Metamodel download, type generation, the integration launcher. +metamodel.json The product's metamodel for one release; the generated types come from it. +``` + +## Commands + +```bash +npm ci +npm run verify # typecheck, build, unit tests. Run before every push. +npm run test:integration # the live tier; skips with a message when no instance is configured +npm run generate:types # after metamodel.json changes +``` + +`npm run verify` includes three structural tests that will fail a careless +change, by design: `layers.test.ts` (imports point down the layer table), +`publicTree.test.ts` (nothing private in the tree) and +`generate-types.test.ts` (the generated types match the metamodel). + +## Rules that are easy to break + +- **Prove it live before you build on it.** The API's real behaviour is not + what its documentation or a plausible fake says. A new claim about the + server gets an integration test, with a control beside every "it + returned rows" that expects zero rows. A unit-test fake sends what the + server sends, copied from a live response with identities replaced. +- **Live calls go only where fixtures may be written**: a local dev + instance, or a hosted instance set aside for API testing and named in + `SDK_TEST_ALLOWED_INSTANCES`. Fixtures are named `sdk-integration …` and + deleted by exact OID by the test that made them. Every query is paged. +- **Nothing private in the tree.** See `CONTRIBUTING.md`. A URL in an + example uses `agility.example.com`. +- **A failure never reads as an empty result**, and no read is unbounded + (spec 000 §6). +- **Everything thrown is an `ApiError` with a `kind`** (spec 000 §7). +- **Names are meta.v1's names** (spec 000 §3): no renaming, no aliases. +- **A change a consumer can see gets a changelog entry with its migration + line.** Until 1.0.0, breaking changes are allowed between alphas and are + listed under "Breaking". + +## Pull requests and releases + +- Branch from `master`, open the pull request against `master`, and say + in it what you verified and how. +- A release is a pull request that bumps `package.json`'s version and + writes the changelog section. A maintainer merges it, pushes the tag + `v` and approves the staged publish (`README.md`, "Releasing"). + Nothing else publishes. +- CI (`.github/workflows/ci.yml`) runs `npm run verify` on the supported + Node lines. The integration tier runs on a schedule and on demand + (`.github/workflows/integration.yml`) against the API-testing instance. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32267b0..87a86d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,6 +8,9 @@ the mechanical parts and `npm run verify` runs it. ## What lives here, and what does not - `src/`, `test/`, `scripts/`: the SDK and what proves it. +- `AGENTS.md`: the short map of the repository for whoever changes it + next, agent or person. Keep it true: a change to how the repository + works changes it in the same pull request. - `specs/`: the invariants of this code (spec 000 and its successors). A spec describes the SDK and the API it talks to, never a consumer, a person, a session or an instance. @@ -69,6 +72,8 @@ and consumers pin commits by SHA), and nothing new is added to it. for API testing and named in `SDK_TEST_ALLOWED_INSTANCES` (comma- separated base URLs), set beside the credential by whoever runs it. Any other hosted URL, and anything named V1Production, is refused. + `.github/workflows/integration.yml` runs the tier weekly and on demand + against the API-testing instance, from two repository secrets. - `metamodel.json` is pulled by `scripts/download-metamodel.mjs`, which strips an instance's own definitions and spells every `href` from `/meta.v1/`, so the committed file is the product's and names no From ba5dd80e7d8c8beffa54b4868615e98a57998f0c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 14:10:48 +0000 Subject: [PATCH 2/2] AGENTS.md: the four import paths and where writes are, as of 1.0.0-alpha.8 Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm --- AGENTS.md | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7247666..3ccc241 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,18 +29,37 @@ ESM and CommonJS. It is published to npm and this repository is public. ## Where things are ``` -src/core HTTP transport, errors. Knows nothing about assets. -src/types The model. src/types/assets is GENERATED: never edit by hand. +src/core HTTP transport, the resend rule, errors. Knows nothing about assets. +src/types The model: assets, queries, commands, outcomes. src/types/assets is GENERATED: never edit by hand. src/wire One module per endpoint: its envelope and the translation to the model. -src/services What to do with assets: schema, resolve, guard, batch, attachments, fields. +src/services What to do with assets: schema, resolve, guard, batch, attachments, fields, explain. src/client.ts The client: binds the layers. -src/index.ts The package's public exports. +src/testing What a consumer's tests import: a fake client and the Transport conformance checks. +src/index.ts The root's public exports. test/unit Runs with nothing. A fake Transport answering what the server answers. test/integration The same modules against a real instance. Writes fixtures. scripts Metamodel download, type generation, the integration launcher. metamodel.json The product's metamodel for one release; the generated types come from it. ``` +## What a consumer imports + +Four paths, and `package.json`'s `exports` lists no others (spec 000 §5a): + +| Path | Holds | +|---|---| +| `@versionone/agility-sdk` | The client, the model, every error class, a few pure helpers. What nearly every consumer needs. | +| `@versionone/agility-sdk/services` | The services as free functions over a `Transport`, for a caller without a client. | +| `@versionone/agility-sdk/wire` | The endpoint modules and their envelopes, for a caller who needs the raw API. | +| `@versionone/agility-sdk/testing` | `FakeAgilityClient` and `transportConformance`. Never imported by `src` outside `src/testing`. | + +A new export goes on the lowest of these that serves it; the root grows +only for something a client user writes or reads. On the client, reads are +`client.query` / `queryPage` / `get`, and writes are `client.send`, +`client.preview` and `client.sendGuarded` (a guarded write compares each +asset's `Moment`; what matched nothing is a conflict, never a success: +spec 000 §6). + ## Commands ```bash @@ -50,10 +69,11 @@ npm run test:integration # the live tier; skips with a message when no instance npm run generate:types # after metamodel.json changes ``` -`npm run verify` includes three structural tests that will fail a careless +`npm run verify` includes structural tests that will fail a careless change, by design: `layers.test.ts` (imports point down the layer table), -`publicTree.test.ts` (nothing private in the tree) and -`generate-types.test.ts` (the generated types match the metamodel). +`publicTree.test.ts` (nothing private in the tree), +`generate-types.test.ts` (the generated types match the metamodel) and +`cjs.test.ts` (every import path loads by `require` and by `import`). ## Rules that are easy to break @@ -72,6 +92,9 @@ change, by design: `layers.test.ts` (imports point down the layer table), (spec 000 §6). - **Everything thrown is an `ApiError` with a `kind`** (spec 000 §7). - **Names are meta.v1's names** (spec 000 §3): no renaming, no aliases. +- **One shape for a row** on every read path (spec 000 §2): a selected + relation is a Ref, a path selected by name is at `row[path]`, nothing + unselected arrives, and a row's identity is `_oid`. - **A change a consumer can see gets a changelog entry with its migration line.** Until 1.0.0, breaking changes are allowed between alphas and are listed under "Breaking".