Skip to content

feat(coding-agent): add host request contracts - #1238

Open
sethkarten wants to merge 1 commit into
mainfrom
core00-host-request-contracts
Open

feat(coding-agent): add host request contracts#1238
sethkarten wants to merge 1 commit into
mainfrom
core00-host-request-contracts

Conversation

@sethkarten

@sethkarten sethkarten commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • define host request context contracts
  • add request contract coverage

Testing

  • Not run (per task instruction)

Note

Add host request handler contracts with context validation and forgery prevention

  • Introduces HostRequestContext interface in packages/coding-agent/src/core/kernel/index.ts providing per-call requestId, generation, AbortSignal, and isCurrent() for authority checks.
  • Adds createHostRequestHandler factory that enforces two-argument implementations and validates context via assertGenuineHostRequestContext before delegating to user code.
  • Adds assertHostRequestHandler guard that rejects forged handlers using a branded symbol plus WeakSet provenance tracking, preventing copied-symbol or raw-function spoofing.
  • Tests in packages/coding-agent/test/host-request-contract.test.ts cover factory rejection of unary implementations, invalid context detection, and forgery prevention.

Macroscope summarized 15b56d0.


Note

Low Risk
Additive kernel types and test utilities only; KernelManager still dispatches unary hostHandlers and is not modified here.

Overview
Introduces staged, context-aware host-request handler contracts in the kernel module while the existing unary HostRequestHandler registration path stays unchanged for now.

New HostRequestContext carries per-call dispatcher authority (requestId, generation, AbortSignal, isCurrent()). createHostRequestHandler wraps two-argument implementations, validates context before user code runs, and brands handlers via a symbol plus a WeakSet so only factory-minted functions count. assertHostRequestHandler rejects forged handlers that copy the brand without provenance.

Adds host-request-contract.test.ts for unary rejection, invalid context, and forgery cases, plus host-request-context.ts test helpers to invoke handlers with synthetic dispatcher context.

Reviewed by Cursor Bugbot for commit 15b56d0. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread packages/coding-agent/src/core/kernel/index.ts
Comment thread packages/coding-agent/src/core/kernel/index.ts
@sethkarten
sethkarten force-pushed the core00-host-request-contracts branch from 15844db to 15b56d0 Compare August 12, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant