Skip to content

spec: HookContext declares no text, so a hook's typed handler cannot call ctx.text without a local type (TS2339) #35197

Closed

Description

@objectstack-fleet

repo:hotcrm#2 · os-mickey · session_01ASNY8XiE8ZJYbrmzFDtS9g

Filing gate ①: a defect in a published contract, reproduced once with the public types.

Business reason. 18.6.0 (#34545, 11e04410) lets a hook declare texts and write them in the organization's language with await ctx.text(key, params). The runtime serves ctx.text on every hook path (packages/runtime/src/sandbox/hook-text.ts, buildHookTextSurface). But the type an app writes its handler against, HookContext (packages/spec/src/data/hook.zod.ts, z.input<typeof HookContextSchema>), has no text member. Every app that adopts the feature writes a local type to call it. hotcrm did: HookTextContext in src/sales/objects/_hook-api.ts, used by its four text-writing hooks (objectstack-ai/hotcrm#2494 / #2522 / #2535, PR objectstack-ai/hotcrm#2652). The HookSchema.texts docstring's own example (await ctx.text('follow_up_subject', { lead })) does not type-check against HookContext.

Reach (measured once). @objectstack/spec 18.6.0: tsc over async (ctx: HookContext) => { await ctx.text('k') } answers TS2339: Property 'text' does not exist on type 'HookContext'. On objectstack main ba6556c6, the top-level keys of HookContextSchema are id, object, event, input, result, previous, submitted, dispatch, session, provenance, referentialFieldClear, referentialCascadeDelete, transaction, ql, api, notice and user. There is no text.

Expected: HookContext declares text?: (key: string, params?: Record<string, unknown>) => Promise<string>, the way it declares api and notice, so the documented call type-checks.

Seam. spec:HookContext → runtime:buildHookTextSurface (injected as ctx.text).

Reader. objectstack triage grades it and routes it to the spec/runtime lane. Not a claim; awaits triage. When it ships, hotcrm drops HookTextContext; that will be its own hotcrm card at the pin bump.

Dedupe (search/issues, repo:objectstack-ai/objectstack is:issue, open and closed):

Activity

  1. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    First touch: p2 · domain:spec · pm:queue. Not a queue jump. HookContext lacks the text member that 18.6.0's hook texts serve at runtime, so a typed handler needs a local type. The runtime call works; the gap is only the published type.

  2. added
    domain:spec
    pm:queue
    priority:p2
    on Nov 18, 2026
  3. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbabAdcWyApSTGBYJNY

    Ruling-ref: maintainer 14:43Z 「立一张专题卡,开始执行」 and 15:56Z 「domain 和优先级 不是已经定了吗?为什么现在不能改卡」 · regrade v3 under epic #35205

    Grade: p3 (was p2) · area:build · Bug · impeded × rare · HookContext declares no text; a local type works around it

  4. added and removed
    priority:p2
    on Nov 18, 2026
  5. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-sales · session_01L6bhgX6mQpVU8yUysiRAFC

    Claim: PM loop round 1 (repo:objectstack#1 card thread for #34575, area lease b1-A; this card rides the same PR)
    Session: session_01L6bhgX6mQpVU8yUysiRAFC
    Thread session: session_01L6bhgX6mQpVU8yUysiRAFC
    Account: os-sales
    Branch: claude/project-thread-lryneu (platform exception: this card thread can push only its assigned branch; shared with #34575, the chain head)
    Worktree: objectstack-issue-34575
    Domain: domain:spec
    Seat: repo:objectstack#1
    Area: b1-A
    File surface: packages/spec/src/data/hook.zod.ts (HookContextSchema gains a text member, declared the way api and notice are), a card-named test beside packages/spec/src/data/hook.test.ts (a typed handler calling ctx.text compiles; a reverse check), the spec generated artifacts the change makes stale (check:generated --fix), .changeset/**; full surface of the shared PR is on the #34575 claim
    Container & model: M, mode:thread, model: default (dispatch-gates --tier: no path-derived mandate; floor sonnet · default opus · ceiling fable; L2 owed at CONTRACT_REVIEW_TIER, separate isolated reviewer), effort: high
    Clause-②: yes
    Metadata-protocol: none
    Responsibility: objectstack: HookContextSchema in packages/spec/src/data/hook.zod.ts declares no text member while runtime buildHookTextSurface (packages/runtime/src/sandbox/hook-text.ts) serves ctx.text on every hook path | none: each app writes a local type (hotcrm HookTextContext) | every app that writes a typed handler calling ctx.text
    Thread-read: 6985066334
    Premise: holds — on origin/main 6f36818 the HookContextSchema object (hook.zod.ts:930) has no text key; notice is declared as a function member (precedent for the shape). The developer re-measures the TS2339 on a typed handler before writing code.
    Pre-claim lane: packages/spec/src/data/**; the repo:objectstack seat covers every domain, card carries area:build (lease b1-A).
    Pre-claim deps: none named; #34374 (the feature) is closed and on main.
    Prior rulings read: spec,hookcontext,declares,text,hook,typed,handler,call,local,type,ts2339 → 282 hits (broad terms; none rules against declaring the member); hook.zod.ts file-surface grep for ruling / maintainer / ⛔: 28 hits, governing ones #34374 6913660232 parameter 7 and the non-strict HookContextSchema header (members are declared, never strict); thread: 6985066334 (regrade to p3, no ruling on the shape); repo: objectstack-ai/objectstack.
    Serial constraints cleared: covered by the #34575 claim's overlap-check (hook.zod.ts was in the probe): exit 0, 0 open PR heads share a file.


    Generated by Claude Code

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 19, 2026
  7. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-sales · session_01L6bhgX6mQpVU8yUysiRAFC

    Delivered (2026-11-19T18:58Z): PR #35510 merged as b38e1330954f22e85e841aa9d31a975c72ca9ce1. HookContext declares text?: HookTextReader ((key: string, params?: Record<string, unknown>) => Promise<string>), the runtime's HookTextSurface exactly; @objectstack/spec takes a minor (Metadata-protocol: added). Residue labels pm:dispatched and lease:b1-A removed in this stroke.

    Partly reached for strict consumers, until #35512 lands: the member is optional, as this card asked and as api and notice are, so under strict a typed handler narrows with ctx.text?.(…) or ctx.text!(…), and the save-time literal check reads neither spelling today (#35512). A strict app such as hotcrm can drop its local type now with a narrowing, and gets the save-time check on that spelling once #35512 merges.


    Generated by Claude Code

  8. removed
    pm:dispatched
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:builddomain:specpriority:p3

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions