Skip to content

feat(daily-brief): deviation ingestion SDK#274

Merged
hopeatina merged 1 commit into
mainfrom
feat/daily-brief-deviations
Apr 17, 2026
Merged

feat(daily-brief): deviation ingestion SDK#274
hopeatina merged 1 commit into
mainfrom
feat/daily-brief-deviations

Conversation

@hopeatina
Copy link
Copy Markdown
Contributor

Summary

Adds a reusable SDK for posting skill deviations to OrgX when a skill fires locally in the plugin runtime.

  • `src/deviations-sdk.ts`
    • `computeDedupeKey()` — sha1(skill_id | evidence_kind | evidence_ref | floor(epoch/600)), matches server's `UNIQUE (workspace_id, dedupe_key)` constraint
    • `postDeviation()` — POST /api/v1/skills/{id}/deviations with Bearer auth, structured error handling, optional timeout
    • `postDeviationBatch()` — parallel fan-out
  • `src/deviations-sdk.test.ts` — 7 tests

Companion contracts

  • orgx#664 — deviations endpoint at `app/api/v1/skills/[skillId]/deviations/route.ts`
  • orgx#667 — cron + migration guide

Next

Sister SDKs for `orgx-claude-code-plugin`, `orgx-codex-plugin`, `cursor-plugin` follow the same 5-field dedupe key contract.

Test plan

  • `pnpm typecheck` — clean
  • `npx tsx --test src/deviations-sdk.test.ts` — 7/7

🤖 Generated with Claude Code

Adds a reusable SDK for posting skill deviations to OrgX when a skill
fires locally (pre-PR, pre-commit, pre-chat) against a file edit,
commit, PR, chat turn, or task output.

- src/deviations-sdk.ts
  - computeDedupeKey(): sha1(skill_id | evidence_kind | evidence_ref |
    floor(epoch/600)) — matches server's UNIQUE (workspace_id, dedupe_key)
    constraint. 10-minute bucketing handles save-happy editors.
  - postDeviation(): POST /api/v1/skills/{id}/deviations with Bearer auth,
    structured error handling (no throw on HTTP failure), optional
    AbortController timeout.
  - postDeviationBatch(): parallel fan-out.
- src/deviations-sdk.test.ts — 7 tests covering dedupe stability across
  bucket boundaries, POST shape, dedup echo, 4xx handling, network failure.

Sister SDK for other plugin runtimes can either port this file directly
(Node/TypeScript) or reimplement the same 5-field sha1 dedupe key in
their language of choice.

Companion server contract: orgx/docs/api-contracts/daily-brief-schema.md §04
Initiative a3b9a125-4078-4f24-9e10-088c6c6dd005.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant