@zq-silk/yui 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/artifacts/artifactCapability.js +14 -8
  2. package/dist/artifacts/artifactCommitLock.js +7 -5
  3. package/dist/artifacts/jobArtifact.js +93 -0
  4. package/dist/artifacts/jobArtifactTransport.js +13 -0
  5. package/dist/artifacts/taskArtifactRepository.js +58 -10
  6. package/dist/cli/commandCatalog.js +45 -14
  7. package/dist/cli/commandDiscovery.js +1 -1
  8. package/dist/commands/durableJobCommands.js +31 -6
  9. package/dist/commands/globalRoleCommands.js +5 -0
  10. package/dist/commands/scheduleCommands.js +14 -3
  11. package/dist/commands/taskCommands.js +5 -2
  12. package/dist/context/taskCatalog.js +6 -1
  13. package/dist/controlPlaneCli.js +7 -2
  14. package/dist/controller/agentJobControl.js +391 -0
  15. package/dist/controller/controller.js +24 -3
  16. package/dist/controller/fileSchedulerStoreAdapter.js +12 -1
  17. package/dist/controller/globalInputDelivery.js +8 -1
  18. package/dist/controller/jobArtifactControl.js +111 -0
  19. package/dist/controller/jobControl.js +4 -0
  20. package/dist/controller/jobDefinitionControl.js +191 -19
  21. package/dist/controller/jobSupervisor.js +83 -3
  22. package/dist/controller/jobTaskDelegationControl.js +193 -0
  23. package/dist/controller/runtime.js +7 -1
  24. package/dist/controller/scheduleControl.js +83 -20
  25. package/dist/integration/gitIntegrationService.js +2 -0
  26. package/dist/job/agentJob.js +131 -0
  27. package/dist/job/agentJobObservation.js +61 -0
  28. package/dist/job/agentRoleScope.js +33 -0
  29. package/dist/job/durableJob.js +63 -28
  30. package/dist/job/jobAssignmentScope.js +1 -0
  31. package/dist/job/jobBusinessResult.js +72 -0
  32. package/dist/job/jobCleanupInspection.js +4 -0
  33. package/dist/job/jobDefinition.js +26 -2
  34. package/dist/job/jobRunner.js +4 -3
  35. package/dist/job/projectRefreshRunner.js +54 -18
  36. package/dist/job/projectSync.js +162 -0
  37. package/dist/job/scheduleService.js +55 -0
  38. package/dist/job/taskDelegation.js +48 -0
  39. package/dist/message/messageContinuation.js +1 -1
  40. package/dist/resources/projectResourceService.js +1 -1
  41. package/dist/resources/resourceGc.js +1 -1
  42. package/dist/role/role.js +12 -0
  43. package/dist/schedule/schedule.js +65 -15
  44. package/dist/scheduler/wakeReason.js +4 -0
  45. package/dist/storage/agentJobSchema.js +10 -0
  46. package/dist/storage/recordValidation.js +2 -0
  47. package/dist/storage/sqliteSchema.js +77 -6
  48. package/dist/storage/sqliteStore.js +53 -0
  49. package/dist/storage/storageVersions.js +1 -1
  50. package/dist/storage/storeRpc.js +3 -0
  51. package/dist/storage/taskCatalog.js +10 -2
  52. package/dist/storage/upgrade/jobBusinessResultMigration.js +20 -0
  53. package/dist/storage/upgrade/scheduleDispatchMigration.js +15 -0
  54. package/dist/task/archivePreflight.js +15 -0
  55. package/dist/task/completionReadiness.js +7 -0
  56. package/dist/task/task.js +17 -1
  57. package/dist/verification/verificationGateService.js +4 -0
  58. package/dist/web/assets/client/app/catalog.js +16 -0
  59. package/dist/web/assets/client/i18n/en.js +29 -2
  60. package/dist/web/assets/client/i18n/zh-CN.js +29 -2
  61. package/dist/web/assets/client/layout/manageShell.js +9 -0
  62. package/dist/web/assets/client/layout/router.js +1 -0
  63. package/dist/web/assets/client/views/jobs.js +166 -37
  64. package/dist/web/assets/client/views/task/files.js +5 -4
  65. package/dist/web/assets/client/views/task/page.js +5 -1
  66. package/dist/web/taskPreviews.js +2 -2
  67. package/dist/web/webJobs.js +36 -11
  68. package/dist/web/webMaterials.js +21 -9
  69. package/dist/web/webServer.js +6 -5
  70. package/dist/web/webTaskSurface.js +1 -0
  71. package/docs/job-runs.md +392 -17
  72. package/docs/release-workflow.md +42 -0
  73. package/docs/release-workflow.zh-CN.md +31 -0
  74. package/docs/schedules.md +69 -15
  75. package/docs/storage-baseline.md +38 -1
  76. package/docs/storage-baseline.zh-CN.md +27 -1
  77. package/docs/testing/verification-levels.md +2 -2
  78. package/docs/testing/verification-levels.zh-CN.md +2 -2
  79. package/package.json +1 -1
package/docs/schedules.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Persistent time plans
2
2
 
3
- A Schedule answers **when** to admit a Run of an existing scoped Job. It owns
3
+ For the installed Project maintenance plan and its user overrides, see
4
+ [Built-in Project sync](project-sync.md) ([简体中文](project-sync.zh-CN.md)).
5
+
6
+ A Schedule answers **when** to dispatch a scoped Job. It either admits a Run
7
+ of an existing Job (default), or asks the Job layer to instantiate an exact
8
+ definition revision as a new Job and admit its first Run. It owns
4
9
  the time rule and trigger progress, not the command, execution status or result.
5
10
  Immediate execution remains `job run`; manual Runs do not move a Schedule.
6
11
  All processing uses the existing Controller and the Job supervisor.
@@ -9,6 +14,7 @@ All processing uses the existing Controller and the Job supervisor.
9
14
 
10
15
  ```sh
11
16
  yui schedule create --global --schedule daily-probe --job probe \
17
+ --authorization service \
12
18
  --rule '{"kind":"cron","expression":"30 9 * * 1-5","timezone":"Asia/Shanghai"}'
13
19
  yui schedule list --global
14
20
  yui schedule show --global --schedule daily-probe
@@ -16,17 +22,26 @@ yui schedule disable --global --schedule daily-probe --revision 1
16
22
  yui schedule enable --global --schedule daily-probe --revision 2
17
23
  yui schedule update --global --schedule daily-probe --revision 3 \
18
24
  --rule '{"kind":"interval","anchor":"2026-10-17T00:00:00Z","everyMs":3600000}'
25
+ # New Job per occurrence, pinned to the currently available source revision:
26
+ yui schedule create --global --schedule isolated-probe --job probe \
27
+ --authorization service --target '{"kind":"new-job","definitionRevision":1}' \
28
+ --rule '{"kind":"interval","anchor":"2026-10-17T00:00:00Z","everyMs":3600000}'
29
+ # Unlike disable, revoke also denies not-yet-started service Runs:
30
+ yui schedule revoke --global --schedule isolated-probe --revision 1
19
31
  ```
20
32
 
21
33
  Create the referenced Job first using [the Job CLI](job-runs.md). Replace
22
- `--global` with `--task task-N` for a Task-owned Schedule. Global management
23
- requires a current authenticated Operator Session; Task callers cannot access
34
+ `--global` with `--task task-N` for a Task-owned Schedule. Public local users can
35
+ manage global plans without an Operator Session. Creating or rebinding a public
36
+ plan requires the explicit `--authorization service` choice. Current Operator
37
+ callers can also choose service authorization; omitting it on creation preserves
38
+ the Session-bound behavior. Task callers cannot access
24
39
  global or other Tasks' plans. Assignment limits are checked against the Job
25
40
  on the server. A Project is a Job target, never an ownership scope.
26
41
 
