Skip to content

Column visibility: visibility:internal in entity.yaml, generated wire structs, V18 lint #858

Closed

Description

@athvin

API product implementation work · roadmap #1008 · use parent dependency order; not a separate product rank.

Part of #857. Stack rank 1 of 13. Depends on: nothing — this is the root of the epic.

Color

The one live defect: three secrets are published as required schema properties (Webhook.secret, ApiKey.key_hash, TaskInstance.token_hash) while the runtime guard is a comment on a hand-written struct (pg.rs::WebhookRow: "the secret is never listed"). The TypeScript bindings overclaim the same way (bindings/Webhook.ts declares secret: string). This ticket moves the guard into the entity framework so it cannot be forgotten per-handler. P0 because every later ticket builds on the wire structs, and because the published document is currently asserting a leak.

Scope

  • er-entity-spec: Column.visibility (public default | internal), Visibility enum in types.rs. The struct is deny_unknown_fields, so this is the one deliberate spec change; all 50 existing entities parse unchanged via the default.
  • er-entity-gen/src/rust.rs: for every wire: [json] entity emit <Name>Wire (public columns only, declaration order) + impl From<&<Name>>, deriving Serialize + utoipa::ToSchema with #[schema(as = <Name>)] so component-schema names never move (verified supported in the pinned utoipa 6). ToSchema comes OFF the row struct — uniformly, even where the two are identical — so ApiDoc can only ever reference wire structs and adding visibility: internal later needs no edit anywhere else.
  • er-entity-gen/src/typescript.rs: json-wire bindings emit public columns only.
  • er-entity-lint: V18 (error) — on a wire: [json] entity, a secret-shaped column (secret, *_secret, token_hash, key_hash, password, *_token) must declare visibility: internal; and a key/natural_key column may not be internal (a resource whose id is hidden cannot be described). One rule file under rules/, one registry line, one fixture dir; references/entity-lint-rules.md regenerates from the registry.
  • Declare visibility: internal on webhook.secret, api_key.key_hash, task_instance.token_hash.
  • Replace pg.rs::WebhookRow with the generated WebhookWire. Leave ConfigVersionRow/ScheduleRow alone — those are payload-size trims, not secrecy, and visibility must not mean two things.
  • Regenerate all artifacts; point openapi.rs registrations at the wire structs.
  • Skills in this PR: entity-framework references gain the visibility field; security gains the visibility-guard row.

Out of scope

Paths, audiences, any handler response typing, key self-service (later tickets).

Testing

  • V18 fixture tests in both directions, and observe the gate failing: remove one declaration, watch V18 name the column, restore it. A lint rule whose precondition always holds is decoration.
  • Diff proof that secret/key_hash/token_hash left all three layers: openapi.json, schema.d.ts, bindings/*.ts.
  • er-openapi-check will report the property removals — expected, advisory, and the point of the gate.
  • Grep proof no frontend code read the removed fields (pre-verified: none does; webhooks-content.tsx reads the create response, not the entity binding).
  • make check (which runs er-entity verify: V-rules, byte-exact staleness, orphans, E0xx).

Definition of done

Epic DoD, plus: the three secrets are absent from all three generated layers; V18 appears in er-entity lint --list with --explain V18 reasoning and worked examples; a new secret-shaped column cannot ship undeclared; WebhookRow is gone.

Lint-code allocation correction

The refreshed main branch already uses V18 for append-list columns (er-entity-lint fixtures). Select the next available append-only lint code from the live registry when implementing visibility; the historical V18 proposal in this ticket is not a reservation.

Activity

  1. added
    enhancement
    rust
    mvp
    on Nov 8, 2026
  2. self-assigned this
    on Nov 9, 2026
  3. athvin commented on Nov 9, 2026

    @athvin
    OwnerAuthor

    Claimed — working in #1019 (draft), created 2026-11-09T04:46:10Z. Closing that PR releases the claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementmvprust

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions