Commit Graph

241 Commits

Author SHA1 Message Date
xiaomo a7fd543648 feat(pulseflare): complete D1 event store Worker
CI / test (push) Has been cancelled
- Add Bearer token auth (API_TOKEN secret)
- Add POST /events/batch (max 100)
- Add GET /events?after_id= for cursor-based pagination
- Add POST/GET /instances for object instances
- Add POST /maintenance/archive for event cleanup
- Add D1 migration (0001_init)
- D1PulseStore fully implements PulseStore interface
- Type checks pass
2026-04-20 01:38:03 +00:00
xiaomo 7993ecc6d6 feat: extract @uncaged/pulse-local package, remove createStore from core exports
CI / test (push) Has been cancelled
Phase 2 of PulseDatabase abstraction:
- Create @uncaged/pulse-local with bun:sqlite implementation
- Core @uncaged/pulse now exports types only for store (no createStore/createScopedStore)
- Update pulse-workflows, upulse to import factories from @uncaged/pulse-local
- All tests passing (267 core, 39 pulse-workflows)
2026-04-20 01:34:46 +00:00
xiaomo 03ee151c72 feat(pulse): abstract PulseDatabase interface from bun:sqlite
CI / test (push) Has been cancelled
Phase 1 of pulseflare migration: decouple core logic from bun:sqlite.

- Add PulseDatabase/PulseStatement interfaces in database.ts
- Replace 'import { Database } from bun:sqlite' with PulseDatabase alias
  in defs.ts, projection-engine.ts, guard-projection.ts
- Update PulseStore.getDatabase() and ScopedStore.scopeDatabase() return
  types to PulseDatabase
- store.ts retains bun:sqlite as concrete implementation
- Export PulseDatabase/PulseStatement from package index
- All existing tests pass unchanged
2026-04-20 01:11:32 +00:00
xiaoju 75dc04a51d feat: guard defs table-only, lifecycle guard restored, daemon fault-tolerant
CI / test (push) Has been cancelled
2026-04-19 02:35:41 +00:00
xiaoju 3a4f4efdf1 feat: version-aware guard state — code_rev dimension (pulse#10)
CI / test (push) Has been cancelled
2026-04-19 00:15:47 +00:00
xiaoju 62696b71c9 fix: abort uses event-based lastRole instead of guard state (daemon restart safe)
CI / test (push) Has been cancelled
Guard state is not replayed on daemon restart, causing crashes when
lifecycle guard encounters events whose state transitions were lost.
Switched to checking summary.lastRole === '__abort__' which is rebuilt
from actual events every tick.
2026-04-18 23:08:42 +00:00
xiaoju 7b7a3300a7 feat: workflow abort via GuardProjection lifecycle (pulse#10)
CI / test (push) Has been cancelled
2026-04-18 23:04:13 +00:00
xiaoju c6e715fb3b fix: deduplicate guard-core exports in index.ts
CI / test (push) Has been cancelled
2026-04-18 22:56:44 +00:00
xiaoju 8361e0a66f fix: checker uses git diff HEAD (working tree) instead of HEAD~1..HEAD
CI / test (push) Has been cancelled
Coder may not commit changes, so HEAD~1..HEAD misses uncommitted files.
git diff --name-only HEAD catches both staged and unstaged changes.
2026-04-18 22:52:04 +00:00
xiaomo ff1efdf3d2 refactor: extract guard-core pure logic + fix check-before-transition (refs #9)
CI / test (push) Has been cancelled
2026-04-18 15:15:51 +00:00
xiaoju d6b607d610 feat: write __end__ event when workflow completes
CI / test (push) Has been cancelled
2026-04-18 15:09:14 +00:00
xiaoju aa89fdf144 fix: guard-projection tests — db sharing + async assertions + event format
CI / test (push) Has been cancelled
2026-04-18 15:08:18 +00:00
xiaoju 24dc6e88f0 fix: daemon loads gate role from engine (meta-gate-role crash fix)
CI / test (push) Has been cancelled
2026-04-18 14:55:24 +00:00
xiaoju b57a9d25ec Merge pull request 'refactor: restrict meta workflow to src/workflows/ scope' (#12) from refactor/restrict-meta-workflow-scope into main
CI / test (push) Has been cancelled
2026-04-18 14:40:18 +00:00
tuanzi 300eede226 refactor: restrict meta workflow to src/workflows/ scope
CI / test (pull_request) Has been cancelled
What: Tighten file scope for meta workflow coder and checker roles.
Why: Meta workflow should only modify workflow code under
$HOME/.upulse/engine/src/workflows/, not arbitrary project files.
Changes:
- meta-coder-cursor.ts: add prompt constraint to only modify src/workflows/
- meta-checker.ts: restrict allowedPrefixes from src/docs/test/ to src/workflows/ only
- meta-checker.ts: remove blacklist exemption for src/workflows/

团子 🐰
2026-04-18 14:26:02 +00:00
xiaoju 8ef1926772 feat: daemon supports engine directory override for workflow definitions (pulse#11 prep)
CI / test (push) Has been cancelled
2026-04-18 14:20:38 +00:00
xiaoju 6f4886db6a feat: GuardProjection — event admission control (pulse#9)
CI / test (push) Has been cancelled
- Add guard-projection.ts: registerGuard, checkGuards, applyGuardUpdates, getGuardState
- Guards use JSONata check + transition expressions, evaluated as data context
- Kind pattern matching with * wildcard (e.g. *.__start__)
- Integrate into store.ts appendEvent/appendEvents with transaction safety
- Handle nested transactions (inTransaction check)
- Export types and functions from index.ts
- 7 tests covering lifecycle, rejection, wildcards, complex expressions
2026-04-18 13:35:04 +00:00
tuanzi f59e3e7cb5 refactor: remove closer role from coding and coding-tdd workflows (#7)
CI / test (push) Has been cancelled
Co-authored-by: 团子 <tuanzi@shazhou.work>
Co-committed-by: 团子 <tuanzi@shazhou.work>
2026-04-18 13:31:12 +00:00
xiaoju b94a9046ac feat(workflows): subprocess role isolation
CI / test (push) Has been cancelled
Add createSubprocessRole() to run workflow roles in isolated child
processes. Roles that crash/hang/OOM no longer affect the daemon.

- subprocess-runner.ts: child process entry, reads stdin JSON, executes role
- subprocess-role.ts: createSubprocessRole() wrapper matching Role<unknown>
- 4 test fixtures + 4 passing tests (echo, error, timeout, crash)
- Exported from workflows/index.ts and main index.ts

小橘 🍊 (NEKO Team)
2026-04-18 11:36:54 +00:00
xiaomo 6c3888af48 feat: add Durable Objects delete migration for pulseflare
CI / test (push) Has been cancelled
- Add v2 migration with deleted_classes = ["PulseTick"]
- Required to deploy after removing DO from index.ts
2026-04-18 10:06:36 +00:00
xiaomo 5609cd36f4 refactor: pulseflare as passive event store + projection API (refs #5)
CI / test (push) Has been cancelled
- Remove durable-tick.ts and executor-sigil.ts (no more active ticking)
- Remove Durable Objects bindings from wrangler.toml
- Add CAS objects table to schema.sql
- Rewrite index.ts as pure API service:
  * POST /events - push events with auto-generated occurredAt
  * GET /events?kind&key&since&limit - query events
  * GET /projections/:key - get latest collect event meta for key
  * POST /objects - CAS store objects, return hash
  * GET /objects/:hash - retrieve objects by hash
  * GET /health - service health check
- No more /tick, /start, /configure, /status endpoints
- Pure passive event store, no rules engine or Sigil integration
2026-04-18 10:04:11 +00:00
xiaoju 40a7804dfb refactor: migrate business workflows to @upulse/workflows package
CI / test (push) Has been cancelled
- Move coding, coding-tdd, report, werewolf, cursor-health workflows
  to packages/pulse-workflows/
- Move analyst, architect, coder, renderer, reviewer roles to
  packages/pulse-workflows/
- Update all imports in migrated files to use @uncaged/pulse
- Update daemon and e2e files to import from @upulse/workflows
- Clean up core workflows/index.ts re-exports
- Add AgentExecutor, LlmRoleFactory, Scaffold exports to core index.ts
- Core package: 25 tests pass, workflows package: 40 tests pass

小橘 🍊 (NEKO Team)
2026-04-18 09:56:43 +00:00
xiaoju a3db066808 feat: add checker role to meta workflow (coder→checker→tester→END)
CI / test (push) Has been cancelled
- checker validates file scope, build, unit tests before e2e
- tester enhanced with diagnostic info on failure (event chain, last role, meta)
- tester no longer duplicates build (checker handles it)
- 6 meta workflow tests, 78 total pass
2026-04-18 09:39:28 +00:00
xiaoju 695dac8106 feat: register report workflow in daemon (analyst+renderer) 2026-04-18 09:39:28 +00:00
xiaomo 25591e2c21 fix: D1 bind params must be spread, not chained (refs #5)
CI / test (push) Has been cancelled
2026-04-18 08:12:37 +00:00
xiaoju b533094792 fix: tester detects completion by quiescence, not __end__ event
CI / test (push) Has been cancelled
Adapter doesn't write __end__ events — moderator returns END and
tick produces executed=[]. Now tester checks: did at least one tick
execute, then quiesced = completed.
2026-04-18 08:11:06 +00:00
xiaomo 1ba77929e6 feat: pulseflare real tick logic — rules + snapshot + sigil executor (refs #5)
CI / test (push) Has been cancelled
- Implement real Pulse tick logic in durable-tick.ts
- Add snapshot rebuild from D1 collect events
- Add pulse() method with demo rules (CPU spike detection, heartbeat)
- Add adaptive tick logic (30s base, up to 5min backoff)
- Add /configure endpoint for senseKeys and configuration
- Add CAS object storage in store-d1.ts
- Update index.ts with /configure route
- Persist prev snapshot in DO storage
- Execute effects through Sigil with error handling
2026-04-18 08:09:04 +00:00
xiaoju 7168b68896 feat: tester e2e verification — dynamic import + tick lifecycle + commit/push
CI / test (push) Has been cancelled
Tester no longer duplicates build+test (that's coder's job).
Instead: dynamic-import workflows from engine dir, spin temp store,
tick to __end__, verify lifecycle completes. Workflow-agnostic.
2026-04-18 08:02:53 +00:00
xiaomo 70be73efde chore: update pulseflare D1 database_id (refs #5)
CI / test (push) Has been cancelled
2026-04-18 07:54:05 +00:00
xiaomo 272aa9728a feat: pulseflare package — CF Workers + D1 runtime (refs #5)
CI / test (push) Has been cancelled
2026-04-18 07:51:37 +00:00
xiaoju ad25161a8f refactor: merge promoter into tester — meta workflow now coder → tester → END
CI / test (push) Has been cancelled
2026-04-18 07:48:25 +00:00
xiaoju be2d9de6b1 fix: werewolf test async + e2e tick loop
CI / test (push) Has been cancelled
2026-04-18 07:06:40 +00:00
xiaoju 1afce01335 refactor: simplify meta workflow — coder → tester → promoter 2026-04-18 07:03:33 +00:00
xiaoju 2a17dcc892 feat(workflow): add werewolf game workflow
CI / test (push) Has been cancelled
2026-04-18 05:58:10 +00:00
xiaomo d9717ab941 fix: correct stale test assertion in cursor-agent.test.ts
CI / test (push) Has been cancelled
The test was checking for 'Bug Fix' but the mock data has title: 'Fix bug' and the prompt builder uses the title directly. Remove the incorrect assertion.

Made-with: Cursor
2026-04-18 03:21:36 +00:00
xiaomo 39d58f58c1 chore: remove stale test files for deleted modules (council, container)
council.test.ts and container.test.ts reference modules that were removed in a previous commit (b65e9d6). These files cannot run and cause test suite failures.

Made-with: Cursor
2026-04-18 03:19:07 +00:00
xiaomo 0b2f3073b5 style: apply biome formatting to test files
Made-with: Cursor
2026-04-18 03:16:27 +00:00
xiaomo 125aafaa12 fix: adapt test files for async PulseStore (refs #5)
CI / test (push) Has been cancelled
- Fixed await patterns in index.test.ts, objects.test.ts, scoped-store.test.ts
- Converted expect(await store.method()) patterns throughout test files
- Fixed rebuildSnapshot async calls in E2E tests
- Made test functions async where needed for store operations
- Reduced test failures from 35+ down to 6 (remaining are mostly unrelated)
2026-04-18 03:13:26 +00:00
xiaomo d56d0fd435 style: apply biome formatting to pulse-cursor
Made-with: Cursor
2026-04-18 03:08:29 +00:00
xiaomo 145be974f3 fix: adapt pulse-cursor package to async PulseStore API
Make resolveTask and resolveProject async and await their store.queryByKind calls

Made-with: Cursor
2026-04-18 03:08:12 +00:00
xiaomo 6062e692ac fix: adapt upulse package to async PulseStore API
Update upulse commands and UI server to await all async store methods. - Make CLI action callbacks async (workflow create, timeline, list, inspect events/object) - Make daemon status function async - Make all UI server handler functions async with awaited store calls - Fix Promise.all patterns for getObject calls in map functions - Fix scopedStore.close() calls to be awaited

Made-with: Cursor
2026-04-18 03:07:20 +00:00
xiaomo 3313f29954 fix: resolve lint errors in test files for async refactor
- Make non-async helper functions async (triggerCoding, triggerWorkflow, writeVitalAndRebuild, writeEffectEvent, cleanup, trigger) - Fix bad await placement in object literals (await hash: -> hash: await) - Fix await in non-async arrow callbacks and await data: object property - Convert expect(async).toThrow() to rejects.toThrow() for async functions - Fix Promise.all pattern for async getObject calls in map - Remove stray await before return statements - Fix db.close() (sync bun:sqlite API) wrongly awaited - Auto-fix formatting issues via biome

Made-with: Cursor
2026-04-18 03:01:24 +00:00
xiaomo 6f753ae68e test: await async store/defs calls in all test files
Update all *.test.ts files to properly await the async PulseStore, ScopedStore, and defs functions. Fix gc.test.ts timing issues for async GC trigger, fix bad await assignment targets, and correct .length access on Promise objects.

Made-with: Cursor
2026-04-18 02:57:30 +00:00
xiaomo ca3dd52e38 refactor!: async PulseStore interface for multi-runtime support (refs #5)
CI / test (push) Has been cancelled
- PulseStore/ScopedStore 接口方法返回 Promise<T>
- 所有 store 实现方法改为 async(bun:sqlite 同步调用外包 async)
- defs.ts, projection-engine.ts, gc.ts 公共函数异步化
- index.ts 中 store 调用加 await
- rules/health.ts rebuildHealth 函数异步化
- 核心异步化完成,支持 CF D1 等异步数据库运行时

Breaking Changes:
- All PulseStore methods now return Promise<T>
- Consumer code must add await for all store operations
- Tests need to be updated to use async/await patterns
2026-04-18 02:50:12 +00:00
xiaomo 80eeac03c2 docs: Pulseflare runtime analysis report (refs #5)
CI / test (push) Has been cancelled
2026-04-18 02:24:52 +00:00
xiaoju 0517007d40 chore: remove legacy broker code (pulse#6)
CI / test (push) Has been cancelled
2026-04-18 02:09:59 +00:00
xiaoju 5ccd50221c refactor(rollback): extract performRollback + add 6 tests
CI / test (push) Has been cancelled
- Extract core logic into testable performRollback(opts) function
- CLI action now delegates to performRollback and prints output
- Tests cover: dry-run, event export/delete, git checkout, missing
  commit error, noop when already at target, dump metadata
- All tests use tmpdir, no dependency on ~/.upulse
2026-04-18 01:39:22 +00:00
xiaoju 8754ff51cd feat(upulse): add rollback command — time-machine revert for engine
CI / test (push) Has been cancelled
- upulse rollback <commit> [--dry-run] [--engine <path>] [--events <path>]
- Exports events after cutoff to .pulse/rollbacks/rollback-<date>-<commit>.db
- Deletes those events from events.db
- Clears projection cache
- git checkout target commit in engine
- Also adds migrate.ts stub (missing file)

Ref: pulse#3
2026-04-18 01:34:26 +00:00
xiaoju 37e3331ccb feat(workflow): add in-memory checkpoint for incremental tick
CI / test (push) Has been cancelled
- WorkflowCheckpoint caches lastEventId, topic summaries, and per-topic events
- First tick: full read (getAfter(0)), subsequent ticks: incremental (getAfter(lastEventId))
- Newly written role events also update checkpoint in-place
- No interface changes, no new files
2026-04-18 01:30:01 +00:00
xiaomo 90f7ba5a62 feat: export new CursorCall interface and executeCursorTask function
CI / test (push) Has been cancelled
2026-04-17 15:28:29 +00:00