xiaoju
9443406703
fix(daemon): address all 12 PR #10 review items
...
🔴 Critical:
1. parseWorkerMessage() in ipc.ts — validates worker→parent IPC messages
2. signalIdCounter moved inside createKernel closure
3. throttle deferred trigger — pending trigger fires after window ends
⚠️ Warnings:
4. worker respawn on crash with backoff
5. stop() awaits worker exit with SIGKILL fallback
6. signal-bus handler errors caught, no re-throw
7. removed unnecessary as SenseReflexConfig cast
8. config validates sense reflex has at least one trigger
💡 Suggestions:
9. signal ID documented as process-scoped (solved by #2 )
10. +3 throttle-pending tests
11. +6 kernel unit tests (mock fork, message routing)
12. example imports verified correct
54 tests (was 45), all green. biome check passes.
小橘 🍊 (NEKO Team)
2026-04-22 09:34:13 +00:00
xiaoju
d9355a6299
feat(daemon): Signal Bus, Reflex Scheduler & Kernel (Phase 3)
...
- signal-bus: in-memory pub/sub for Signal dispatch, sync broadcast,
subscriber error isolation
- reflex-scheduler: interval + event-driven triggers, throttle enforcement,
merge/coalesce (pending flag, no unbounded queue), workflow reflexes skipped
- kernel: orchestrator tying workers, signal bus, and scheduler together,
graceful shutdown
- examples/nerve.yaml: cpu-usage (10s), disk-usage (30s), system-health
(on: [cpu-usage, disk-usage])
- 20 new tests (45 total): signal bus (8) + reflex scheduler (12)
Closes #4
小橘 🍊 (NEKO Team)
2026-04-22 08:56:38 +00:00
xiaomo
bf60047186
Merge pull request 'feat(daemon): Sense Runtime — Worker, IPC, Migrations, Peer Isolation' ( #9 ) from feat/sense-runtime into main
2026-04-22 08:48:30 +00:00
xiaoju
c80a6b9fa8
fix(daemon): address all 6 PR review items
...
🔴 Must fix:
1. compute timeout — AbortController + configurable timeoutMs, soft timeout
returns error Result (RFC §5.3)
2. migration journal — _migrations table tracks applied files, skips
already-executed migrations
3. IPC validation — parseParentMessage() validates type field, rejects
malformed messages with Result error
⚠️ Also fixed:
4. Self DB excluded from peers map
5. Per-sense compute serialization (mutex via Promise chain)
6. Unhandled rejection — .catch() on compute promise, errors sent via IPC
+10 new tests (25 total), biome check + vitest all green.
小橘 🍊 (NEKO Team)
2026-04-22 08:45:19 +00:00
xiaoju
a38986acdb
feat(daemon): sense runtime — worker, IPC, migrations, peer isolation
...
Implements the Sense observation engine runtime per RFC-001:
- IPC types: discriminated union for parent↔worker messages
- sense-runtime: openSenseDb (WAL), openPeerDb (readonly), runMigrations,
loadComputeFn, executeCompute with Result<T> error handling
- sense-worker: CLI bootstrap, reads nerve.yaml, inits per-sense DB,
builds peer map, enters IPC event loop
- examples/cpu-usage: sample sense with Drizzle schema + migration
- 15 unit tests covering migrations, DB ops, compute, peer isolation
小橘 🍊 (NEKO Team)
2026-04-22 08:45:19 +00:00
xiaomo
cf55f3bc3a
Merge pull request 'feat(core): Phase 1 — Core Types & Config Parsing' ( #8 ) from feat/phase-1-core-types into main
2026-04-22 08:43:36 +00:00
xiaoju
852cad9c60
docs(rfc-001): archival watermark + workflow_runs materialized table
...
- Cold archival: meta table with archived_up_to watermark for crash-safe recovery
- Workflow state: workflow_runs materialized table (UPSERT in same txn as log write)
- O(active) queries instead of full table scan
- Derivable from logs if lost
小橘 <xiaoju@shazhou.work >
2026-04-22 08:15:28 +00:00
xiaoju
f5c561173d
docs(rfc-001): add Log concept, append-only storage architecture, workflow event sourcing
...
- §2.4: Log as data asset, not trigger source (anti-avalanche constraint)
- §3: Add Log to terminology table
- §5.4: New storage architecture section
- Unified logs table (append-only SQLite)
- Workflow state via event sourcing (no mutable tables)
- Cold archival: >30d data exported to daily JSONL files
- §5.6: Error handling now writes logs instead of error signals
- §8: Directory structure updated with logs.db and archive/
- §10: Design principles updated (8 principles, +1 log rule)
- Thread outputs are now Logs, not Signals
小橘 <xiaoju@shazhou.work >
2026-04-22 08:06:09 +00:00
xiaoju
636b00c0a3
fix(core): address PR #8 review — gracePeriod, maxQueue default, drop+maxQueue guard, workflow name validation
...
- SenseConfig: add gracePeriod field (RFC §5.3 two-tier timeout)
- WorkflowConfig: discriminated union (DropOverflowConfig | QueueOverflowConfig)
- overflow: queue defaults maxQueue to 100
- overflow: drop + max_queue now returns validation error
- Cross-validate workflow reflex references against defined workflows
- Update tests: 21 cases covering all new behaviors
小橘 <xiaoju@shazhou.work >
2026-04-22 07:55:23 +00:00
xiaoju
8784a4edc4
refactor: duration fields → number|null (milliseconds)
...
- throttle, timeout, interval: string|null → number|null
- parseDurationField now returns parsed ms (5s→5000, 10m→600000, 1h→3600000)
- biome.json: ignore dist/** from checks
小橘 <xiaoju@shazhou.work >
2026-04-22 07:41:22 +00:00
xiaoju
1949007c99
refactor: ban optional properties, use T|null + discriminated unions
...
- Add coding convention: no '?:', use explicit 'T | null'
- ReflexConfig → discriminated union (SenseReflexConfig | WorkflowReflexConfig)
- All optional fields → explicit null (throttle, timeout, interval, on, maxQueue, workflows)
- Add exactOptionalPropertyTypes to tsconfig
- Add lib: ES2022 to tsconfig
- Refactor validateReflexConfig to reduce cognitive complexity
小橘 <xiaoju@shazhou.work >
2026-04-22 07:33:14 +00:00
xiaoju
3159d3713d
feat(core): add autoincrement id to Signal type
...
Timestamp alone can't guarantee strict total ordering (multiple signals
in the same millisecond). An autoincrement id provides a reliable
sequence for ordering and cursor-based pagination.
小橘 <xiaoju@shazhou.work >
2026-04-22 07:22:10 +00:00
xiaoju
3eba156b6b
feat(core): Phase 1 — core types & config parsing
...
- Define Signal, SenseConfig, ReflexConfig, WorkflowConfig, NerveConfig types
- Implement Result<T,E> with ok()/err() helpers
- Implement parseNerveConfig() with full YAML validation
- 14 unit tests covering normal and error paths
- pnpm run check passes with 0 errors
Closes #2
小橘 <xiaoju@shazhou.work >
2026-04-22 07:16:49 +00:00
xiaoju
3b22fde79c
chore(biome): 强化 lint 规则 — 用工具约束 coding conventions
...
- noDefaultExport: 禁止 default export
- noParameterProperties: 禁止 class 参数属性
- noNamespace: 禁止 namespace
- noExplicitAny: 禁止 any
- noUnusedVariables/Imports: 禁止未使用变量和 import
- noForEach: 用 for-of 替代
- useArrowFunction: 回调用箭头函数
- useImportType: type-only import
- useConst/noVar: 不可变优先
- noStaticOnlyClass: 禁止纯静态 class(用函数)
- cognitive complexity <= 15
2026-04-22 06:31:34 +00:00
xiaoju
d643ccf5af
fix: rename packages to @uncaged/nerve-{core,cli,daemon}
2026-04-22 06:29:08 +00:00
xiaoju
a7126c453f
chore: monorepo scaffolding — pnpm workspaces, biome, tsup, coding conventions
...
- packages/core, packages/cli, packages/daemon
- biome: noDefaultExport, useNodejsImportProtocol, noStaticOnlyClass
- docs/coding-conventions.md: 函数式优先,type over interface
2026-04-22 06:05:21 +00:00
xiaoju
643c353cc3
feat(rfc-001): 回应小墨 review — runtime 注入 db/peers、migration rollback、drizzle config、schema 新鲜度
2026-04-22 05:54:56 +00:00
xiaoju
8a3937f0e1
feat(rfc-001): Drizzle 作为 Sense schema 标准工具链
...
- schema.ts 为 single source of truth,migration 由 drizzle-kit 自动生成
- Sense 目录结构从单文件改为目录(schema.ts + index.ts + migrations/)
- 设计理由:开发者是 Coding Agent,确定性工具链优于概率模型自律
- 更新 §4.1 存储设计、§8 目录结构
小橘 <xiaoju@shazhou.work >
2026-04-22 05:36:17 +00:00
xiaoju
8379dae585
fix(rfc-001): 解决小墨 review 的生产风险问题
...
- 删除 Guard 表达式(when),条件判断由 Workflow 自己处理
- Workflow queue 加 max_queue 上限(默认 100)
- compute 超时改为两级:soft timeout + grace_period hard kill
- 热更新加 drain_timeout,防止长 thread 阻塞 reload
小橘 <xiaoju@shazhou.work >
2026-04-22 05:12:58 +00:00
xiaoju
6e49deaf99
refactor(rfc-001): Reflex 作为 Event Mesh,Sense 不知道 Workflow
...
- 删除 Sense → Workflow 桥接(ThreadStart payload),Sense 只产出数据
- Reflex 新增两种 action:TriggerCompute / StartWorkflow
- 引入 Event Mesh 概念:所有事件路由声明在 Reflex 中
- 更新依赖图、Haskell 类型签名、设计原则
- 删除 should-cleanup sense(改由 Reflex when 守卫实现)
小橘 <xiaoju@shazhou.work >
2026-04-22 05:02:14 +00:00
xiaoju
aba4580ff6
docs: polish RFC — fix Signal definition for Maybe, dedupe YAML config, merge §7 into §5, renumber
2026-04-22 04:28:41 +00:00
xiaoju
99d5549630
docs: unify compute return type to Maybe (T | null)
2026-04-22 04:25:51 +00:00
xiaoju
f08f37e14e
docs: clarify engine as kernel/event-hub, worker isolation, signal bus in-memory
2026-04-22 04:21:32 +00:00
xiaoju
96c740d175
docs: add §5 runtime model (process isolation, persistence, hot reload, error handling)
2026-04-22 03:39:29 +00:00
xiaoju
aa5b0c6349
docs: workflow concurrency/overflow, signal-thread boundary
...
Signal only kicks off Thread. Thread has its own event loop.
Thread output signals are execution logs for retrospection only.
小橘 <xiaoju@shazhou.work >
2026-04-22 03:12:42 +00:00
xiaoju
162c50b326
docs: Event → Signal terminology, add senses config with throttle, update reflex semantics
...
- Signal replaces Event/Observation as the term for Sense output
- Senses config in nerve.yaml for runtime properties (throttle)
- ReflexCondition: OnInterval | OnSignal [SenseId]
- OnDemand is engine-builtin, not declared
小橘 <xiaoju@shazhou.work >
2026-04-22 02:56:28 +00:00
xiaoju
b3beaf5e19
docs: add reflex semantics — interval origin, event compensation, idempotency
...
小橘 <xiaoju@shazhou.work >
2026-04-22 02:46:17 +00:00
xiaoju
a1785cf36a
fix: remove unused type parameter from Sense compute
...
小橘 <xiaoju@shazhou.work >
2026-04-22 02:40:02 +00:00
xiaoju
ec25c993d0
docs: RFC-001 Observation Engine — Sense, Reflex, Workflow
...
小橘 <xiaoju@shazhou.work >
2026-04-22 02:37:49 +00:00
xiaoju
79c1863f65
Initial commit
2026-04-22 02:36:18 +00:00