Skip to content

DeliveryPayload.severity is declared 'info' | 'warning' | 'critical' | string — the trailing | string collapses the union, so the closed set enforces nothing #7174

Closed

Description

@os-zhuang

Observation-class finding, noticed while closing the NotifyConfigSchema.severity gate for #7086 (PR pending). Recorded unassigned. Type-level only — no user-visible failure today, which is why it carries finding and no pm:queue.

Anchor

packages/services/service-messaging/src/outbox.ts, DeliveryPayload:

/** Rendered content snapshot carried on the delivery row for dispatch. */
export interface DeliveryPayload {
    title?: string;
    body?: string;
    severity?: 'info' | 'warning' | 'critical' | string;
    actionUrl?: string;
    [k: string]: unknown;
}

The defect

'info' | 'warning' | 'critical' | string is exactly string to TypeScript — a
literal union member is absorbed by the wider primitive it is unioned with. The three
names therefore contribute nothing but an editor hint; severity: 'urgent' type-checks
here with no error, and so does severity: ''.

The result is a type that reads as the closed vocabulary while enforcing the open one —
the same declared-vs-enforced shape as #7086, one layer down and in the type system
rather than in Zod. It sits in the package that also owns the genuinely closed
declarations, which is what makes it easy to misread:

  • messaging-service.ts:64 — readonly severity?: 'info' | 'warning' | 'critical';
  • channel.ts:40 — readonly severity?: 'info' | 'warning' | 'critical';
  • inbox-message.object.ts:88 — a Field.select offering exactly those three

so DeliveryPayload is the one member of that family that is silently open.

Why it matters

DeliveryPayload is the rendered snapshot carried on the delivery row. Anything that
builds or mutates one gets no compiler signal when it writes an out-of-vocabulary
severity, and the value then reaches inbox-channel.ts's severity: n.severity ?? 'info'
and the sys_inbox_message.severity select column, whose options are the three names.
Nothing today is measured to write a bad value — this is a missing guard-rail, not a
live bug — but it is the guard-rail that would have made #7086's 'urgent' visible to
tsc instead of only to a probe.

Suggested shape, if triage wants it fixed

Drop the | string so the union means what it says. If some caller genuinely needs to
carry an unvalidated severity through, that is a real decision worth stating explicitly
(e.g. a named string & {} escape or a comment recording the tolerance), not something
the current spelling communicates — as written it looks like a closed set and behaves
like an open one, which is the worst of both.

Worth checking in the same pass whether other 'a' | 'b' | string unions exist in the
services layer; this one was found by eye, not by a sweep.

Refs

#7086 (the Zod-side twin, being closed now), #6762 (the describe-claims-closed class).

Activity

  1. added
    finding
    domain:services
    on Aug 10, 2026
  2. os-zhuang commented on Aug 10, 2026

    @os-zhuang
    ContributorAuthor

    Route repair only — domain:services appended; the finding grade is unchanged and no ownership is taken.

    • Landing anchor: DeliveryPayload is declared at packages/services/service-messaging/src/outbox.ts:22 (verified on origin/main @ 5d24f4b) — the 'info' | 'warning' | 'critical' | string collapse is on that interface's severity member ⇒ domain:services.
    • Why this comment exists: this card carried finding with no domain:*/repo:*, making it invisible to every lane filter; routing labels are the triage seat's single-producer territory, so the label is appended here rather than by the lane.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  3. added
    pm:queue
    and removed
    finding
    on Aug 10, 2026
  4. added
    pm:dispatched
    on Aug 10, 2026
  5. self-assigned this
    on Aug 10, 2026
  6. os-help commented on Aug 10, 2026

    @os-help
    Collaborator

    Claim: PM loop round 4 (domain:services seat #6021)
    Session: session_015fkdTyGmMD5s8ZtEifvuGy
    Branch: claude/issue-7174-severity-union-collapse
    Worktree: objectstack-issue-7174
    Domain: domain:services
    File surface: packages/services/service-messaging/src/outbox.ts + consumers inside service-messaging that a narrowed union turns red + tests. (Stop on breach; explain in the report.)
    Container & model: S mechanical (single-interface type fix, correctness judged by typecheck + suite), mode:subagent, model: sonnet
    Serial constraints cleared: no in-flight claim touches service-messaging; #7086 (the Zod-side twin) — check its PR state at branch point for same-day churn on the severity family.


    Generated by Claude Code

  7. removed
    pm:queue
    on Aug 10, 2026
  8. os-help commented on Aug 10, 2026

    @os-help
    Collaborator

    ACCEPT. PR #7382, reviewed by the domain:services seat (#6021, session session_015fkdTyGmMD5s8ZtEifvuGy). Marking ready and queueing.

    Verified against GitHub rather than the report: 3 files — the one-line union fix in outbox.ts, a compile-time pin test (in a *.test.ts because this package's tsc program DOES read test files — measured, per the #7140 convention's decision rule), one patch changeset with the public-type-narrowing reasoning. 25/25 check runs success/skipped; ESLint (08:25:16Z) and TypeScript Type Check (08:36:18Z) read by job conclusion. Fixes #7174 correct.

    Quality notes: premise re-verified including the non-obvious index-signature question (probed that [k: string]: unknown does not swallow the named property's narrowed type — the fix is a real compiler gate, not a no-op); reverse verification measured the predicted TS2578 on the restored collapse; every in-package construction site traced (all already write from the closed EmitInput.severity, so zero runtime change); downstream sweep in the correct direction ('...pkg' prefix) found zero external references — fully contained. The card's suggested services-layer sweep for other 'a' | 'b' | string collapses ran and found this was the only instance. Vocabulary matches the merged Zod-side twin (#7086 / PR #7192).


    Generated by Claude Code

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

Metadata

Metadata

Assignees

Labels

domain:servicespm:dispatched

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions