#156

Resource-bound endpoints cannot be estimated through the CLI or test helper

Opensdivyanshu90opened 12d ago

I cannot obtain a pre-run estimate for endpoints with resource bindings through either engine:estimate or the shared estimateEndpoint helper. Both construct an Engine without a ResourceReader, so loading fails before the pure estimate hook can run.

From the repository root with Deno 2, run:

deno task engine:estimate 'saperly#list-numbers'

I get a nonzero exit and:

EngineError: [NO_RESOURCE_READER] saperly#list-numbers declares resource bindings but EngineCtx carries no ResourceReader

The testing helper has the same failure:

deno eval 'import { estimateEndpoint, testSealedUnit } from "./shared/testing/mod.ts"; console.log(await estimateEndpoint(await testSealedUnit("saperly#list-numbers"), {}));'

I expect the CLI to print:

{
  "endpoint": "saperly#list-numbers",
  "credits": {},
  "evidence": {}
}

The helper should return { credits: {}, evidence: {} }. The same loading failure prevents estimating metered bound endpoints such as saperly#place-calls, even with valid input. This blocks cost previews and connector estimate assertions without making an upstream request.

Engine.load deliberately requires a reader for bound documents. LoadedEndpoint.estimate only validates input, invokes the pure estimate hook, and folds the rate card; it does not query ownership. loadEndpoint already wires a fixture reader, but estimateEndpoint in shared/testing/runner.ts and the standalone scripts/estimate.ts entry point omit it.

I propose wiring an empty reader in these two estimate entry points, preserving the existing Engine.load requirement and rejecting transport. Regression coverage should include a free bound endpoint, a metered bound endpoint without owned rows, and invalid-input rejection.

I searched open and closed issues and PRs for estimateEndpoint, NO_RESOURCE_READER, engine:estimate, and resource estimates. I found the original resource lifecycle work (#38/#37), but no report or fix for these two entry points.

Activity

0

No activity yet.