Skip to content

feat(patches): the read path: GET /api/patches at its three levels over the company-readable inventory #250

Closed

Description

@allisonmahmood

Part of #247. Implements spec §7's patch routes, §13's read query and §14's read rows (the connections group is ticket 4's); decisions Discovery for agents and the prototype (a company-readable inventory, reads, purgeAt, --state at the patch level, token-only).

What to build

  • One read query in packages/patches, shared later by the portal: the company's patches joined with their owners (name, deactivated), the current version's number and publish time, the live dependant edges, each patch's declared shared-table reads across its retained versions (alias, source patch id and name, table, source state), and, when the company database exists, the cumulative inventory per patch. It takes the credential's openability predicate (every company patch today) and a state filter.
  • A company-readable inventory read in Patches, openability-gated, that does not take the owner-only write predicate; the owner's GET /api/patches/:patchId/inventory keeps its route.
  • Routes in the patches group: GET /api/patches?mine&state → { patches: [PatchSummary] } (no connections; the CLI merges them); GET /api/patches/:patchRef?state and GET /api/patches/:patchRef/primitives/:name?state with one resolution rule: a name resolves among non-deleted patches, an id among all; a resolved patch whose state lies outside the requested state is wrong_state 409 naming its actual state (retired name under live, deleted id without all, live name under retired); unopenable, unknown, foreign, gone and deleted-by-name are one 404. PatchDetail carries title, inventory: { tables, stores } | null (null when the company database is unavailable; declarable, the reason code and hint per spec §7) and reads (with gone as a state and name omitted when the source is gone); PrimitiveDetail per spec §7 (an absent default is no default; explicit null is present). An overlong :patchRef is 414 through the guard's table. Machine tokens only.
  • Hints and reasons: shared table patchy add shared-table <patchId>/<table>; unshared not_shared with the owner's name in the hint; store not_shareable; a source that is off source_off; connected connection patchy add postgres/<handle>; disconnected not_connected pointing at /company/connections.

Admitted at merge

The read routes for any machine token. The catalog route is ticket 4's to remove; nothing here breaks patchy catalog.

Done when

  • A patch the credential cannot open (test with an alternate openability layer) is absent from the list and 404 by name; a name resolves only to non-deleted patches; reads listed from an older retained version that the current version dropped; the inventory shown to a non-owner includes a table omitted since; an unavailable company database answers inventory: null, never empty arrays; a retired name under state=live, a deleted id without state=all and a live name under state=retired are each 409 naming the state; purgeAt equals deletedAt plus 30 days; the guard's 414 covers :patchRef.

Surfaces

The wire (docs/API.md), the API guard's 414 table, the Patches glossary (Dependant, the openable gate), docs/product.md § Sharing and finding (agents discover) from decided toward built.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions