Skip to content

Runnable examples, and integration fixtures that cannot be left behind - #62

Merged
jallers merged 5 commits into
masterfrom
claude/examples
Nov 26, 2026
Merged

jallers merged 5 commits into
masterfrom
claude/examples

Conversation

@jallers

@jallers jallers commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Nothing in the published package changes (examples/ is not in files). Head defca1b, with master merged in.

examples/: nine programs, one per task

File Shows Writes?
01-read.ts Typed rows, relations and paths, a page with its total, one asset by OID, me() no
02-write.ts client.send: create, update, an operation, the Outcome, unmatched yes
03-guarded-write.ts client.sendGuarded with the Moment a person saw: a conflict as data and as an error yes
04-batch-undo.ts client.batch.run with preview, confirmation and receipt; batch.reversible yes
05-errors.ts kind on everything thrown; client.explain no
06-attachments.ts Add, list, read back in one request, remove yes
07-testing.ts FakeAgilityClient, no instance no instance
08-custom-transport.ts A Transport of your own (a timed wrapper), checked with transportConformance no; a live read only if an instance is set
09-browser-session.ts Cookie auth for a browser app: credentials, onUnauthorized, and when "retry-write" is the app's to answer no instance (a stand-in server)
  • Each is self-contained (no shared helper, so a file can be copied out and run), imports @versionone/agility-sdk by name as a consumer does, and is run with plain node examples/NN-….ts.
  • One that writes creates its own Stories named sdk-integration example …, deletes them by exact OID in a finally, and refuses to start without V1_EXAMPLES_WRITE=1.
  • 09 replaces fetch with a small stand-in whose session expires on demand, so the re-authentication flow can be run anywhere; it says so at the top, and that in a browser the stand-in is deleted.
  • Kept true two ways. npm run typecheck now compiles examples/ against the source (a paths entry in tsconfig.json maps the package's name to src), so an API change that breaks an example fails in CI on every push. test/integration/examples.test.ts runs each one against an instance and fails on a non-zero exit or a run over thirty seconds.

Integration tier: a fixture left behind fails the suite

Writing the first example showed Stories named sdk-integration batch aliased … on the testing instance: one per run of the tier, 29 in all. Every suite's cleanup sent Delete and ignored the answer, and Agility refuses to delete a closed asset, which is how one batch test left its Story.

  • deleteFixtures(transport, oids) in test/integration/instance.ts deletes by exact OID, reactivates and retries what would not delete, and throws naming anything still there. Every suite's afterAll uses it.
  • The 29 leftovers were deleted by exact OID (matched on the test's exact name pattern; nothing else was touched), and a search afterwards finds none.

AGENTS.md

Now that it is on master: it lists examples/, says how the examples are kept true, and names deleteFixtures in the rule about live calls.

Things a reviewer should know

  • Running a .ts file directly needs Node 22.18 or later; examples/README.md says so. The package itself still supports Node 22.
  • The examples test needs the instance as a URL and a token and a build in dist/; otherwise it skips with the reason in the test's name. The scheduled integration workflow builds during npm ci, so it runs them.

Verification

  • npm run verify on defca1b: 234 unit tests in 30 files, all passing; the type-check includes the nine examples.
  • Full integration tier against the API-testing instance with the strict cleanup: 50 passed, 3 skipped by design, before the examples suite was added. The examples suite afterwards: 10 passed (nine examples and the listing check). Each example ran in under five seconds.
  • A search of the instance after the tier ran finds no sdk-integration fixture of this SDK's.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm

Every suite's cleanup sent Delete and ignored the answer. Agility refuses
to delete a closed asset, so one batch test left its Story behind on every
run. deleteFixtures deletes by exact OID, reactivates and retries what
would not delete, and throws naming anything still there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
Read, write, guarded write, batch with undo, errors, attachments, and
testing with the fake. Each imports the package by name as a consumer
does, cleans up what it creates, and refuses to write without
V1_EXAMPLES_WRITE=1. npm run typecheck compiles them against the source;
the integration tier runs each and fails on a non-zero exit or a slow run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
@jallers
jallers merged commit e50b250 into master Nov 26, 2026
4 checks passed
@jallers
jallers deleted the claude/examples branch November 26, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants