Commit Graph

15 Commits

Author SHA1 Message Date
xiaoju 9f0c303056 feat: pre-allocated slot pool — zero DNS latency
- Pre-create fixed Worker slots (s-slot-0, s-slot-1, s-slot-2)
- Deploy/page-in only updates slot code, no Worker create/delete
- Subdomain always active, zero DNS propagation delay
- Slot = physical page frame, capability = virtual page
- New endpoint: POST /_api/init-slots
- Clean up old dynamic Worker naming
- 73/73 tests pass
2026-04-03 10:37:47 +00:00
xiaoju 49fb9a8c76 feat: Dynamic Workers LOADER — zero latency invoke — 小橘 🍊
- Replace child Worker subdomain routing with CF Dynamic Workers LOADER
- Code executes inline in Sigil Worker process, no DNS propagation needed
- Deploy → invoke immediately, zero delay
- LOADER.get() caches warm instances by capability+hash
- Remove cf-api.ts (no more child Worker management)
- All 67 tests passing
2026-04-03 10:13:59 +00:00
xiaoju 09e710101d fix: complete Dynamic Workers migration — all 68 tests pass — 小橘 🍊 2026-04-03 09:49:52 +00:00
xiaoju 120e62d7e4 fix: restore missing KV route methods and getWorkerName helper
- Added back KvStore.getRoute/setRoute/deleteRoute methods
- Added back WorkerPool.getWorkerName() private method
- Fixed deploy() to properly set route.worker_name with prefix

Tests passing: 56/68 (82%)
2026-04-03 09:43:19 +00:00
xiaoju ce4c2b7b36 refactor: migrate from CF API worker scripts to Dynamic Workers — 小橘 🍊
- Added worker_loaders binding (LOADER) to wrangler.toml
- Updated WorkerPool to use LOADER.get() instead of CF API deploy/delete
- Removed subdomain-based invoke; now uses Dynamic Workers directly
- Cleaned up config.ts (removed SUBDOMAIN_SUFFIX, PAGE_RATE_LIMIT)
- Simplified cf-api.ts to legacy cleanup only (LegacyCfApi)
- Updated all tests to use createMockLoader instead of createMockCfApi
- Removed PageRateLimitError (no longer needed)
- All API endpoints unchanged; migration is internal implementation only
2026-04-03 09:41:13 +00:00
xiaoju 3709fae5e1 fix: /run/{name} → 302 redirect, bypass CF same-zone fetch limitation
CF Workers cannot fetch() other workers on the same .workers.dev zone.
This caused all /run/{name} routes to return Cloudflare's HTML 404
instead of proxying to the sub-worker.

Fix: replace inline fetch() proxy with a redirect-based approach:
- Default (browser/curl): 302 redirect to sub-worker URL
- Accept: application/json: return JSON with {url, capability, cold_start}

LRU bookkeeping (page-in, access count) still happens in Sigil before
the redirect, so cold capabilities are warmed up transparently.

New backend method: resolveInvoke() — same LRU/page-in logic as invoke()
but returns route info instead of executing the subrequest.

Fixes: https://sigil.shazhou.workers.dev/run/* returning CF 404
Reported-by: 小墨 🖊️
2026-04-03 09:15:58 +00:00
xiaoju fd210c0edd feat: schema + execute abstraction for Agent-friendly deploy
- Agent provides schema (JSON Schema) + execute (function body)
- Sigil auto-generates full Worker code via codegen.ts
- Input parsing: GET query params + POST JSON body, auto type conversion
- Required field validation, default values
- find mode returns schema so Agent knows how to call
- Backward compatible: raw code deploy still works
2026-04-03 08:34:49 +00:00
xiaoju c3f3b822f1 feat: embedding semantic search + MMR for explore
- Use CF Workers AI bge-base-en-v1.5 for embeddings
- Deploy stores capability embedding in KV
- Query uses cosine similarity (find) and MMR (explore)
- Query embedding cached in KV (1h TTL)
- Fallback to string matching for capabilities without embeddings
- Mock embedding service for unit tests
2026-04-03 08:16:27 +00:00
xiaoju 513e84622c feat: unified query API + deploy metadata
- Add description/tags/examples to deploy params
- Replace /_api/list with /_api/query (public, no auth)
- find mode: precise, detailed, default limit=3
- explore mode: diverse, summary, default limit=20
- Relevance scoring + tag-based dedup for explore
- Delete old list endpoint
2026-04-03 08:02:09 +00:00
xiaoju 3705b158bb refactor: simplify to user-level shared capabilities
- Remove agent isolation (data sovereignty belongs to user, not agent)
- Capability naming: ping instead of xiaoju--ping
- Route: /run/{capability} instead of /{agent}/{capability}
- Auth: single deploy-token instead of per-agent tokens
- Delete S10 test (agent isolation no longer exists)
- Clean up old agent-prefixed workers
2026-04-03 05:49:20 +00:00
xiaoju b8b00f235e fix: enforce page-rate-limit on all invoke→page_in paths; loop eviction to prevent used_slots>total_slots; clamp status used_slots; fix S07 test to respect MAX_SLOTS=3 2026-04-03 05:42:03 +00:00
xiaoju 4be91b9bc8 fix: ESM multipart deploy + auto-enable subdomain — 小橘 🍊
- Fix CF API deploy to use multipart form (ESM modules need metadata)
- Auto-enable workers.dev subdomain after deploy
- Verified end-to-end: deploy + invoke + list + health all working
2026-04-03 04:30:14 +00:00
xiaoju cfac87411e feat: wire up real CF API for deploy/delete/invoke 2026-04-03 04:25:16 +00:00
xiaoju f20b19a71e feat: implement Sigil Phase 1 MVP 🔮
- Wrangler project setup (TypeScript + Vitest)
- SigilBackend interface + WorkerPool implementation
- KV store with layered key schema (code/meta/lru/route/auth/stats)
- LRU scheduler with eviction priority (ephemeral_expired > ephemeral > normal > persistent)
- AuthModule: Bearer token validation, agent isolation, deploy cooldown
- Router: /_health, /_api/deploy, /_api/remove, /_api/list, /_api/inspect, /{agent}/{capability}
- 13 test scenarios, all passing (38 tests)
- MockKV + MockCfApi for isolated testing

Tests: 38/38  | Build: 22KB gzip:5KB 

小橘 🍊(NEKO Team)
2026-04-03 04:17:43 +00:00
xiaoju 8d0a1e12ee init: Sigil capability registry 🔮 2026-04-03 04:08:31 +00:00