Repository navigation
Description
Problem or use case
An application has native session authentication but needs custom business behavior keyed to the signed-in account. Today the supported direct identity consumer is a custom extension handler: request.principal carries the verified opaque {id, provider}. A plain route function guarded by auth: true does not receive that principal, and auth's session-authorize branch does not populate the existing reserved identity header that its bearer branch produces.
This is a narrower follow-up to #618, not a claim that its implementation is missing. #618's generic trusted extension-to-guest reserved-header channel works, and bearer authentication already uses it. #331 implemented the separate opaque principal channel for extension consumers. The current documentation explicitly says that opaque principal does not reach route function/middleware guest code.
A small novel-behavior pilot on the exact published 0.6.5 packages asked for authenticated room membership, an exclusive controller, and durable application-specific transitions. It used native auth's wire contract, so this is not the fixed external API mapping problem in #828. One URLCode trial made 45 discovery/setup tool calls before its first source edit, then exhausted its $2.50 estimated model-cost allowance after beginning implementation. This observation does not isolate identity discovery as the cause or establish that adding an API will improve performance.
An independent generic integration probe did establish the working alternative: native authentication plus an app-local extension passed 11 checks, including verified principal delivery, anonymous denial, write-CSRF denial, foreign-origin denial and logout denial. This establishes the supported identity integration, not completion of the application. The question is whether every otherwise-small authenticated custom handler should need extension registration/activation merely to know the caller's opaque account id.
One trial generated this route/extension registration excerpt while implementing the custom behavior (excerpt only, not a complete independently validated application):
extensions:
rooms: {version: "1", config: {}}
routes:
/api/*:
extension: rooms
methods: [GET, POST, DELETE]
auth: {csrf: token}Verified source and contract:
- Auth authorize implementation: bearer branch writes the reserved derived-principal header; session branch sets the opaque extension principal after its auth and CSRF checks.
- Runtime guest projection: guest headers derive from extension-request headers with credentials withheld; FunctionContext is built without the extension principal.
- Public request-principal contract: opaque principal reaches extension hooks/handle, not ordinary function/middleware guests.
Proposed behavior and alternatives
Evaluate a first-party, bounded way for an ordinary auth: true function/middleware route to read a verified opaque session-derived identity without receiving cookies, bearer credentials, or a service object and without writing its own identity bridge extension.
Prefer evaluating an auth-owned producer over the already-implemented #618 reserved-header mechanism before introducing a new core context semantic seam. A new session-specific header/typed accessor could preserve the existing bearer header's established shape. Alternatively, expose the generic opaque {id, provider} in function context if that is the cleaner portable behavioral contract; core must remain unaware of auth. Do not choose the representation solely from this pilot.
Preserve the important existing properties: inbound identity spoofing is stripped; only successful authorization commits identity; denied writes do not reach custom logic; credentials remain withheld; requests cannot inherit another request's identity. Prove trusted/sandbox behavior and explicit unsupported-target refusal for whichever surface is selected. Identity identifies an account; it does not replace application membership/ownership authorization.
A lower-cost alternative is a tested, discoverable generic authenticated-custom-handler scaffold or bounded authoring entrypoint over the public extension API. #741 already documents external extensions, #427 already provides bounded planning, and #759 already supports bounded documentation fallback; evaluate a focused composition/example in those existing surfaces instead of creating another general tool. Compare that alternative against the proposed identity projection on unseen custom-behavior tasks, with frozen checks and matched budgets. Keep any task-specific room/controller logic outside the scaffold.
Not verified: no implementation or API design comparison has been run; the pilot does not establish identity projection as the sole discovery bottleneck or prove a speed improvement. This request should not reopen #618 as broken or imply that custom authenticated behavior is currently impossible.
Activity
jimhoyd commentedon Sep 28, 2026
A second integration-discovery pattern from all three original pilot sources: each began maintaining a separate known-account index via lifecycle hooks to validate room membership. One added create/delete hooks and a users map, one wrote
known-users.json, and one addedmarkAccountKnownin its room store. These were incomplete, unaccepted artifacts, so this describes source intent rather than proven behavior.The native auth operator service already has a public
getUser(id)lookup. A trusted host can pass a narrowuserExistscallback into an app-local extension without exposing credential-bearing service objects to guest code. The guided control uses that supported path. This does not imply core should import auth or that an entire service should reach function context.When testing the generic custom-handler/scaffold alternative in this issue, include discoverability of existing native service access as well as verified principal access. The desired outcome is avoiding duplicated application plumbing while keeping the novel business rules application-owned. This evidence still does not isolate a causal fix or establish an API speed gain.
jimhoyd commentedon Sep 28, 2026
The completed guided capability control passed initial102/102, seed102/102, restart/update retention13/13 and hidden-change behavior182/182, using native auth and public extension APIs with a narrow getUser callback. No application behavior repairs were needed after first HTTP execution (a syntax typo was fixed before that). This establishes expressibility of the selected workflow; it does not establish autonomous authoring speed or prove the proposed API improvement. Full matched-agent results, corrective repeat and limitations: https://github.com/jimhoyd-com/urlcode-benchmarks/issues/99#issuecomment-5861655503
jimhoyd commentedon Sep 28, 2026
The alternative proposed here—one generic authenticated-custom-handler scaffold over the existing public extension API—now has preliminary positive evidence across two distinct workflows.
Full attempt ledger, methods and limitations.
The same frozen adapter supplied verified opaque native identity, parsed JSON and a narrow public account-existence callback; it contained no business rules or persistence helper. Two fresh approval builds and one unseen inventory build completed their frozen initial and hidden-change suites while preserving native core/auth and the adapter. The first adapter attempt was invalid due to an outside native Write/broad search and remains counted. A prepared-native baseline with identical working auth/key setup and focused documentation first edited at9m34s and timed out at10minutes. Fresh approval adapter builds first edited at1m14s/2m20s and did no installed-framework/internal discovery.
Important qualification: an extra valid-string-key test found the same business-code bug in both inventory conditions (adapter and Fastify). Both captured repairs pass expanded checks; the adapter model finished within the equal120s allowance, while Fastify's response timed out after editing working code. Repairs, costs and post-timeout diagnostics are separately scored; no blanket correctness or speed claim is supported.
Recommendation: evaluate a first-party generic scaffold and its discoverable entrypoint as the next bounded product experiment, alongside the session-identity projection option. This supports the scaffold hypothesis, not this exact prototype as a public API. Preserve inspectable per-route authorization/capabilities: the prototype wildcard mount loses route-level visibility. The interface is trusted Node/JSON; it does not establish sandbox portability. Scaffold construction/review was unmetered and excluded from authoring times. No hosted URLCode.ai, streaming MCP or second AI was tested, and no core change or deployment was made.
jimhoyd commentedon Sep 28, 2026
Implemented the narrow session-identity handoff and ordinary
authenticated-handlersrecipe in draft PR #833 (f17b724). Native auth writes only the opaque user ID after authorization, CSRF and accepted principal assignment;sessionUserId(request)reads it. Trusted and sandbox-local request paths, credential withholding, spoofing/denial cases and unchanged imports through packed installation are covered. Full verify, package smoke and all 32 CI checks passed. No merge/publication/deployment yet.The six unfamiliar-app trials are complete, with exact source/package hashes and no builder reruns. This does not establish a general productivity advantage: one candidate and two Fastify artifacts completed the frozen build/change sequence. The valid ledger pair took candidate 411.945 vs Fastify 423.282 total model seconds, but a separate review/probe found a candidate business-handler denial-ordering defect missed by the original suite. Timeout and boundary-invalid trials remain in the denominator.
Full evidence and limitations: https://github.com/jimhoyd-com/urlcode-benchmarks/issues/99#issuecomment-5863156351. Follow-ups are #834 (executable validation handoff), #835 (bounded conditional state transitions beyond current store primitives), and benchmark #108 (checker/contract gaps and generated ordering defect). All candidate artifacts used native auth and ordinary explicit YAML function routes, so the integration seam itself is useful without a custom bridge. The broader authoring advantage remains unproven.
feat(auth): expose session identity to ordinary function routes (#833)