Thanks to visit codestin.com
Credit goes to github.com

Skip to content

type-architecture: add explicit JsonValue output contract #202

@iamfj

Description

@iamfj

What problem does this solve?

Linearis promises JSON-only output, but outputSuccess accepts unknown. That means the compiler allows non-JSON values such as functions, undefined, symbols, class instances, or cyclic objects to reach the output boundary.

Proposed solution

Define a JsonValue type and evaluate whether outputSuccess can require it directly.

Example:

export type JsonPrimitive = string | number | boolean | null;
export type JsonValue =
  | JsonPrimitive
  | { readonly [key: string]: JsonValue }
  | readonly JsonValue[];

export function outputSuccess<T extends JsonValue>(data: T): void;

If generated GraphQL result objects are too noisy initially, add a transitional output type or runtime-safe stringify helper and document the path to full JsonValue enforcement.

Acceptance criteria:

  • A project-level JsonValue type exists.
  • The output boundary is stricter than unknown or has a documented transitional plan.
  • Add tests for undefined/non-serializable output behavior if runtime validation is introduced.

Alternatives considered

Keep unknown for ergonomics. This is permissive but does not encode the project's JSON-only contract in types.

Primary use case

LLM agent integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P2Important work, but not part of the immediate implementation queueqa:smell

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions