Skip to content

feat: add integration history helpers - #91

Merged
steipete merged 1 commit into
mainfrom
feat/integration-history-primitives
Jul 17, 2026
Merged

steipete merged 1 commit into
mainfrom
feat/integration-history-primitives

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • expose bounded durable-event pagination through client.events.list
  • add latest=true thread windows across SQLite, Postgres, HTTP, OpenAPI, and the TypeScript SDK
  • keep latest thread replies in chronological order
  • document both framework-neutral integration helpers

This extracts the reusable integration capabilities surfaced by #78. Thanks @arcabotai for identifying the need and for the original implementation direction.

Proof

  • focused SQLite, Postgres, HTTP, SDK build, and SDK typecheck — pass
  • pnpm check — pass
  • pnpm coverage — 85.3%
  • pnpm test:e2e — 98 passed
  • pnpm audit --audit-level=high — no known vulnerabilities
  • govulncheck ./... — no vulnerabilities
  • real built Go server plus real built TypeScript SDK — created five thread replies, fetched replies 4–5 with latest=true&limit=2, observed reply count 5, fetched a two-event durable page, and received the captured tail cursor
  • AutoReview — clean, no accepted/actionable findings
  • public model identifier gate — PASS

@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head proof for 79d96964549d020143d50cbc4794ad460bf1ed87:

  • go test ./apps/api/internal/store/sqlite ./apps/api/internal/store/postgres ./apps/api/internal/httpapi && pnpm build:sdk && pnpm --filter @clickclack/sdk-ts typecheck — passed. SQLite and HTTP latest-window coverage passed; PostgreSQL integration test is enabled when its DSN is present.
  • pnpm check && pnpm coverage && pnpm audit --audit-level=high && govulncheck ./... — passed; 85.3% coverage; no known JavaScript or Go vulnerabilities.
  • pnpm test:e2e — 98 passed in 46.9s.
  • Built and ran the real server binary with a disposable SQLite database, then used the built SDK to create a root plus five replies, request latest=true&limit=2, and paginate realtime events with include_tail=true. Observed: {"latestReplies":["history live reply-4","history live reply-5"],"replyCount":5,"eventCount":2,"tailCursor":true}. Server returned 201 for all writes and 200 for thread and realtime reads.
  • AutoReview branch review — clean; no accepted/actionable findings.
  • Hosted exact-head CI — all seven jobs passed: Go, TypeScript, Playwright E2E, Docker Image, Linux Desktop, macOS Desktop, Windows Desktop.

Land-ready. Not merged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79d9696454

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const params = new URLSearchParams();
if (options.limit !== undefined) params.set("limit", String(options.limit));
if (options.latest !== undefined) params.set("latest", String(options.latest));
const query = params.size > 0 ? `?${params.toString()}` : "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid dropping thread query options in older browsers

When the SDK runs in browsers/WebViews that support URLSearchParams but not the newer size property (for example Safari/iOS 16), params.size is undefined, so callers that pass limit or latest still get an empty query string and the server returns the default earliest window. This SDK is documented as browser-compatible, and the surrounding code already avoids this compatibility trap by checking params.toString() instead.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 17, 2026, 12:17 AM ET / 04:17 UTC.

Summary
Adds latest bounded thread windows across SQLite, Postgres, HTTP, OpenAPI, and the TypeScript SDK, plus an SDK durable-event pagination helper, focused tests, and documentation.

Reproducibility: no. live older-browser reproduction was supplied, but the failure path is high-confidence from the changed source: when URLSearchParams.size is unavailable, the SDK constructs an empty suffix despite populated parameters.

Review metrics: 3 noteworthy metrics.

  • API Surface: 2 integration helpers added. The PR exposes durable-event listing and latest bounded thread-history retrieval as new public SDK behavior.
  • Backend Coverage: 2 stores, HTTP, OpenAPI, and SDK changed. Maintainers should verify behavioral parity across every layer before accepting the new contract.
  • Focused Tests: 3 test files added. SQLite, Postgres, and HTTP latest-window behavior receive dedicated coverage.

Root-cause cluster
Relationship: canonical
Canonical: #91
Summary: This PR is the narrow landing candidate for reusable history helpers extracted from the broader, closed-unmerged connector proposal.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Replace the URLSearchParams.size check and add a request-URL regression test.
  • [P2] Implement the new thread-window queries through sqlc and regenerate typed outputs.
  • Remove the CHANGELOG.md edit, then rerun the focused server, SDK, and live integration proof.

Risk before merge

  • [P1] On older Safari/iOS WebViews, callers can supply limit or latest yet silently receive the default earliest thread window because the SDK omits the query string.
  • [P1] Landing new raw SQL in both backends would bypass the repository's sqlc source-of-truth policy and increase the chance of SQLite/Postgres query drift.

Maintainer options:

  1. Repair compatibility before merge (recommended)
    Use a serialized-query check, move the new SQL into sqlc query sources, regenerate outputs, add focused regression coverage, and retain the successful live integration proof.
  2. Pause the API addition
    If the sqlc-compatible implementation cannot remain narrow, pause this PR and redesign the storage query boundary before exposing the SDK contract.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Replace the `URLSearchParams.size` query check with a `toString()`-based check, move the latest-thread SQL into sqlc query definitions for both stores, regenerate typed SQL outputs, remove the release-owned CHANGELOG edit, add focused SDK compatibility coverage, and rerun the existing server/SDK validation.

Next step before merge

  • [P2] An automated repair can address the three concrete blockers on the PR branch without requiring API product-direction judgment.

Security
Cleared: The diff adds scoped read helpers without new dependencies, permissions, secret handling, executable supply-chain inputs, or a concrete authorization regression.

Review findings

  • [P2] Avoid relying on URLSearchParams.size — packages/sdk-ts/src/index.ts:984
  • [P2] Move the latest-window SQL into sqlc queries — apps/api/internal/store/sqlite/sqlite.go:684-690
  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:23
Review details

Best possible solution:

Keep the API design, serialize the thread query with params.toString(), express both latest-window queries through the repository's sqlc sources, regenerate typed outputs, preserve chronological responses and the existing earliest-window default, and remove the release-owned changelog edit.

Do we have a high-confidence way to reproduce the issue?

No live older-browser reproduction was supplied, but the failure path is high-confidence from the changed source: when URLSearchParams.size is unavailable, the SDK constructs an empty suffix despite populated parameters.

Is this the best way to solve the issue?

No, not as currently written. The public API shape is reasonable, but query construction must use the established serialized-string pattern and the new database queries must follow the repository's sqlc workflow.

Full review comments:

  • [P2] Avoid relying on URLSearchParams.size — packages/sdk-ts/src/index.ts:984
    Build the suffix from params.toString() instead. In browsers or WebViews without the newer size property, this condition is false even after limit or latest is set, so the request silently fetches the default earliest window rather than the caller's requested history.
    Confidence: 0.98
  • [P2] Move the latest-window SQL into sqlc queries — apps/api/internal/store/sqlite/sqlite.go:684-690
    Repository policy requires typed SQL through sqlc, but this patch adds dynamic raw ORDER BY SQL directly in both SQLite and Postgres stores. Define the earliest/latest query variants in the sqlc query sources and regenerate the typed store code so both backends retain one reviewed query contract.
    Confidence: 0.96
  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:23
    CHANGELOG.md is release-owned and normal feature PRs should leave release-note assembly to the release process. Keep the user-visible summary and attribution in the PR body or commit message instead.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b3837d1743db.

Label changes

Label changes:

  • add P2: This is a normal-priority SDK/API improvement with narrow, repairable compatibility and repository-policy blockers.
  • add merge-risk: 🚨 compatibility: The new public SDK options can silently stop working in older supported browser/WebView environments because they rely on URLSearchParams.size.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The exact-head proof exercises a real built server and SDK end to end, showing five writes, chronological latest-window reads, event pagination, and a captured tail cursor; private data should remain redacted in any additional evidence.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The exact-head proof exercises a real built server and SDK end to end, showing five writes, chronological latest-window reads, event pagination, and a captured tail cursor; private data should remain redacted in any additional evidence.

Label justifications:

  • P2: This is a normal-priority SDK/API improvement with narrow, repairable compatibility and repository-policy blockers.
  • merge-risk: 🚨 compatibility: The new public SDK options can silently stop working in older supported browser/WebView environments because they rely on URLSearchParams.size.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The exact-head proof exercises a real built server and SDK end to end, showing five writes, chronological latest-window reads, event pagination, and a captured tail cursor; private data should remain redacted in any additional evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head proof exercises a real built server and SDK end to end, showing five writes, chronological latest-window reads, event pagination, and a captured tail cursor; private data should remain redacted in any additional evidence.
Evidence reviewed

Acceptance criteria:

  • [P1] pnpm generate:sqlc.
  • [P1] go test ./apps/api/internal/store/sqlite ./apps/api/internal/store/postgres ./apps/api/internal/httpapi.
  • [P1] pnpm build:sdk.
  • [P1] pnpm --filter @clickclack/sdk-ts typecheck.
  • [P1] pnpm check.

What I checked:

  • Feature remains necessary: Current main does not expose the proposed events.list SDK helper or latest bounded thread-window option; these are additions in the PR head rather than redundant implementations. (packages/sdk-ts/src/index.ts:976, 79d96964549d)
  • Browser compatibility defect: The new thread helper decides whether to append the query using URLSearchParams.size; the existing review discussion identifies browsers and WebViews where that property is unavailable, causing supplied options to be silently omitted. (packages/sdk-ts/src/index.ts:984, 79d96964549d)
  • Repository SQL policy: The fully supplied repository AGENTS.md requires typed SQL through sqlc, while the patch adds dynamic raw ordering SQL directly to both store implementations instead of editing query sources and regenerating outputs. (apps/api/internal/store/sqlite/sqlite.go:684, 79d96964549d)
  • Real behavior proof: The contributor built the real Go server and TypeScript SDK, created five replies, observed the latest two in chronological order, paginated durable events, captured a tail cursor, and reported successful HTTP writes and reads on the exact reviewed head. (79d96964549d)
  • Related implementation direction: The helper APIs extract a bounded subset of the broader connector work proposed in feat: add Hermes Agent connector example #78, which is closed unmerged; that PR remains useful provenance but is not a safe replacement landing path. (packages/sdk-ts/src/index.ts:1112, 5a20a79973c8)
  • Security pass: The patch adds read helpers behind existing resource and scope checks, introduces no dependencies, workflows, permissions, secrets, or downloaded code, and constrains the dynamic SQL direction to an internal boolean. (apps/api/internal/httpapi/server.go:1046, 79d96964549d)

Likely related people:

  • shakkernerd: Current-main changelog history credits shakkernerd with the realtime tail-cursor and event-pagination behavior that the new SDK events helper wraps. (role: adjacent realtime history contributor; confidence: medium; files: apps/api/internal/httpapi/server.go, packages/sdk-ts/src/index.ts, docs/sdk.md)
  • arcabotai: The PR body and related closed connector PR credit arcabotai with identifying and implementing the bounded-history and event-recovery requirements extracted here. (role: original integration direction contributor; confidence: high; commits: 5a20a79973c8; files: packages/sdk-ts/src/index.ts, apps/api/internal/store/sqlite/sqlite.go, apps/api/internal/store/postgres/postgres.go)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 3e1d284 into main Jul 17, 2026
7 checks passed
@steipete
steipete deleted the feat/integration-history-primitives branch July 17, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant