Skip to content

docs: fix root README TS and Go quick-start snippets#594

Merged
ojongerius merged 1 commit into
mainfrom
fix/readme-ts-go-snippets
May 24, 2026
Merged

docs: fix root README TS and Go quick-start snippets#594
ojongerius merged 1 commit into
mainfrom
fix/readme-ts-go-snippets

Conversation

@ojongerius
Copy link
Copy Markdown
Contributor

Summary

Same paper-cut as the Python snippet in #593, applied to the TS and Go quick-start snippets in the root README. Both reference a fictional Receipt class that does not exist in either SDK.

TypeScript — README previously showed:

import { Receipt } from "@agnt-rcpt/sdk-ts";
await Receipt.create(...);
await receipt.sign(privateKey);

@agnt-rcpt/sdk-ts exports createReceipt, signReceipt, generateKeyPair, etc. There is no Receipt symbol — the import fails at module-load time.

Go — README previously showed:

r, _ := receipt.New(receipt.WithAction("tool_call", payload))
signed, _ := r.Sign(privateKey)

sdk/go/receipt provides Create(CreateInput) UnsignedAgentReceipt and the package-level Sign(unsigned, privateKeyPEM, verificationMethod) (AgentReceipt, error). There is no New, no WithAction functional option, and Sign is not a method on a receipt value — it takes three required args.

Both snippets now mirror the Python shape: generate a key pair, build a full Create…Input struct (Issuer / Principal / Action / Outcome / Chain), then sign with a verification method DID.

Verification

  • Go snippet compiles against the in-tree SDK (go build).
  • TS snippet type-checks against the in-tree SDK under tsc --strict.

Follow-up worth tracking

Three identical bugs slipping through three releases is the signal that there's no gate here. Suggest a release-blocking CI job that extracts every fenced code block from README.md (and SDK READMEs) and tries to build/type-check it against the published artifact — same idea as the P0-1 item in the audit synthesis. Happy to open a tracking issue if useful.

Same paper-cut as the Python snippet in #593: the TS and Go quick-start
snippets call non-existent APIs.

- TS: `Receipt.create()` / `receipt.sign()` — no `Receipt` symbol is
  exported from `@agnt-rcpt/sdk-ts`. Real API is `createReceipt({...})`
  and `signReceipt(unsigned, privateKey, verificationMethod)`.
- Go: `receipt.New(receipt.WithAction(...))` / `r.Sign(privateKey)` —
  no `New` constructor or `WithAction` option exists. Real API is
  `receipt.Create(receipt.CreateInput{...})` and the package-level
  `receipt.Sign(unsigned, privateKeyPEM, verificationMethod)`.

Both snippets now mirror the Python shape: generate key pair, build a
full `Create…Input` struct (Issuer / Principal / Action / Outcome /
Chain), then sign with a verification method DID.

Verified by compiling each snippet against the in-tree SDK (Go: `go
build`; TS: `tsc --strict`).
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the root README SDK quick-start snippets so they use the actual Go and TypeScript functional APIs instead of nonexistent Receipt class/method-style APIs.

Changes:

  • Updates the Go snippet to generate a key pair, create a receipt with receipt.Create, and sign with receipt.Sign.
  • Updates the TypeScript snippet to import and use createReceipt, generateKeyPair, and signReceipt.
  • Aligns the examples with the existing Python quick-start shape.

@ojongerius ojongerius merged commit 3de5ef1 into main May 24, 2026
9 checks passed
@ojongerius ojongerius deleted the fix/readme-ts-go-snippets branch May 24, 2026 09:38
ojongerius added a commit that referenced this pull request May 26, 2026
Adds a release-blocking gate that extracts the SDK quick-start snippets from
the user-facing READMEs and compiles / type-checks each one — catching the
recurring papercut (#593, #594) where a snippet calls a non-existent API,
imports a wrong module path, or drifts behind a published rename.

- scripts/readme_snippets/: a dependency-free Python harness. extract.py
  (pure, unit-tested) parses fenced blocks and assembles compilation units;
  check.py scaffolds a throwaway project and runs go build / tsc --noEmit /
  mypy against either the in-tree SDK (--source local) or the published
  artifact (--source published).
- Default-in: every SDK-importing fenced block is checked, so a newly added
  snippet is covered without annotation. snippet-check directives (continues,
  skip) handle dependent and illustrative blocks.
- readme-snippets.yml runs the in-tree check on every README-touching PR;
  the publish-* workflows run the published check at release time.

Fixes drift the gate caught:
- sdk/go/README.md used the stale module path github.com/agent-receipts/sdk-go
  instead of github.com/agent-receipts/ar/sdk/go (install + imports).
- Root README Python quick-start passed action as a dict where
  CreateReceiptInput expects ActionInput; now uses ActionInput(...).

Closes #595

https://claude.ai/code/session_016jA1Qu4hJK8mnsjCMDFPFu
ojongerius added a commit that referenced this pull request May 26, 2026
* docs(site): rewrite Quick Start to drive against the daemon (#625)

* docs(site): rewrite Quick Start to drive against the daemon (closes #616)

Lead every SDK section (Python, TypeScript, Go) with the daemon-mediated
signing path per ADR-0022 D1: the SDK emits tool-call events over a Unix
socket and the agent-receipts-daemon holds the Ed25519 key. Each section
follows Install -> Start the daemon -> Emit -> Verify and ends with
`agent-receipts verify` so the reader confirms the receipt landed.

In-process signing is demoted to a clearly-labeled tutorial/testing-only
appendix carrying the ADR-0022 D2 "Not for production" note. Replaces the
stale attest_protocol imports. The page's posture now matches the homepage
and daemon-setup, closing SITE-P3.

https://claude.ai/code/session_01FCwvdzkbcG574nCU4h8Zwp

* docs(site): address Quick Start review feedback

Reorder the intro SDK list to Python/TypeScript/Go to match section
order, check the TypeScript emit() return value, and drop the unused
receipt_hash from the in-process appendix example.

https://claude.ai/code/session_01FCwvdzkbcG574nCU4h8Zwp

* docs(site): address second-round Quick Start review feedback

Drop the @Alpha dist-tag from the TypeScript install (DaemonEmitter
ships in stable 0.10.0; @Alpha resolves to an older prerelease that
still exports the old Emitter name). Wrap the TypeScript example in an
async main() with try/finally so it is copy/paste runnable and always
closes the socket. Ignore the Go Close() error in the deferred call to
stay errcheck-clean. Note AGENTRECEIPTS_CHAIN_ID alongside the DB and
public-key overrides in every verify step.

https://claude.ai/code/session_01FCwvdzkbcG574nCU4h8Zwp

* docs(site): handle main() rejection in TS Quick Start snippet

Adds .catch() with process.exitCode=1 to surface emit() errors
deterministically across Node versions (Copilot review on #625).

* docs(site): fix stale APIs and macOS socket path in Daemon Setup (#628)

* docs(site): fix stale APIs and macOS socket path in Daemon Setup

Brings `daemon-setup.mdx` into line with the shipped SDKs and
`daemon/README.md`:

- TypeScript snippets use `DaemonEmitter` (renamed from `Emitter` in
  @agnt-rcpt/sdk-ts 0.10.0).
- TypeScript install drops `@alpha` — `DaemonEmitter` ships on the
  default tag; `@alpha` still resolves to the old `Emitter` name.
- Go snippets use `emitter.NewDaemon` (current constructor;
  `emitter.New` no longer exists).
- macOS default socket path moves from `$TMPDIR/agentreceipts/...` to
  `$XDG_DATA_HOME/agent-receipts/events.sock` (matches the daemon's
  actual resolver; `$TMPDIR` is not inherited by GUI-spawned processes,
  so the old path made the handshake fail silently on macOS — issue
  #545).

Updates the troubleshooting `ls` example to the new macOS path and
fixes one prose reference to `New()` → `NewDaemon()` in the same
paragraph as the renamed snippets.

Closes #627.

* docs(site): address Copilot review on #628

- "Connect your emitters" paragraph: drop the incorrect claim that the
  Go SDK ignores `AGENTRECEIPTS_SOCKET` on non-macOS/Linux platforms.
  `emitter.DefaultSocketPath` consults the env var first on every host;
  `NewDaemon()` only errors when neither the env var nor an explicit
  socket-path option supplies a path.
- Troubleshooting `ls`: switch the macOS example to
  `~/.local/share/agent-receipts/events.sock` (the absolute default
  fallback) instead of `${XDG_DATA_HOME:-...}`. The daemon and SDKs
  ignore a non-absolute `XDG_DATA_HOME` and fall back, so the previous
  shell expansion could point at the wrong path when the env var is
  set but invalid — same trap the verify section already avoids.

* docs(site): clarify language scope + XDG_DATA_HOME caveat (Copilot round 2)

- "Connect your emitters" paragraph: drop the Go-specific `NewDaemon()`
  reference, since the surrounding text applies to all SDKs. Use "the
  emitter constructor" and mention `WithSocketPath` only as a Go
  example so TS/Python readers aren't misdirected.
- Troubleshooting: add a one-line caveat noting that the macOS `ls`
  example assumes the default fallback path; users with a custom
  `AGENTRECEIPTS_SOCKET` or absolute `XDG_DATA_HOME` should check
  their own path. Mirrors the caveat the verify section already
  carries.

* ci: verify README code snippets against the SDK artifacts

Adds a release-blocking gate that extracts the SDK quick-start snippets from
the user-facing READMEs and compiles / type-checks each one — catching the
recurring papercut (#593, #594) where a snippet calls a non-existent API,
imports a wrong module path, or drifts behind a published rename.

- scripts/readme_snippets/: a dependency-free Python harness. extract.py
  (pure, unit-tested) parses fenced blocks and assembles compilation units;
  check.py scaffolds a throwaway project and runs go build / tsc --noEmit /
  mypy against either the in-tree SDK (--source local) or the published
  artifact (--source published).
- Default-in: every SDK-importing fenced block is checked, so a newly added
  snippet is covered without annotation. snippet-check directives (continues,
  skip) handle dependent and illustrative blocks.
- readme-snippets.yml runs the in-tree check on every README-touching PR;
  the publish-* workflows run the published check at release time.

Fixes drift the gate caught:
- sdk/go/README.md used the stale module path github.com/agent-receipts/sdk-go
  instead of github.com/agent-receipts/ar/sdk/go (install + imports).
- Root README Python quick-start passed action as a dict where
  CreateReceiptInput expects ActionInput; now uses ActionInput(...).

Closes #595

https://claude.ai/code/session_016jA1Qu4hJK8mnsjCMDFPFu

* ci: fail loudly on chained Go snippets instead of dropping them

Self-review caught a silent gap: a `continues` directive before a Go block
would render only the first block in the chain and silently drop the rest,
leaving a snippet unchecked — the exact failure this gate exists to prevent.
Go snippets are standalone, so raise a clear error instead.

https://claude.ai/code/session_016jA1Qu4hJK8mnsjCMDFPFu

* ci: address snippet-harness review feedback

- TS check now reads typescript / @types/node from sdk/ts/package.json
  (the SDK builds on ~6.0.2 / ^25), so the gate matches the published .d.ts
  instead of an arbitrary pinned major.
- Fail fast (exit 2) when a README path doesn't exist, instead of silently
  dropping it and reporting success — a path typo must not disable the gate.
- Pin mypy (==2.1.0) so the gate is deterministic across runs.
- Hoist Go imports verbatim so aliases (foo "pkg"), blank imports (_ "pkg"),
  and inline comments survive the package-shim rewrite.

https://claude.ai/code/session_016jA1Qu4hJK8mnsjCMDFPFu

* ci: address second-pass snippet-harness review feedback

- Clear a pending snippet-check directive when an unrecognised one follows,
  so it can't leak onto the next fenced block.
- Pin the temp TS project's typescript / @types/node to exact versions
  (strip the ^/~ range) so resolution is deterministic without a lockfile.
- Use a conventional throwaway Go module path (example.com/readme-snippets).

https://claude.ai/code/session_016jA1Qu4hJK8mnsjCMDFPFu
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