Repository navigation
Add function and middleware short forms that expand to the long form - #96
Merged
Merged
Conversation
…84) `function: functions/hello.mjs` and string `middleware` entries are now valid YAML. Document validation expands them before anything else reads the route: every `{param}` in the path becomes a required string input (minLength 1, maxLength 128) plus a matching `args` entry unless the route declares that parameter itself, and a middleware string becomes `{source}`. Invalid strings are refused with the route named. The long form stays the canonical IR, so routes, audit, explain, revision hashes and the generated reference show the expansion. The MCP create_route tool now writes the short form and relies on the same normalizer. The cookbook /api/items route uses the short form (40 routes, unchanged). Guide, specification, authoring matrix, reference and llms-full.txt updated; tests cover deep-equal IR, declared parameter override, string middleware, refused strings and a request through the runtime. Closes #84 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AQ3ZGqNtWviSYfUMsxU54E
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01AQ3ZGqNtWviSYfUMsxU54E
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and change
The smallest function route was ten lines: a
parametersblock, afunction.sourceand anargsmap for every{param}. NEXT-STEPS §4.1 asks for a short form.function: functions/hello.mjs(a string) and stringmiddlewareentries are now admitted byschemas/urlcode.schema.json.validateDocumentruns a separatenormalizeRoutepass (alongside the existingnormalizeRouteAuth) that expands them before anything else reads the route: each{param}in the path becomes a required{type: string, minLength: 1, maxLength: 128}input plus a matchingargsentry, unless the route already declares that path parameter (declared parameters keep their schema and order); a middleware string becomes{source}. Strings must be project-relative.mjs/.jspaths without..; anything else is refused with the route path named.routes,audit,explain, revision hashes and the generated reference show the expansion.create_routetool now writes the short form into YAML and delegates expansion to the same normalizer (its previous private expansion usedmaxLength: 256; one rule now)./api/itemsconverted to the short form (route count stays 40, existing fixtures cover it).docs/yaml/functions.mdopens with the short form and shows the expansion,docs/SPECIFICATION.mddocuments the normalization,docs/AI-AUTHORING.mdmatrix row added,docs/YAML-REFERENCE.mdregenerated,llms-full.txtrebuilt.test/config.test.ts): short and long forms validate to deep-equal documents, declared parameter override, string middleware, refused strings citing the route, and a request served through the runtime (including the 128-character bound).Verification
npm run verify(lint, typecheck, check incl. reference/llms-full staleness, build, tests): exit 0.npm teststandalone: 456 tests, 416 pass, 37 skipped (SQLite WAL skips), 3 timing-sensitive failures (sync function hangs time out,versioned fixture ... adapters,deadline kills the worker) that pass when re-run in isolation and passed inside the verify run.node src/cli.ts audit --project examples/cookbook --expect-routes 40: 40 routes, 136/136 checks pass.Compatibility and security
Additive YAML change;
version: "1"and every existing long-form document validate unchanged. No new permissions, bindings or network behaviour: a short-form source goes through the samesafeFileconfinement as before after expansion. No data handling or deployment impact.Closes #84
🤖 Generated with Claude Code
https://claude.ai/code/session_01AQ3ZGqNtWviSYfUMsxU54E
Generated by Claude Code