Skip to content

feat(sdk): TypeScript refresh/cancel/replace controls (wire v2) (#101, 2/2) - #108

Merged
AetherAI3 merged 2 commits into
mainfrom
claude/nano101-ts-controls
Nov 8, 2026
Merged

AetherAI3 merged 2 commits into
mainfrom
claude/nano101-ts-controls

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

Summary

Adds LifecycleClient to @nano/qsearch-lifecycle. It provides status plus refresh / cancel / replace, each available only when the caller grants it, per wire contract v2. Every control makes exactly one signed POST and returns the server's state unchanged. The client never retries, never follows up and never interprets cancellation. StatusClient and all v1 behaviour are unchanged. PR 2 of 2 for #101; based on PR 1. Closes #101.

Key Changes

  • Capability-gated controls — The default is ["status"]. An operation that was not granted fails with UNSUPPORTED_CAPABILITY before any I/O.
  • Byte-exact canonical replace — A lexeme-preserving canonicaliser reproduces Python's canonical_json. The response must bind the descriptor digest and lineage.
  • Lost acknowledgements stay unknown — A transport failure or timeout on a POST is TRANSPORT_UNAVAILABLE with MANUAL_RECONCILIATION, never a state.
  • Injected SHA-256 — createSha256() lives in ./webcrypto. The fetch adapter sends bodies only on POST.

Verification

  • npm test: 121/121 against the Python v2 goldens and the v1 goldens. pack:check installs outside the checkout.
  • Held-out set (20 cases, frozen before implementation and never shown to the implementer): 20/20. It covers canonical bytes, local refusals, replace binding and lost acknowledgements.
  • Independent review found no CRITICAL or HIGH issues. A 36,669-input canonical differential against Python had no byte or refusal mismatch beyond the documented stricter rules. One MEDIUM (sha256 invoked after the deadline) was fixed after a failing test was written first.

Risk / Follow-ups

  • Stricter than Python by design: duplicate keys and depth > 64 in replacement text are refused. Integers longer than 4,300 digits are refused, matching Python's limit.
  • A 3xx on a control maps to UNEXPECTED_REDIRECT/NONE (v1 rule, Python parity). There is no client-side cap on replacement size; the service returns 413.

🤖 Generated with Claude Code

@AetherAI3
AetherAI3 changed the base branch from claude/nano101-lifecycle-wire-v2 to main November 8, 2026 13:06
AetherAI3 and others added 2 commits November 8, 2026 08:07
…ent (wire v2)

Additive v2 client per protocol/qsearch-lifecycle/v2 (Nano #101, PR2):

- LifecycleClient with a caller-chosen capability set (default status);
  ungranted operations are UNSUPPORTED_CAPABILITY with zero transport calls.
- refresh/cancel: one POST, empty body; replace: canonical body, MAC over its
  SHA-256 via an injected sha256 capability (createSha256 in ./webcrypto).
- Binding: refresh/cancel to the requested digest; replace to the
  descriptor digest and lineage.replaces_request_digest; full v1 validation.
- Transport failure or timeout on a POST is TRANSPORT_UNAVAILABLE with
  MANUAL_RECONCILIATION; responses are returned as is, never interpreted.
- src/canonical.ts reproduces Python canonical_json(json.loads(text)) byte
  for byte from JSON text or UTF-8 bytes (lexeme-preserving parser,
  code-point key order, Python float repr).
- StatusClient is a thin wrapper over the shared engine, behaviour unchanged.
- Tests: client suite, canonical dev set derived from the Python reference,
  property tests, v2 drift guard, fetch POST body, and a v2 golden runner
  that fails until the Python fixtures land.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Independent review (no CRITICAL/HIGH) found the injected sha256 capability
could be invoked after the deadline had settled a replace call. Reproduced
by a failing test; both hashes now start together.

Refs #101

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AetherAI3
AetherAI3 force-pushed the claude/nano101-ts-controls branch from e9ae6bb to d219288 Compare November 8, 2026 13:07
@AetherAI3
AetherAI3 merged commit 9e14862 into main Nov 8, 2026
9 checks passed
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.

[P2][hillclimb] Lifecycle wire contract v2: interoperable refresh/cancel/replace controls (follow-up to #86)

1 participant