feat(contract): @forgegraph/contract — Effect HttpApi → operation IR compiler #564
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!564
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/contract-package"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
New workspace package
packages/contract(@forgegraph/contract0.1.0): compile an EffectHttpApiinto ForgeGraph's operation contract IR with no hand-authored endpoint, schema, error or auth catalogs.Phase 1, tasks 1.1–1.7 of the plan: https://7n04n7hhuesf.postplan.dev
Surface
effect@forgegraph/contract/./irvalidateContract, fingerprints./sla./effectcompileHttpApi,Sla/IsPublic/Authenticationannotations,forgeGraph({...})helperDesign points
<serviceId>.<group>.<endpoint>; matches thegroup.endpointspan name the create-gmacko-app template already emits. A route move does not change identity (tested).HttpApi.reflect(identity, middleware, statuses, merged annotations) andOpenApi.fromApi(JSON Schema + components). No AST walking.Authenticationis derived from the security middleware (cookie/basic → user, bearer/header key → service, both → mixed, none → anonymous). An explicit annotation overrides and setsmismatch: truefor ForgeGraph to flag../irZod schema (Phase 2).Verification
pnpm -F @forgegraph/contract test), typecheck andtsc -p tsconfig.build.jsonclean, oxlint clean of errors.effectrc.112 and its deps).Not in this PR
Ingest endpoint, tables, UI tab (Phase 2) and the template-side annotations +
contract.jsongeneration (tasks 1.8–1.10, separate PR in create-gmacko-app).🤖 Generated with Claude Code
New workspace package that turns an Effect `HttpApi` into ForgeGraph's operation contract IR without any hand-authored endpoint, schema, error or auth catalog. - `./effect`: `compileHttpApi(api, { serviceId, globalSla?, serviceSla?, environmentSla? })` built on `HttpApi.reflect` for identity, middleware, success/error statuses and merged annotations, and on `OpenApi.fromApi` for JSON Schema. No private Effect internals are read. - Annotation vocabulary as `Context.Reference`s with defaults: `Sla` ({}), `IsPublic` (false), `Authentication` (derived from security middleware unless overridden; an override sets `mismatch: true`). - `./sla`: leaf-merged resolution global → service → api → group → endpoint → environment with per-leaf provenance and value validation. - `./ir`: Effect-free Zod schema + `validateContract` (shape, unique ids, id/parts agreement, per-operation and contract fingerprints, dangling $refs) so the ForgeGraph server can validate ingested contracts without Effect. - Stable semantic ids `<serviceId>.<group>.<endpoint>` match the `group.endpoint` span names the create-gmacko-app template already emits. `effect` is an optional peer (≥ 4.0.0-rc.112, pinned to the template catalog). 37 unit tests. Plan: https://7n04n7hhuesf.postplan.dev (Phase 1, tasks 1.1–1.7). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>b91621836047a91edcffPreview environment is live: https://pr-564-forgegraph.forgegraf.com
Deployed
b9162183with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.47a91edcffc2f1c4ef6ePreview environment is live: https://pr-564-forgegraph.forgegraf.com
Deployed
c2f1c4efwith the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.