Repository navigation
feat: Claude Code plugin for flAPI, plus the fixes its crew rounds found (#211) - #222
Merged
Merged
Conversation
…plugin scaffold (#211) - Cache audit (audit.sync_events) records real start/end, duration_ms, rows_affected (DuckDB Count of the populate statement) and snapshot_id; failed refreshes and GC are timed too - Runtime metrics: per-endpoint / per-MCP-tool requests, status classes and latency histogram (allocation-free once a series exists), 401/403/429 rejections, per-cache refresh roll-up; on GET /api/v1/_config/metrics (?endpoint= filter), `flapii metrics` and the flapi_get_metrics MCP tool - Deprecate the no-op cache keys rollback-window / delete-handling with a load-time warning - Fix: global `rate_limit: {enabled: false}` failed startup with "bad conversion"; max/interval now default like the endpoint block and errors name the key - Plugin scaffold: marketplace.json, plugins/flapi (plugin.json, .mcp.json, validate-and-reload hook, 7 slash commands) - scripts/check_skills.py + make check-skills (CI: cli-integration): keys vs parser, CLI vs --help, template vars, version stamp, tagged examples run through --validate-config and a live server; --set-version for release prep - Docs: claude-code guide, README section, caching guide (first-run-safe append/merge templates, invalid MERGE syntax fixed, deletes, measuring and tuning), caching spec de-staled, metrics in OBSERVABILITY / API / MCP tool references, AGENTS.md maintenance rules, CHANGELOG - Fix the shipped customers cache example (Handlebars syntax, non-existent variables and columns) - Load baselines recorded at b6085f9 before the hot-path change; cheap and full gates pass
…ate preview (#211) - Skills: flapi-setup, -rest, -mcp, -auth, -cache-design, -cache-tuning, -testing, -live-config, -deploy, -operate (all tagged examples pass check_skills against the real server) - Refresh templates run in ONE transaction, statement by statement; a failure rolls everything back (a failed first build no longer leaves an empty table that warmup if-empty treats as built; a failed DELETE+MERGE no longer half-applies) - rows_affected is the sum of every DML statement's count - Cache audit by endpoint filters on the endpoint's url-path (was empty for endpoints with path parameters) - templates expand fills cache.catalog/schema/table; new ?target=cache / `flapii templates expand --cache` renders the populate template with the live watermark without running it
- check_skills: duckdb settings pass-through, key == "x" readers, per-skill group namespaces, shell operators end a command, global options before a subcommand, claude mcp add is not a flapi call, security auditor codes fail a group unless explicitly allowed (allow=CODE) - hook: reload MCP-only endpoints by name, FLAPI_BASE_URL fallback, show only the lines that explain a validation failure
…ng, probes and cache patterns (#211) - Config-service slugs are -customers, not GET-customers; Appendix A rewritten - CORS: no allow-list sends *, an allow-list echoes matching origins only - {{ params.x }} is bound only outside sections, for typed fields, never in quotes - Pagination is on by default (100 rows, limit/offset reserved); template LIMIT examples removed - Validator keys regex / allowedValues; field-type removed; log level names - self-packaging: refusals, embed:// for bundled data; serverless: /health/live liveness, persistent DuckLake paths, catalog lock with replicas - caching: full-refresh and serving templates, late rows and overlap, DuckLake single-action MERGE delete pattern, rows_affected sum, expand --cache for EXPLAIN - GCS needs an HMAC secret; bearer auth is HS256 JWT; MCP tool counts and provider names - AGENTS.md: conn.* / auth.* template variables, release assets, env syntax
…erialisation gaps (#211) - Parse and enforce endpoint auth.roles (403 JSON when no role matches) - Top-level auth: block is the default for endpoints without their own; auth: {enabled: false} opts out; inheritance count logged at startup - Accept auth.type jwt as an alias of bearer - project-description optional; validator values/pattern aliases - Load-time "has no effect" warnings: field-type, server-name, storage (local template path), connections.*.log-queries/log-parameters/allow - field-in: header read from request headers; DELETE runs its template; refresh-on-write refreshes asynchronously (REST and MCP) - 500 bodies no longer echo SQL or paths (request id instead) - Auditor: PBKDF2 not flagged, bcrypt flagged, passlib advice, CORS wildcard + auth warning; PasswordHasher accepts passlib ab64 - OIDC presets substitute tenant-id/realm/domain, validate at load, accept azure alias - log-level warn alias; unknown config value is a startup error - --version and config health report the build version - DECIMAL serialised exactly, timestamps with full precision - GCS credential log made truthful
…ce (#211) - Refuse a bare SELECT in a populate template before it runs; fail and roll back a refresh that did not create its cache table - cache.schedule fires without ducklake.scheduler.enabled (explicit false still opts out); scheduler.scan-interval is honoured; worker-interval default unified to 60 s - Seed the scheduler from warm-up / newest snapshot; never race warm-up - Global ducklake.retention is the default; expired files are deleted; audit snapshots (which pinned expired files) are bounded with the audit rows - Compaction parses its schedule (@hourly/@daily/@Weekly), runs once per catalog, rewrites delete-heavy files, and runs from the one-shot when due - cache_build_failed for a failed first build, logged once; failed warm-up over an existing table serves it stale; one warm-up per shared cache table - One-shot refresh reports duration_ms/rows_affected, names the catalog lock, --full - POST .../cache/refresh?full=true; UUID audit event ids - SIGTERM interrupts running cache refreshes/warm-up
… output fixes (#211) - MCP tools/resources/prompts lists are rebuilt when the endpoint snapshot changes - REST create/update/delete persist YAML via the loader's parser (keeps mcp-tool, validators) - Typed MCP schema defaults; one config token rule for REST and MCP (+ X-Config-Token) - Reload failure is 400 with a reason; schema tables/connections work; 405 for unsupported methods - Listening log after bind; config-service span labels; bundle validate path fix - Cache-not-ready 503s counted apart; percentiles clamped to max - flapii: server error bodies, --json-style only for config documents, FLAPI_URL, cache refresh --full, audit table, working project init sample, --connection
…compaction, full rebuild (#211)
… CLI output and casing (#211)
…ged fixes (#211) - Upgrade notes for every behaviour change (global auth, roles 403, header fields, DELETE, 500 bodies, scheduler defaults, bare-SELECT refusal, cache_build_failed, --full, config-service persistence, CLI flag renames) - Skills drop workarounds for fixed bugs and teach the real behaviour, with new runnable examples (global auth, header fields, DELETE, refresh-on-write) - Removed documented routes that do not exist
…der default_order DESC (#211) - A cache without template-file renders the endpoint's serving template; a single SELECT there now runs as CREATE OR REPLACE TABLE <cache> AS <select> (full refresh, audited as full) instead of being refused, and startup warns - duckdb.default_order is applied per connection when DuckLake is enabled: DuckLake's own connection read table columns reversed under a global DESC, so every catalog commit failed (Could not convert string ... to INT64) - examples: /customers/ builds its cache with customers_cache.sql and serves from it (customers-rest.sql); the shared cache section declares template-file
- A write without RETURNING reported the result's row count (always 1, the Count row); it now reports the Count value, summed over the statements - With RETURNING, the number of returned rows - Arrow streaming connections also get the per-connection default_order
- 200 {status, endpoint, mode, full, duration_ms, rows_affected, snapshot_id}
from the stats the refresh just recorded; status already_running when a
refresh of the table is in flight
- Errors as JSON {error, reason} instead of plain text
- flapii cache refresh prints the full-rebuild flag and the in-flight case
…ed (#211) - enabled defaults to true when the block sets type, roles, users, jwt-*, oidc or from-aws-secretmanager; only enabled: false opts out - Such an endpoint used to be open and counted as an opt-out of global auth - The global block no longer needs enabled to load; the effective setting is logged
- Their SELECT stand-in for a populate script is now materialised when no template-file is declared; the tests are about the watermark, not that
…e endpoints, persisted MCP update (#211) - PUT /_config/log-level and flapii config log-level set accept warn (and any case) as warning; list shows the alias - A partial PUT body in the YAML spelling merges onto the endpoint; a partial camelCase body takes url-path/template-source/method from the target; an unreadable body is 400, not 500 - Two files with the same url-path+method stop startup naming both; a reload that would duplicate fails with that reason; create answers 409 when any YAML in the templates dir declares the endpoint, loaded or not - MCP flapi_update_endpoint goes through the REST PUT merge+persist path - Created endpoint files are named after the url-path (/a/b -> a_b.yaml) - Reload errors carry error; compaction schedule error lists @midnight; compaction.schedule without compaction.enabled warns
…deletes (#211) - test_northwind_products_crud deletes product 17 on the shared examples server; the write tests ran after it and found nothing to update. Hidden until now because every examples-server test errored at setup
…211) - flapi_update_endpoint now persists, so updating /customers/ wrote into test/integration/api_configuration/sqls/customers.yaml; use a throwaway endpoint and remove the placeholder SQL that create leaves behind
- The file's string-column min/max statistics were inverted, so DuckDB pruned every row group and equality filters on c_mktsegment returned 0 rows - Same rows and schema, rewritten by DuckDB
…cit (#211) - Defer Crow's built-in OPTIONS answer until headers are parsed, so preflights get Allow-Origin/-Methods/-Headers, Max-Age and Vary: Origin - Echo requested headers; list Authorization, Content-Type, X-Config-Token, Mcp-Session-Id by name when auth is on - Endpoint auth blocks without type or credentials inherit the global credentials; otherwise fail with AUTH_NO_TYPE - Warn about auth keys the chosen scheme ignores (endpoint, global, mcp.auth) - 401s carry the configured scheme's challenge and a JSON body - Auditor: method in endpoint locations, empty mcp.auth.jwt-secret warning, fail-closed wording
…rces (#211) - resources/read runs the field defaults and validators on uri-template values (shared validateMcpParams with tools/call) and is shaped: mcp-resource.response (max-rows, redact-columns), else mcp-tool.response, else a 1000-row cap - every config-service slug route takes ?method=; a shared url-path without it is 400 ambiguous; list keys shared paths "METHOD /path"; reload/PUT/DELETE act on exactly that endpoint (reload by its file) - POST /api/v1/_config/endpoints/reload-file reloads or loads a YAML file; flapii endpoints reload --file; create of a file in template.path is 409 - duplicate MCP tool/resource/prompt names fail load/reload naming both files - templated resources only in resources/templates/list; empty read is [] - by-template matches cache template-file (role); expand and _dryRun render bound params as ? with a bindings list, typed parameters - dropped cursor watermark reported (expand --cache, refresh warning, audit) - metrics: role denials are rejected not failures, REST 401/403 attributed to the route, interpolated R10 histogram, p50 in flapii; /health caches.stale, data_age_seconds from the newest snapshot - one-shot cache refresh: usage errors exit 2, accepts --log-level/--no-telemetry - JSON 401s, -32001 for flapi_* token errors, rejected-token log line - flapii: --method, ':' literal, token-rejected guidance, REST+Tool, audit --table and message column, config validate uses template.path of --config, project init scaffold fixes - plugin hook: reload-file, render after reload, 401/403 reported, restart hint for flapi.yaml, SECURITY WARNINGS passed through - connection init errors name the connection; description scanner names the phrase; GCS warning only when gs:// is used
…file, metrics, CLI (#211) # Conflicts: # CHANGELOG.md
…ators, serialisation (#211) - Check Mustache section balance before crow compiles a template (load, reload, config-service template PUT, --validate-config, every render): a stray {{/x}} segfaulted, an unclosed {{#x}} hung with unbounded memory - Keep JSON body number text (9.99 was 9; 301.7 passed an int validator) - number validators parse/enforce min/max; MCP schema emits bounds only when set - DELETE endpoints are writes (MCP tool path); returns-data always has data - limit=0 has empty next; format allowed under request-fields-validation; duplicate query params are 400; required errors listed once; range messages name the limit - /doc.yaml: typed params, body schema, limit/offset/format, 400, X-* headers, endpoint description key - Cached reads skip the serialize-access source lock - Rows in SELECT column order, shortest doubles, no Z on naive TIMESTAMP - MCP serverInfo.version is FLAPI_VERSION
…, serialisation, cache-read locking (#211) # Conflicts: # CHANGELOG.md # src/mcp_route_handlers.cpp
…checks, CLI timeouts (#211) - template/expand?target=cache&validate_only=1: render with the live watermark, split statements, per-statement parse errors, bare-SELECT rule, bind each statement in a rolled-back transaction (CTAS bootstrap WITH NO DATA) - validate_only on the serving template binds the prepared rendering per statement; a cache not built yet is a cache_not_built warning - expand --cache with an unbalanced template is a 400 naming file:line - guard SELECT before the last statement: 'its result is discarded' message - /api/v1/_config/project reports bundled - hook: validates cache and serving templates (with sample typed params), notes an unbuilt cache, skips packed/other-project servers, honours FLAPI_CONFIG for a template.path outside the config dir - flapii: a request timeout says so instead of 'Is it running?'
#211) - Retention matches DuckLake's quoted create keys and every table id a cache has had (default schema, CTAS, --full rebuild); schema-aware table resolution; snapshot_id only when this refresh committed one - GC answers JSON; drop-table route + flapii cache drop-table; shared-snapshot warning in log and audit - Read-only replicas re-check unbuilt caches; 409 on cache template PUT; operation-specific messages - Redact DuckLake DSN secrets in logs and config API; warmup_effective - Packed cache refresh/extensions register the bundle first; embed:// outside a bundle; one-shot registers embed:// - Create DuckLake directories; explain lock conflicts; no spurious detach - pack excludes the DuckLake catalog, --exclude; template.path normalisation; time-travel 404; metrics endpoint; audit sync_type filter; compaction delete-threshold
…h, catalog redaction (#211) # Conflicts: # docs/CONFIG_SERVICE_API_REFERENCE.md # src/include/database_manager.hpp
…ooter describes interpolated percentiles (#211)
…ated database, keep the cache registry in step with reloads (#211) - P0: one populate/maintenance task at a time per DuckLake catalog; two refreshes attaching the same alias invalidated DuckDB until restart - DatabaseHealth: first 'database has been invalidated' error is fatal; /health and /health/live 503 status fatal, data/config requests 503 - Readiness/stats follow endpoint create/update/delete/reload - validate_only target=cache executes READ_ONLY ATTACH/DETACH - Cache routes and flapi cache refresh pick the cached endpoint; --method - POST /api/v1/_config/cache/compact and flapii cache compact - Audit/metrics/refresh full flag; time travel before schema -> 404; replica wording; reload-file of a deleted file unloads it; drop-table applies live tables' retention and names what pins files
…istry sync, cache routes (#211)
…hygiene, log/CLI/plugin fixes (#211) - Remember successful PBKDF2 checks (HMAC-keyed, 5 min TTL, 10k bound, cleared on auth reload); cap concurrent derivations - Unknown auth.type is a load/reload error (AUTH_UNKNOWN_TYPE) - Metrics latency measured from request start, rounded to 3 decimals - MCP tool errors generic + request_id; refused credentials 'not accepted'; ordered structuredContent and write rows - Response access lines carry request_id; log-format applies from the first startup line - flapii --version, honest -q, no duplicate error body - Plugin .mcp.json sends X-Config-Token + Bearer FLAPI_MCP_TOKEN; hook identity/staleness checks, deleted-file unload, AT() params
…giene, logging, CLI, plugin MCP entry and hook (#211) # Conflicts: # CHANGELOG.md
…211) - Early log lines now go through flapi's handler ([debug]) instead of Crow's default format ([DEBUG ]); the absence check was passing vacuously
…uplicates (#211) - /items/:id and /items/:item_id match the same requests; compared as strings both loaded and load order decided which one answered, so an endpoint with auth disabled could shadow an authenticated one (found by the exit-gate crew) - Routes are compared by the regex the router compiles, parameter names dropped - Docs: duplicate-route note, AUTH_UNKNOWN_TYPE is a load error, flapii error output, --full retention with several caches, init-attached checks after a rename publish
…_skills runs claude plugin validate (#211)
…e crash a worker (#211) - url-path: /customers/{cid} compiled to an invalid regex; every request that reached it in the endpoint scan threw out of routing and hung without an answer (health checks included) - Literal segments are regex-escaped ('.' matched any character), and a route that still fails to compile matches nothing and logs why once - Add urlPathProblem, routesOverlap and compareSpecificity: the url-path rules and the segment-wise precedence the loader and router use
…-loosening overlaps (#211) - method is trimmed and upper-cased at every parser (YAML, JSON, config service create/update); empty means GET; anything but GET/POST/PUT/PATCH/ DELETE is a load error / 400. 'method: get' beside a protected GET on the same route used to load and could answer without credentials - findEndpoint picks the most specific matching route (a literal segment beats a :param, left to right) instead of the first in load order, so rate limit, auth and the handler always agree and a reload cannot flip a URL to open - Overlapping routes whose more specific endpoint has looser auth are refused at load, reload-file, create and update unless it sets allow-shadowing: true; allowed overlaps are logged (WARNING if auth differs, INFO if not) - url-path is validated at parse time ({cid} -> suggest :cid) - Endpoint files load in sorted order; a reload keeps the endpoint's position - Config-service slug resolution prefers the most specific route
…auth (#211) - Creates through endpoint_files::CreateFromDocument: the real loader, global auth inheritance, duplicate and overlapping-route checks; refusals name the conflicting endpoint - New auth argument (the shape of a YAML auth: block); an unauthenticated result carries a warning and is logged - flapi_update_endpoint validates method the same way as REST PUT - Integration test reproducing every exit-gate bypass (lowercase method, literal vs param, /a/:x/b vs /:z/:x/b in both file orders, reloads of the protected file, create/update via REST and MCP, the {cid} hang)
…211) - CONFIG_REFERENCE: url-path rules, canonical method, allow-shadowing, precedence - Skills (live-config, api reference, testing, rest, auth), security and config-system specs, CHANGELOG upgrade notes
…romised it (#211) - Same on main: the URL is joined onto the config dir and the directory is listed with std::filesystem, so s3/gs/az/https template paths fail startup - Data files and DuckLake data paths on cloud storage are unaffected
…source included (#211) - A protected literal over an open :param route (/customers/7 over /customers/:id) loaded with a WARNING, but /customers/07 and /customers/+7 reached the open endpoint and the same row; now refused in either direction unless the more specific endpoint sets allow-shadowing: true - 'Same auth' now compares users (name, password digest, roles), a SHA-256 digest of jwt-secret, jwt-issuer, OIDC issuer/client/audience/claims and the AWS secret source; a literal with its own guest user is refused. Messages name the differing field, never a secret value - Refusal/warning text says the less specific route still serves every other URL its pattern matches, including other spellings of the same value - url-path refuses . and .. segments and repeated :param names, and names a non-ASCII character whole with its code point
- 'Overlapping routes with different auth' lines from --validate-config (an allow-shadowing split) go into additionalContext with SECURITY WARNINGS
…s any auth difference (#211)
…verlapping routes (#211) - A literal accepting expired tokens beside a general route passed as same auth - Document that identical-looking auth blocks must match byte for byte
…rver start (#211) - The mtime shortcut skipped the settings comparison for files up to 1 s newer than the server, so CI's quick edit was hot-reloaded instead of 'restart first' - Skip only files clearly older than the server; the comparison decides
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.
Summary
/plugin marketplace add DataZooDE/flapi,/plugin install flapi@flapi): 10 lifecycle skills (setup, REST, MCP, auth, cache design, cache tuning, testing, live config, deploy, operate), 7 slash commands (/flapi:init,new-endpoint,add-cache,auth-setup,deploy-check,diagnose,metrics), an MCP server entry, and a hook that validates config, hot-reloads the affected endpoints and checks every touched template after each edit.make check-skills, in thecli-integrationjob): config keys against the parser,flapi/flapiicommands and options against--help, template variables, version stamp, and 214 snippets / 30+ runnable example projects started and requested.auth:block were not enforced; overlapping routes could answer a protected URL without credentials (lowercasemethod, literal vs:param, load-order precedence, reloads), and a{x}url-path hung the server - requests now go to the most specific route, and overlaps whose auth differs in any way (identity source included) are refused unlessallow-shadowing: true;resources/readskipped validators; CORS preflights carried no CORS headers; error bodies leaked SQL and paths; catalog passwords were logged;duration_ms/rows_affected/snapshot_idin the audit; retention now frees disk (it never did under the default schema); the scheduler, compaction and global retention keys now do what they say;--fullrebuilds; cache-template preview and validation (templates expand --cache,validate_only);/api/v1/_config/metrics,flapii metrics,flapi_get_metrics), fatal-database health, method-aware config-service routes, reload by file, persistent config-service writes.docs/guides/claude-code.md. CHANGELOG## Unreleasedlists every behaviour change, with upgrade notes for those that can turn a working config or request into an error.Definition of done
test/load/baselines/b6085f9-*.json) before the first request-path change;compare.pygates pass on the cheap and full profiles after every fix batch. Final (6fec9ad): all latency metrics equal or better, full-mix throughput 57.2 -> 63.1 rps. The recording path is covered by a zero-allocation test.check_skills481 passed / 0 failed. No new skip / xfail / continue-on-error.Upgrade notes (see CHANGELOG)
Global
auth:now protects every endpoint without its own block; RESTrolesare enforced (403); duplicate routes (same shape, any method spelling) stop startup;methodmust be GET/POST/PUT/PATCH/DELETE; invalid url-paths ({x},*,./..segments, repeated:name) stop startup; the most specific route wins regardless of file order; overlapping routes whose auth differs stop startup unlessallow-shadowing: true; a remotetemplate.pathis documented as not working yet (#219); unbalanced templates and unknownauth.typestop startup/reload;intfields reject fractional numbers; 401/500 bodies are JSON;rollback-window/delete-handlingare deprecated no-ops; refreshes are serialised per catalog;/health/livecan answer 503 on a fatal database.Follow-ups
Filed as GitHub issues: #212, #213, #214, #215, #216, #217, #218, #219, #220, #221.
The old untracked
flapi-data-operatorskill in ai-stuff is superseded by this plugin; its~/.claude/skillssymlink is left in place until the maintainer confirms its removal.Test plan
make release && make testFLAPI_BUILD_TYPE=releasefull integration suitemake check-skills(also in CI)test/load/run_load.shcheap x5 + full x3,compare.pyagainst b6085f9npx vitest runclaude plugin validatepasses for the plugin and the marketplace;claude --plugin-dir ./plugins/flapi plugin details flapiloads 10 skills, 7 commands, the hook and the MCP server (~2.7k always-on tokens)${FLAPI_MCP_TOKEN:-}to an empty header valueCloses #211
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.