27
42
  The Controller RPC is `schedule.control`. Its input is
28
- `{op,scope,caller,id?,jobId?,rule?,expectedRevision?}`. Supported `op` values
29
- are `create`, `list`, `show`, `update`, `enable`, `disable`. `scope` uses the
43
+ `{op,scope,caller,id?,jobId?,target?,authorization?,rule?,expectedRevision?}`. Supported `op` values
44
+ are `create`, `list`, `show`, `update`, `enable`, `disable`, `revoke`. `scope` uses the
30
45
  Job `JobScope` contract. Trusted ingress must resolve/authenticate `caller`;
31
46
  client-supplied scope/identity is not authorization. `create` requires `id`,
32
47
  `jobId`, `rule`; all edits require the observed `expectedRevision`. `update`
@@ -35,9 +50,17 @@ revalidating both old visibility and new execution authority. Scope is immutable
35
50
  Rule updates retain enabled status only for an already enabled plan; all other
36
51
  states become disabled with the new future rule and require explicit enable.
37
52
 
53
+ `target` defaults to `{"kind":"existing-job"}`. `{"kind":"new-job",
54
+ "definitionRevision":N}` requires the exact currently available source version.
55
+ A source edit never silently changes that pinned selection; explicitly update
56
+ the target and, for service plans, reauthorize. Job owns deterministic instance
57
+ identity and `instantiation` provenance (`sourceId`, `sourceRevision`, occurrence
58
+ `key`). It does not create a Task. Each new instance has its own overlap scope;
59
+ existing-job mode retains one Job's overlap behavior.
60
+
38
61
  Create/edits return the Schedule; list returns visible Schedule records.
39
- Show returns `{schedule,lastSuccess}`. `lastSuccess` is the latest readable
40
- **succeeded JobRun** triggered by this Schedule under its current Job, or null.
62
+ Show returns `{schedule,lastSuccess,runs}`. `lastSuccess` is the latest readable
63
+ **succeeded JobRun** triggered by this Schedule across its historical Jobs, or null.
41
64
  It is derived from Run history, never a separately writable Schedule field.
42
65
  Retargeting does not move or erase the old Job's Run history.
43
66
 
@@ -71,7 +94,7 @@ prevents clock rollback or rule edits from replaying old progress.
71
94
  Rule updates increase `generation`; enable retains it. The internal trigger
72
95
  key is `<schedule-id>:<generation>:<UTC-due>`, scoped to the Job.
73
96
 
74
- Admission and advancement commit in the same Store transaction. Repeated scans
97
+ Instance creation, first Run admission and advancement commit in the same Store transaction. Repeated scans
75
98
  and Controller replacement retain the same Run and occurrence identity.
76
99
  The transaction never spawns. The supervisor starts committed Runs and
77
100
  preserves its existing unknown-effect and exact-process safeguards.
@@ -86,13 +109,15 @@ Task terminal shutdown. Disabling does not cancel an already admitted Run,
86
109
  and cancelling a Run does not disable its Schedule.
87
110
 
88
111
  `lastAttempt` records `at`, `dueAt`, `outcome` (`admitted`, `overlap`, `blocked`),
89
- optional exact `runId`, and reason. An overlap Run is the occupying execution,
112
+ optional exact `jobId`/`runId`, `generation`, and reason. Old receipts retain
113
+ only what was originally known; migration does not invent those references.
114
+ An overlap Run is the occupying execution,
90
115
  not a successful execution of this occurrence. Recurring overlap skips that
91
116
  coalesced tick and advances; once overlap retains its original due instant and
92
117
  retries admission on a later pass without adding a queued Run.
93
118
  Failed Runs stay in Job history; the next recurring tick follows the same plan.
94
119
 
95
- Creation, update and enable capture the authenticated Session binding and Job
120
+ Session-authorized creation, update and enable capture the authenticated Session binding and Job
96
121
  revision. They do not grant execution to a replacement Session or a changed
97
122
  Job definition. Before each admission both are checked again, along with current
