feat(api): approvals + ECO workflow API (Phase 5) #145

Closed
opened 2026-02-18 20:59:18 +00:00 by forbes · 0 comments
Owner

Implement the approvals/ECO workflow tables and API endpoints as specified in KC_SERVER.md Sections 3.3 and 4.3.

Depends on: #140 (database migration)
Supports: SILO_VIEWPORT Phase 7 (Approvals Viewer widget)

Overview

Approvals are server-authoritative -- they are created and managed through the web UI and API, not from .kc files. On .kc checkout, the current approval state is serialized into silo/approvals.json for offline display in Create.

API Endpoints (Section 4.3)

Method Path Auth Description
GET /api/items/{pn}/approvals viewer Get current approval/ECO state
POST /api/items/{pn}/approvals editor Create ECO / start approval workflow
POST /api/items/{pn}/approvals/{id}/sign editor Sign (approve/reject) an approval

Data Model

  • item_approvals: item_id, eco_number, state (draft/pending/approved/rejected), updated_at, updated_by
  • approval_signatures: approval_id FK, username, role, status (pending/approved/rejected), signed_at, comment

Behavior

  • Creating an ECO sets state to 'draft'
  • Adding signers transitions to 'pending'
  • Each signer can approve or reject with a comment
  • When all signers have acted, state transitions to 'approved' or 'rejected'
  • Rejected signatures block the approval (any reject = rejected)

Implementation scope

  • internal/db/approvals.go -- repository (create ECO, list, get, sign, state transitions)
  • internal/api/approval_handlers.go -- HTTP handlers
  • Register routes in routes.go
  • Serialize to silo/approvals.json during checkout packing (Phase 2)

Acceptance criteria

  • POST /approvals creates an ECO with state 'draft'
  • POST /approvals/{id}/sign records approval/rejection
  • GET /approvals returns current state with all signatures
  • State transitions follow the rules (draft -> pending -> approved/rejected)
  • Approval state is packed into .kc on checkout (requires Phase 2)
Implement the approvals/ECO workflow tables and API endpoints as specified in [KC_SERVER.md](docs/KC_SERVER.md) Sections 3.3 and 4.3. **Depends on:** #140 (database migration) **Supports:** SILO_VIEWPORT Phase 7 (Approvals Viewer widget) ## Overview Approvals are **server-authoritative** -- they are created and managed through the web UI and API, not from .kc files. On .kc checkout, the current approval state is serialized into `silo/approvals.json` for offline display in Create. ## API Endpoints (Section 4.3) | Method | Path | Auth | Description | |--------|------|------|-------------| | `GET` | `/api/items/{pn}/approvals` | viewer | Get current approval/ECO state | | `POST` | `/api/items/{pn}/approvals` | editor | Create ECO / start approval workflow | | `POST` | `/api/items/{pn}/approvals/{id}/sign` | editor | Sign (approve/reject) an approval | ## Data Model - `item_approvals`: item_id, eco_number, state (draft/pending/approved/rejected), updated_at, updated_by - `approval_signatures`: approval_id FK, username, role, status (pending/approved/rejected), signed_at, comment ## Behavior - Creating an ECO sets state to 'draft' - Adding signers transitions to 'pending' - Each signer can approve or reject with a comment - When all signers have acted, state transitions to 'approved' or 'rejected' - Rejected signatures block the approval (any reject = rejected) ## Implementation scope - `internal/db/approvals.go` -- repository (create ECO, list, get, sign, state transitions) - `internal/api/approval_handlers.go` -- HTTP handlers - Register routes in routes.go - Serialize to silo/approvals.json during checkout packing (Phase 2) ## Acceptance criteria - POST /approvals creates an ECO with state 'draft' - POST /approvals/{id}/sign records approval/rejection - GET /approvals returns current state with all signatures - State transitions follow the rules (draft -> pending -> approved/rejected) - Approval state is packed into .kc on checkout (requires Phase 2)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#145