98
123
  Job/Task/workspace prerequisites. Revocation or a changed definition stops the
@@ -100,8 +125,31 @@ plan as `needs-attention`; an authorized current manager must inspect and
100
125
  explicitly enable it. Controller restart alone does not revoke the binding.
101
126
  Worker-owned plans also retain the current Assignment boundary.
102
127
 
128
+ Service authority is a separate explicit grant stored on the Schedule. The
129
+ compiled internal `schedule` registration permits only global `system.noop`
130
+ and `project.refresh`; it does not permit Task shell execution, arbitrary code,
131
+ or additional scopes. `origin=builtin`, `caller.scope=service` and client-supplied
132
+ grant fields cannot create a service identity. Management first authenticates
133
+ the ordinary public/managed caller and checks the actual Job target.
134
+ The grant binds Home, Schedule, dispatch mode, exact definition, action, Project
135
+ and input. Admission and runner start recheck current validity; Project refresh
136
+ also rechecks after waiting for its maintenance lock. Replacing Operator Sessions
137
+ does not revoke a service grant. Source/configuration changes block the plan
138
+ with retained reasons; no silent rebind occurs.
139
+ Service Run results remain in Job history and do not enqueue an Operator wake.
140
+ Dispatch errors still use the existing attention notification when a recipient exists.
141
+
142
+ `disable` only stops future dispatch; it does not invalidate the grant of an
143
+ already admitted Run. `revoke` disables the plan and invalidates the grant,
144
+ preventing queued service Runs from starting (not cancelling effects already
145
+ in flight). An explicit `enable --authorization service` grants a fresh identity;
146
+ it never resurrects old revoked Runs. Ordinary enable/rule edits retain an
147
+ unchanged active grant. Reauthorization and source/target changes are deliberate
148
+ management operations, not automatic repairs.
149
+
103
150
  Unclassified admission failures roll back, stop that plan, persist the reason
104
- and notify its Task Leader or global Operator via existing durable inboxes.
151
+ and notify its Task Leader or configured global Operator via existing durable inboxes.
152
+ If no Operator role exists, the plan/reason remains inspectable without creating one.
105
153
  No new recovery queue, lease or automatic retry protocol is introduced.
106
154
 
107
155
  Task stop marks enabled plans as needing attention; restarting execution alone
@@ -114,14 +162,20 @@ settlement guards. A reopened Task does not implicitly resume retired plans.
114
162
 
115
163
  ## Storage and downstream integration
116
164
 
117
- Storage **1.9 → 1.10** appends `schedules`, keyed by `(scope_key,schedule_id)`,
118
- and its due index. Old Job/Run bytes and published baseline checksums remain
119
- unchanged. New Homes initialize 1.10; existing Homes require the centralized
165
+ Storage **1.15 → 1.16** adds explicit target and authorization kinds to existing
166
+ plans, preserving Session bindings, identities, rules, progress and old receipts.
167
+ Original Schedule bytes are archived under migration 16. It never turns historical
168
+ Session authority into a service grant. New optional Job instance provenance and
169
+ Run service-grant references use the existing tables. The published **1.9 → 1.10**
170
+ DDL and all older transitions remain unchanged. New Homes initialize 1.16;
171
+ existing Homes require the centralized
120
172
  explicit upgrade path. No real Home migration or package release is implied.
121
173
 
122
174
  `src/schedule/schedule.ts` exports `Schedule`, `ScheduleRule`, time calculation
123
175
  and validation. `src/controller/scheduleControl.ts` owns management and bounded
124
- reconciliation; `admitJobRun` remains the only execution admission seam.
176
+ reconciliation; Job's `instantiateJobRun` composes instance creation with
177
+ `admitJobRun`, the execution admission seam. No ScheduleRun state or second
178
+ writable execution result is introduced.
125
179
  Consumers should use RPC/service responses rather than write storage directly.
126
180
 
127
181
  Project refresh is a separate controlled Job action supplied by Task128.
@@ -2,7 +2,44 @@
2
2
 
3
3
  # Storage baseline 1.0
4
4
 
5
- Current storage is 1.14. The 1.13 → 1.14 transition removes the Role foreign key
5
+ Current storage is 1.20. The 1.19 → 1.20 transition adds Agent Job configurations,
6
+ optional Job ownership on Global Roles, and the `agent_job_runs` table for
7
+ exact original-message/native-attempt evidence and explicit business results.
8
+ Existing Role, Session, process Run and artifact identities are unchanged;
9
+ no Agent or native Session is invented during migration.
10
+
11
+ The 1.18 → 1.19 transition adds optional immutable Task
12
+ creation source, exact Run delegation and Task/WorkItem result-reference kinds.
13
+ Existing valid payload bytes, ordinary source-less Tasks, unknown effects and
14
+ fixed references are unchanged; no historical source or authority is inferred.
15
+ SQL layout is unchanged.
16
+
17
+ The additive 1.17 → 1.18 transition admits builtin
18
+ Project-sync provenance, a compiled service issuer and a separate user-enabled
19
+ preference on new Schedules. SQL layout and every existing payload remain unchanged;
20
+ it neither adopts custom Jobs nor fabricates historical grants or Runs.
21
+ Installation is a Controller operation, separate from storage migration.
22
+
23
+ The 1.16 → 1.17 transition adds optional append-only
24
+ JobRun artifact references and scope/Run-isolated local Git repositories.
25
+ Existing payload bytes and Task Git repositories/frozen references remain
26
+ unchanged; no historical artifact, provenance or authorization is inferred.
27
+ No SQL layout change or automatic cleanup is introduced.
28
+
29
+ The 1.15 → 1.16 transition adds explicit Schedule
30
+ dispatch targets and authorization kinds. Existing plans keep their exact Session
31
+ authority, rules, identity and progress; original bytes are archived under migration
32
+ 16. No service permission is inferred. New service grants and Job instance
33
+ provenance use the same tables; no ScheduleRun lifecycle is introduced.
34
+
35
+ The 1.14 → 1.15 transition adds separate Job business
36
+ results derived from saved process results, archiving original Run payload bytes
37
+ under migration 15. It does not infer structured business data from logs, change
38
+ execution identities, replay effects or rewrite frozen Context/Integration evidence.
39
+ SQL layout is unchanged. Public immediate builtin admissions use an explicit
40
+ Home/Run-bound user authority, not an invented Session or Schedule authorization.
41
+
42
+ The 1.13 → 1.14 transition removes the Role foreign key
6
43
  from `global_role_session_sets`, preserving every payload byte and rebuilding
7
44
  its retry index. Stopped Session identity/history can then outlive Role removal
8
45
  without granting authority. No new authorization table or inferred history is
@@ -2,7 +2,33 @@
2
2
 
3
3
  # 存储基线 1.0
4
4
 
5
- 当前存储为 1.14。1.13 → 1.14 只移除 `global_role_session_sets` 对 Role 的外键,
5
+ 当前存储为 1.20。1.19 → 1.20 增加 Agent Job 配置、Global Role 的可选 Job
6
+ 归属和 `agent_job_runs` 表,保存原始消息、准确原生尝试与显式业务结果。
7
+ 保留现有 Role、Session、进程 Run 和固定产物身份;迁移不创建 Agent 或原生会话。
8
+
9
+ 1.18 → 1.19 增加 Task 可选且不可改写的创建来源、准确 Run
10
+ 委托及 Task/WorkItem 结果引用,不改变 SQL 布局或旧 payload 字节。
11
+ 普通历史 Task 仍无来源,不补造权限、来源或结果;未知效果与固定产物引用保持。
12
+
13
+ 1.17 → 1.18 允许新记录携带内置 Project 同步来源、
14
+ 编译期注册服务签发者及独立的用户启停偏好;SQL 布局和已有 payload 原字节不变。
15
+ 迁移不接管手建 Job、不补造历史授权或 Run;安装由 Controller 单独核对。
16
+
17
+ 1.16 → 1.17 增加 JobRun 可选的只追加产物引用,
18
+ 以及按 scope 和 Run 隔离的本地 Git 正式产物库。原 payload 字节、
19
+ Task 产物库及冻结引用保持不变,不补造历史产物、来源或授权,
20
+ 不改变 SQL 布局,也不增加自动清理。
21
+
22
+ 1.15 → 1.16 增加明确的 Schedule 派发目标及授权类型;
23
+ 原计划保留准确 Session 授权、规则、身份与进度,原始字节归档于 migration 16。
24
+ 不推导或升级为服务权限。新增服务授权和 Job 实例来源沿用原表,不新增 ScheduleRun 生命周期。
25
+
26
+ 1.14 → 1.15 根据已保存的进程结果增加独立的 Job 业务结果,
27
+ 原始 Run payload 字节归档于 migration 15;不从日志猜测结构化业务数据,
28
+ 不改执行身份,不重放动作,也不改冻结 Context 或 Integration 证据。SQL 布局不变。
29
+ 公共即时 builtin 使用绑定 Home/Run 的 user 授权,不伪造 Session,也不授予 Schedule 持久权限。
30
+
31
+ 1.13 → 1.14 只移除 `global_role_session_sets` 对 Role 的外键,
6
32
  原样保留 payload 并重建 retry 索引,使已停止会话的身份/历史在角色移除后继续保留,
7
33
  但不赋予权限。不新增授权表,不补造已经丢失的历史。普通读取要求当前存储版本,
8
34
  已有 Home 只能通过显式受支持升级迁移,不能在读取时自动迁移。
@@ -50,12 +50,12 @@ is required.
50
50
  ## Permanent core smoke
51
51
 
52
52
  `npm test` and `npm run test:core` build the checkout and run the maintained suite.
53
- The stable suite owns current storage 1.14 and its declared 1.0 through 1.13 minor
53
+ The stable suite owns current storage 1.20 and its declared 1.0 through 1.19 minor
54
54
  transition. It contains no undeclared historical format compatibility path.
55
55
 
56
56
  Current coverage includes:
57
57
 
58
- 1. Fresh storage 1.14, exact schema/record validation, no initialization over
58
+ 1. Fresh storage 1.20, exact schema/record validation, no initialization over
59
59
  unknown data, and rejection of old integer formats without mutation.
60
60
  2. Exact-version staging, mismatched-target refusal, same-major contiguous
61
61
  minor preflight, explicit maintenance-owner identity across handover, and
@@ -36,12 +36,12 @@ Yui 是一个单用户本地产品。永久验证保护关键的 happy path 和
36
36
  ## 永久 core smoke
37
37
 
38
38
  `npm test` 和 `npm run test:core` 构建当前 checkout 并运行维护中的套件。
39
- 稳定套件维护当前存储 1.14 和明确声明的 1.0 至 1.13 连续小版本迁移,
39
+ 稳定套件维护当前存储 1.20 和明确声明的 1.0 至 1.19 连续小版本迁移,
40
40
  不包含未声明的历史格式兼容路径。
41
41
 
42
42
  当前覆盖包括:
43
43
 
44
- 1. 新建存储 1.14、精确结构与记录校验、禁止覆盖未知数据库、无修改拒绝旧整数格式。
44
+ 1. 新建存储 1.20、精确结构与记录校验、禁止覆盖未知数据库、无修改拒绝旧整数格式。
45
45
  2. 精确版本暂存、目标不匹配拒绝、同主版本连续小版本预检、交接锁显式所有者,
46
46
  以及恢复时核对捕获的协议和存储身份,不接受缺失字段。
47
47
  3. 持久 Task/Message/Decision 上下文、Draft 激活权威、mailbox 认领、
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zq-silk/yui",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Local control plane for long-running native agent CLI sessions backed by tmux.",
5
5
  "license": "MIT",
6
6
  "private": false,