@jsonstudio/appsdk-linux-x64-gnu 0.0.0-stage → 0.1.15

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.
@@ -0,0 +1,664 @@
1
+ ---
2
+ name: appsdk-project-governance
3
+ description: "AppSDK 质量门禁、规则/Skill 升级审计与 defect 追踪; 协作与质量准入分开。"
4
+ ---
5
+
6
+ # AppSDK Project Governance
7
+
8
+ ## Purpose and mandatory boundary
9
+
10
+ AppSDK verifies engineering quality. Collab supports automatic multi-worker
11
+ registration, communication and task/file ownership. Memory and Guidance help
12
+ when useful. Missing auxiliary state does not fail independent development.
13
+ Collab transport, daemon, identity, and migration/reset state machines have
14
+ separate owners; an SDK-only rule, Skill, or template upgrade does not require
15
+ them.
16
+
17
+ Default flow: understand goal/scope → implement → relevant verification →
18
+ review → authorized delivery. Require applicable quality, safety and evidence
19
+ integrity gates; do not turn every available command into a mandatory phase.
20
+ - External AppSDK: compiler, CLI, schemas, harness, adapters, immutable rules.
21
+ - `.appsdk/`: committed project governance contract, maps, goal, records, verification, and `sdk.lock`.
22
+ - `.appsdk-control/`: ignored local run state, review cache, temporary harness output, and worker state.
23
+ - `playground/`: mutable experiment source.
24
+ - `active/lib/`: immutable consumable library.
25
+ - `protected/`: frozen source, contracts, and history.
26
+ - `generated/` or the project-declared artifact root: compiler output only; never hand-edit.
27
+ - AppSDK communication control: `appsdk::communication` owns the stable `appsdk-comm/v1`
28
+ request/event/capabilities contracts and the replayed notification/Loop projections.
29
+ Keep `.appsdk-control/communication/mailbox.jsonl` local and ignored; host integrations
30
+ select a registered adapter (`mailbox` or `appserver`) instead of copying transport
31
+ logic into a project. An App Server adapter must bind its target to a registered
32
+ recipient and declare `send_message_to_thread`. Detailed route, batching, wakeup,
33
+ receipt, and Bug/Loop gate semantics live in
34
+ [`docs/design/apps-sdk-communication.md`](../../docs/design/apps-sdk-communication.md).
35
+
36
+ Run project commands from project cwd. An explicit optional project path is for
37
+ operators intentionally working elsewhere; no project-root environment variable.
38
+
39
+ ## Truth and path ownership
40
+
41
+ The host-wide persistent truths are fixed and must not be inferred from a
42
+ project directory:
43
+
44
+ ```text
45
+ ~/.appsdk/{projects,runtimes,communication}.jsonl AppSDK host truth
46
+ ~/.collab/{server.sock,events.jsonl,log.txt,routes.jsonl,...}
47
+ Collab host truth
48
+ ```
49
+
50
+ Project-local state has a different scope and owner:
51
+
52
+ ```text
53
+ <project>/.appsdk/ AppSDK project contract, maps, records and lock
54
+ <project>/.appsdk-control/ AppSDK-owned local run/cache state
55
+ <project>/.agent-collab/ Collab-owned project registration/reducer input
56
+ ```
57
+
58
+ None of the project-local paths is the global truth, and none is proof that the
59
+ current peer is registered. Read live registration, role, liveness and peers
60
+ through `collab context`; retire project-local state only through the owner's
61
+ canonical reset/migration command. Do not inspect or edit `~/.appsdk`,
62
+ `~/.collab`, `.appsdk-control/`, or `.agent-collab/` to reconstruct control
63
+ state.
64
+
65
+ The current client is Codex only. A peer is bound to the Codex sessionID
66
+ through the live App Server thread; the global Collab store is the identity,
67
+ route, mailbox, task, and liveness truth. Tracked `.appsdk/` files are present
68
+ in a Git worktree because they are committed, but ignored `.agent-collab/` and
69
+ `.appsdk-control/` state is not inherited. Ordinary AppSDK project
70
+ initialization runs from the canonical project main checkout. Agent-facing
71
+ Collab identity bootstrap is `collab context`; it may run from the project or
72
+ worktree, and the daemon resolves the canonical route. An authorized AppSDK
73
+ `--fresh --discard-legacy` reset is a separate operation and may run from its
74
+ clean non-main owner worktree as specified below. Inside a worktree the same
75
+ Codex sessionID/thread remains the same peer; return to the canonical project
76
+ main checkout for human-approved role changes. Never register the worktree as
77
+ a second peer or promote yourself from a worktree.
78
+
79
+ ## SDK source repository and managed project boundary
80
+
81
+ This Skill is used in two different contexts and must not blur them:
82
+
83
+ - **AppSDK source repository:** a checkout containing the SDK implementation,
84
+ release scripts, contracts, docs, and Skills (for example, `rust/` and
85
+ `scripts/install-global-appsdk.sh`). Its root is an SDK development and
86
+ release surface by default. A missing `.appsdk/project.json` means that the
87
+ checkout is not implicitly a managed consumer project; it does not make
88
+ initialization impossible. If the user explicitly chooses to govern this
89
+ SDK workspace with AppSDK, run `appsdk prepare` and confirm the preparation,
90
+ then run ordinary `appsdk init` from the canonical project main checkout.
91
+ The normal initialization path creates a project contract that the owner
92
+ must review and bind to the SDK source modules; it does not infer or
93
+ overwrite those modules. A `playground/<slug>` worktree used to develop the
94
+ SDK remains an SDK source worktree unless that explicit project registration
95
+ is made. Its
96
+ source, Git history, and release gates remain SDK-owned. Never run
97
+ `appsdk init` or `appsdk reset-governance` merely to manufacture a contract,
98
+ and never use fresh reset without the existing contract and explicit
99
+ `--fresh --discard-legacy` authorization. Any local `.appsdk-control/` state
100
+ is inspected as local runtime state and is not a reason to delete source
101
+ repository files.
102
+ - **AppSDK-managed business project:** a consumer root with an explicit
103
+ `.appsdk/project.json` and its project-owned goal, maps, records, module
104
+ contracts, and `sdk.lock`. `appsdk prepare`, `init`, `verify`, `compile`,
105
+ promotion, freeze, and an authorized governance reset operate on this root.
106
+ A source repository or an arbitrary `cwd` is never treated as a business
107
+ project without that contract. To govern a child project inside a larger
108
+ checkout, first name that relative root through the preparation flow and
109
+ bind it in the resulting contract.
110
+
111
+ The SDK source repository can still use an explicitly enabled Collab route for
112
+ its own TUI development, but that route proves agent communication only; it
113
+ does not by itself create a project contract or authorize a governance reset.
114
+ An explicit, confirmed `appsdk init` is the separate opt-in that registers the
115
+ SDK workspace as a project. Conversely, initializing a managed business project
116
+ does not grant authority over the SDK source repository. Keep source/release
117
+ evidence, project governance truth, and Collab runtime state in their
118
+ respective owners.
119
+
120
+ ## Rule and Skill upgrade audit
121
+
122
+ An SDK-only rules, Skills, or template upgrade starts with the project owner
123
+ reading effective upstream rules, project `AGENTS.md`, project Skills, actual
124
+ test commands, and CI/hook entrypoints. Compare them with the installed
125
+ `.appsdk/templates/minimal/AGENTS.md`; that template is advisory reference, not
126
+ an active rule source.
127
+
128
+ For each difference, record location, owner, action (`delete`, `merge`,
129
+ `narrow`, or `add`), basis, retained safeguard, and actual entrypoint impact.
130
+ Reuse session authorization that already covers the difference; seek approval
131
+ only for uncovered changes. Guidance is optional: a project may perform the
132
+ same audit and update CI/hooks without declaring or compiling Guidance.
133
+
134
+ Repeated `appsdk init` and unrelated version refreshes do not trigger a
135
+ whole-project rule audit. Run checks affected by the changed rules or
136
+ entrypoints during development; run the declared complete release gate only for
137
+ release scope.
138
+
139
+ SDK-only upgrades do not require Collab daemon freeze, restart, identity
140
+ migration, or reset. Follow the installed `collab` Skill only when Collab-owned
141
+ state or transport actually changes.
142
+
143
+ ## One global AppSDK binary
144
+
145
+ Do not copy or select AppSDK binaries by hand. The AppSDK repository's only
146
+ supported global installation entry is:
147
+
148
+ ```bash
149
+ scripts/install-global-appsdk.sh
150
+ ```
151
+
152
+ It builds the release, atomically replaces the executable beside the active
153
+ `cargo`, removes exact AppSDK-managed legacy copies, and checks that one
154
+ managed `appsdk` remains. The same release source installs
155
+ `appsdk-project-governance`, `appsdk-migration`, and `project-memory` under
156
+ `~/.agents/skills/`. Run it from any directory; it resolves its own repository
157
+ root. SHA-256 is diagnostic output only, not a fixed admission condition. Do
158
+ not stop project development because a historical binary hash differs. If the
159
+ version or command path is wrong, run the installer once and refresh the
160
+ current shell cache (`rehash` in zsh or `hash -r` in bash); do not manually
161
+ copy, rename, or leave `.local/lib/appsdk/<version>/appsdk` beside the
162
+ canonical entry.
163
+
164
+ An AppSDK binary install does not restart a daemon. Use the daemon's official
165
+ maintenance command separately when the running process must load the new
166
+ binary. Never start v2 or create a second global AppSDK entry as a workaround.
167
+
168
+ ## Legacy governance inventory and reset boundary
169
+
170
+ The canonical inspect, snapshot, freeze, reset or migrate, identity context
171
+ reconciliation, restart, and verify state machine belongs to the
172
+ [AppSDK migration Skill](../appsdk-migration/SKILL.md). This project Skill only
173
+ defines what a managed project may classify, preserve, and hand to that Skill;
174
+ do not copy the migration state machine into this file or into a project.
175
+
176
+ For an existing project that contains legacy `.appsdk/` or `.agent-collab/`,
177
+ start with the exact operator path in
178
+ [Existing project: remove old governance](references/bootstrap-migration.md#existing-project-remove-old-governance).
179
+ The AppSDK reset and the Collab migration are separate owners and separate
180
+ transactions. Never treat removal of `.appsdk/` as permission to delete or
181
+ rebuild `.agent-collab/`, and never use the Collab migration as a substitute
182
+ for an authorized AppSDK governance reset.
183
+
184
+ The only clean-epoch reset entries are:
185
+
186
+ ```sh
187
+ # AppSDK-owned project control plane; requires an existing contract and a
188
+ # clean non-main owner worktree.
189
+ appsdk init <project> --fresh --discard-legacy
190
+ # Same transactional reset owner, lower-level entry:
191
+ appsdk reset-governance <project> --discard-legacy
192
+
193
+ # Collab-owned project control plane: use the installed collab Skill's
194
+ # `collab reset --project --discard-legacy --approval ...` during an authorized
195
+ # maintenance window.
196
+ ```
197
+
198
+ `collab reset` archives the exact `.agent-collab/` and `.agent-collab-v2/`
199
+ bytes, removes only Collab-owned control state and stale routes, and records
200
+ `delivery_verified: false`. It never removes `.appsdk/` or
201
+ `.appsdk-control/`. Never manually delete either project-local root, journal,
202
+ mailbox, identity, task record, or route.
203
+
204
+ Before choosing a route, record an inventory of every exact path and runtime
205
+ object in the run note. At minimum include the AppSDK contract root and its
206
+ records/maps, `.appsdk-control/`, declared generated roots, Active/Protected,
207
+ business source/runtime data, every Collab initialization root, daemon
208
+ PID/socket, identity and route binding, mailbox/journal, claims, tasks, and
209
+ worktrees. For each item record its owner, observed status, content or
210
+ identity digest when applicable, retention class, proposed disposition, and
211
+ the evidence that makes the classification trustworthy. A filename, stale
212
+ screen, or successful daemon status is not an inventory decision.
213
+
214
+ Choose exactly one of these routes for a managed business project:
215
+
216
+ - **Preserve and migrate:** retain immutable project evidence, resolve one
217
+ owner for ambiguous state, and invoke the canonical migration Skill. Old
218
+ PASS, hashes, receipts, and review claims are historical witnesses; they are
219
+ never copied into a new record or treated as proof for the new binary.
220
+ - **Reset and reinitialize:** only after the user authorizes discarding the
221
+ named legacy control plane, from a clean non-`main` owner worktree with no
222
+ competing claim. For an existing project that must start a new governance
223
+ epoch, use the single explicit entry
224
+ `appsdk init <project> --fresh --discard-legacy`; it performs the canonical
225
+ reset and current-contract rebuild together, and records `mode: "fresh_init"`.
226
+ The current SDK scaffold is the only reset baseline. Legacy SDK pins, migration
227
+ witnesses, record/transition contracts, indexes, and rebuildable projections
228
+ are ignored and regenerated from that baseline; missing SDK-owned fields are
229
+ refilled. Only project-owned identity, module ownership, build declarations,
230
+ and protection boundaries are carried forward. It must not replace those
231
+ boundaries with the generic `change-me/app-core` scaffold. After the old
232
+ control plane is removed, validation runs only against the new staging
233
+ baseline. The lower-level `appsdk reset-governance <project>
234
+ --discard-legacy` uses the same transactional reset owner. Neither route
235
+ inherits delivery, review, freeze, or deployment claims.
236
+
237
+ Reset may remove the old `.appsdk/` records/transactions and declared
238
+ rebuildable generated projections, plus local `.appsdk-control/` state owned by
239
+ that managed project. It preserves business source, runtime data, `active/`,
240
+ and `protected/` by default. Failed staging belonging to a live task must go
241
+ through that task's retry/abort owner first. `dist/`, `.deploy/`, `build/`,
242
+ `tmp/`, custom reports, vendor outputs, and other external paths require an
243
+ exact-path rebuildability decision and a separate authorization/cleanup
244
+ record.
245
+
246
+ `.agent-collab/`, its journal/mailbox, identity tokens, daemon PID/socket,
247
+ claims, task records, and worktrees remain Collab-owned. This Skill never
248
+ deletes or hand-edits them to make a migration appear clean; use the Collab
249
+ migration/recovery contract and preserve its evidence. After either route,
250
+ report retained and removed classes separately and verify one current truth.
251
+ A clean directory is not evidence of delivery, review, install, restart, or
252
+ live communication.
253
+
254
+ ## Working loop
255
+
256
+ 1. Read project AGENTS and affected code/contracts. Resolve owner, scope,
257
+ acceptance and relevant gates. Read historical notes only when they help.
258
+ 2. Implement the smallest adequate change. Use existing design for local work;
259
+ clarify only material unknowns.
260
+ 3. Run only the applicable checks. Fix failures at their owner; never forge
261
+ evidence or hide errors.
262
+ 4. Stay within authorization. Report each achieved state separately: test,
263
+ review, merge, install, publish and resource cleanup are distinct, and a
264
+ result in one is not evidence for another.
265
+ 5. Single-file documentation and Skill edits are out of this loop: make the
266
+ change, run one targeted check, and do not acquire a plan, task, worktree
267
+ switch, extra review or lifecycle ceremony.
268
+
269
+ The heavier parts of delivery are conditional, not a default. Take a clean owner
270
+ worktree from latest `origin/main`, register peer and task/file scope through
271
+ Collab, review under the shared standard, and reuse stage evidence under
272
+ [Stage gates: re-entry and reuse](#stage-gates-re-entry-and-reuse) only when the
273
+ changed module or the requested delivery actually needs them.
274
+
275
+ ## Quick start: new governed project with Collab
276
+
277
+ For a new business project that also needs agent-to-agent Collab, do not invent
278
+ project-local transport or old `.appsdk/` state. Run the AppSDK flow from the
279
+ project root. `appsdk init` may internally call the daemon context when a live
280
+ Codex App Server sessionID binding exists; the agent-facing Collab bootstrap is
281
+ one `collab context` after AppSDK initialization. App Server is the only
282
+ supported Collab transport.
283
+
284
+ ```bash
285
+ cd /abs/path/project
286
+ appsdk prepare
287
+ appsdk init .
288
+ appsdk guide status
289
+ appsdk verify
290
+ ```
291
+
292
+ `appsdk prepare` is mandatory for a new root. It writes
293
+ `.appsdk-prepare.json` as a draft, and `appsdk init` fails with
294
+ `PREPARATION_NOT_CONFIRMED` until the preparation fields are user-confirmed:
295
+ `status: "confirmed"`, `change_kind`, `project_root`, `boundary`, `questions`
296
+ closed, `confirmed_by`, and `confirmed_at`. Do not confirm scope on the
297
+ user's behalf and do not bypass prepare by editing `.appsdk/project.json`.
298
+ Detailed fields and an example are in
299
+ [bootstrap-migration.md](references/bootstrap-migration.md).
300
+
301
+ In a live Codex App Server runtime, `appsdk init` remains the AppSDK project
302
+ initialization owner and may invoke the daemon context internally. It does not
303
+ authorize this Skill to invent a separate Collab identity bootstrap. The
304
+ agent-facing Collab bootstrap is one `collab context`; `registered: true` ends
305
+ bootstrap. If the snapshot returns `required_fields`, supply only those real
306
+ facts once with `collab context --provide '<JSON>'`. The supplement may contain
307
+ only `session_id`, `thread_id`, `endpoint`, or `namespace` when requested; it
308
+ never supplies a worker, approval, token, route, or binding. The daemon owns
309
+ identity creation, selection, recovery, registration, route publication, and
310
+ lease restoration. If no registered App Server route exists, AppSDK initialization
311
+ still succeeds for independent development, reports Collab pending, and never
312
+ fabricates a peer or notification channel. Do not rerun initialization to
313
+ repair pending Collab. Then use `collab sendmessage`, `collab inbox`, and
314
+ `collab recv` only through the server-selected transport.
315
+
316
+ For an already governed project, the initialization contract is only:
317
+
318
+ ```text
319
+ collab context
320
+ -> registered: stop
321
+ -> required_fields: collab context --provide '<JSON>' once
322
+ -> explicit daemon DOWN or runtime error: preserve and stop
323
+ -> role=master requires user approval and no live master; otherwise remain peer
324
+ ```
325
+
326
+ Do not pre-probe environment, panes, `routes.jsonl`, or `.agent-collab/`.
327
+ For the roles and copy/paste prompts after initialization, see
328
+ [bootstrap-migration.md](references/bootstrap-migration.md#master-and-ordinary-peer-bootstrap).
329
+ Master initialization adds `collab master promote --approval "<user text>"`
330
+ after the peer is live and the user explicitly approved the exact project and
331
+ peer; ordinary peers only verify identity, liveness, transport, presence and
332
+ task scope. Long-horizon goal scheduling is master-only and is verified with
333
+ `appsdk goal status --json` plus one real fired/consumed deadline replay, not
334
+ by command output alone.
335
+
336
+ ## Quick start: replace old governance with current baseline
337
+
338
+ When a project already contains old `.appsdk/`, `.appsdk-control/`, or
339
+ `.agent-collab/`, treat AppSDK and Collab as separate owners with separate
340
+ transactions. First read
341
+ [Existing project: remove old governance](references/bootstrap-migration.md#existing-project-remove-old-governance)
342
+ and run the exact commands there. The invariant is:
343
+
344
+ ```text
345
+ inventory both roots -> migrate/retire Collab first -> authorize AppSDK reset
346
+ -> clean non-main owner worktree -> appsdk init <project> --fresh --discard-legacy
347
+ -> appsdk guide compile -> appsdk verify
348
+ ```
349
+
350
+ `appsdk init --fresh --discard-legacy` is the only init path that discards the
351
+ named AppSDK legacy control plane. It requires an existing
352
+ `.appsdk/project.json`, a clean non-`main`/`master` owner worktree, and explicit
353
+ authorization. It removes old AppSDK control state and declared generated
354
+ roots, refills missing current SDK fields, carries forward project-owned
355
+ boundaries, and never deletes `.agent-collab/` or old Collab evidence. Collab
356
+ state is removed or migrated through the `collab migrate` and daemon lifecycle
357
+ owned by the Collab Skill. A fresh reset record proves reset only; it never
358
+ imports old PASS, review, install, restart, delivery, or live communication.
359
+
360
+ For the Collab half, use `collab migrate` when the journal is replayable. Use
361
+ the explicit `collab reset --project --discard-legacy --approval "<user text>"`
362
+ path only when the operator authorizes abandoning the old Collab epoch. The two
363
+ reset commands are independent; neither one can claim the other's cleanup or
364
+ delivery result.
365
+
366
+ ### Upstream AppSDK defect report
367
+
368
+ When the defect belongs to AppSDK itself, query for an existing report, file
369
+ one upstream record with reproduction and runtime identity, then read the
370
+ created record back:
371
+
372
+ ```bash
373
+ appsdk bug list -q "<symptom>" --json --upstream
374
+ appsdk bug new --upstream -t "[SDK Bug] <symptom>" \
375
+ -m "<reproduction, expected, observed, version, commit, logs>" \
376
+ -l "P0,appsdk"
377
+ appsdk bug show <id> --json --upstream
378
+ ```
379
+
380
+ The report is evidence of a filed defect, not proof that the local delivery or
381
+ the upstream fix passed.
382
+
383
+ ## Conditional delivery gates
384
+
385
+ Candidate, review, integration, publication and runtime replay are separate
386
+ evidence states. Run only the checks and service operations declared by the
387
+ changed module and requested delivery. Ordinary development or documentation
388
+ work stops after its applicable checks and review; it does not acquire a
389
+ freeze, install, restart, live replay or full-suite ceremony by default.
390
+
391
+ Use [review-delivery.md](references/review-delivery.md) for the selected
392
+ delivery path. It binds every phase to the exact candidate, artifact,
393
+ environment and producer identity. Reuse unchanged PASS evidence after a
394
+ lightweight integrity/freshness check; do not rerun the external test,
395
+ deployment, merge or publication action merely because a later phase started.
396
+ If a required input changes, invalidate only that phase and its downstream
397
+ dependants. A candidate, review PASS, merge, push, install, restart or cleanup
398
+ receipt never implies any other state.
399
+
400
+ For design or architecture review that consumes project requirements, use
401
+ [authoritative-review-template.md](references/authoritative-review-template.md)
402
+ to assemble the packet from the project's authoritative source. The executing
403
+ agent supplies observed scope and evidence; the independent reviewer reads the
404
+ source and verifies every applicable requirement item. The template does not
405
+ grant requirement authority, replace the SDK bundle owner's distribution work,
406
+ or claim authentication or tamper protection.
407
+
408
+ ### Optional black-box test governance
409
+
410
+ AppSDK owns the optional black-box test governance selection, scope
411
+ confirmation, scenario contracts, trusted runner registry, effect
412
+ authorization, evidence binding and final object admission. Missing
413
+ `project.json#/test_governance` or `mode: "off"` keeps existing compile and
414
+ verify behavior unchanged. A selected project points to a committed
415
+ `.appsdk/test-governance.json` manifest that conforms to
416
+ `contracts/test-governance.schema.json`; its result records conform to
417
+ `contracts/records/test-scenario-result-record.schema.json`. Object-level
418
+ `invariants` / laws are descriptive governance assertions in that manifest;
419
+ they are not proof language and are never compiled as DAGpipe business nodes.
420
+
421
+ Governance records never carry executable shell strings. Scenarios refer only
422
+ to stable `runner_ref` entries from the trusted runner registry; the actual
423
+ project test entrypoint remains project-owned. `passed` result records must
424
+ reference an EvidenceRecord bound to the candidate commit, result `pass`,
425
+ matching environment/entrypoint and unexpired. `verify --test-admission` is a
426
+ read-only report, not a test executor. `verify --admission` applies the object
427
+ gate only when the project is selected; ordinary `verify` reports
428
+ `not_selected`/`passed`/`blocked` without making test passage a delivery
429
+ requirement, and `compile` does not depend on the optional manifest.
430
+
431
+ DAGpipe CLI remains graph-only. It validates DAG topology and never substitutes
432
+ for AppSDK test evidence or admission. Existing module whitebox, public-entry
433
+ blackbox and runtime review gates are not weakened by optional test
434
+ governance.
435
+
436
+ ## Optional Guidance
437
+
438
+ Use `appsdk guide status/init/plan/update/next/close` when the user/project
439
+ selects persistent planning or a long task benefits from recovery. Default
440
+ `advisory` and `warning` do not require a task plan or setup before development.
441
+ Missing PlanRecord does not fail ordinary `verify` or `compile`.
442
+
443
+ When using Guidance, follow its declared transitions and bind observations to
444
+ the current context. A failed optional workflow is not a failed quality gate.
445
+ Do not fabricate a successful step to close a plan.
446
+
447
+ For a requested setup/upgrade, `guide init --mode bootstrap` is read-only.
448
+ Compare current project-owned sources with the advisory standard template;
449
+ apply only authorized rule changes. Ordinary `appsdk init` refreshes SDK
450
+ resources but never overwrites project AGENTS, Skills, records, Active or
451
+ Protected. The explicit `appsdk init --fresh --discard-legacy` route is the
452
+ user-authorized exception: it removes only the named legacy control plane and
453
+ rebuilds current SDK-managed contracts from the current scaffold baseline:
454
+ legacy SDK pins, migration witnesses, indexes, and rebuildable projections are
455
+ ignored, missing SDK-owned fields are refilled, and project-owned identity,
456
+ module ownership, build, and protection boundaries are carried forward.
457
+ Business source, runtime, Active and Protected are preserved. Merely auditing
458
+ rules does not require running initialization or changing setup.
459
+
460
+ ## Optional Collab coordination
461
+
462
+ Collab is a coordination adapter, not a quality-admission prerequisite. The
463
+ AppSDK source repository and a managed consumer project keep separate owners;
464
+ initializing one never grants authority over the other. A missing App Server
465
+ peer, daemon, mailbox or native task route leaves independent AppSDK work
466
+ runnable; only an operation that explicitly needs shared ownership or
467
+ communication waits, with the exact Collab error preserved.
468
+
469
+ When managed child coordination is selected, use the canonical **subworker**
470
+ term and the `appsdk subworker` compatibility entry documented in the
471
+ [subworker policy](references/subagents-config.md). That entry forwards to
472
+ Collab and never creates a second registry, native Desktop thread or quality
473
+ gate. For identity, scope, route and two-way delivery evidence, follow the
474
+ Collab Skill and its live-route contract; do not duplicate that state machine in
475
+ AppSDK governance. Desktop does not register or subscribe a long-horizon goal.
476
+
477
+ ## Universal Bug Tracking & Defect Governance
478
+
479
+ Execution-bound user inputs, requirements, problems, defects, and features use
480
+ one development intake backed by the existing `git-bug` store:
481
+
482
+ ```bash
483
+ appsdk bug intake --input <intake.json>
484
+ ```
485
+
486
+ The JSON declares `execution_bound: true`, classification `bug` or `feature`,
487
+ title, original input, scope, owner, optional parent, acceptance, status,
488
+ evidence links, and a dedup query. Intake queries first, reuses an exact
489
+ match, appends changed intake details, reopens a closed match, or creates one record.
490
+ It returns the authoritative `issue_id`. Read-only conversation uses no intake
491
+ and `execution_bound: false` is rejected.
492
+
493
+ Master, peer/worker, and subworker prompts use this same contract. Bind the
494
+ returned ID through worktree, implementation, tests, review, merge, and
495
+ closure. Without an ID, do not claim governed completion. Do not add another
496
+ issue database, scheduler, daemon, or task truth.
497
+
498
+ `WorktreeRecord` retains `bug_triage` and its query binding for non-legacy IDs.
499
+ Closing or promotion still requires canonical solution evidence:
500
+
501
+ ```bash
502
+ appsdk bug close <id> -m "Solution: <root cause and resolution>" --receipt-id <receipt>
503
+ ```
504
+
505
+ Legacy empty, `none`, and `legacy-*` IDs remain exempt from retroactive intake.
506
+ AppSDK framework defects retain the explicit `--upstream` route. Blocked tasks
507
+ still require cause, owner, unblock condition, and recovery trigger.
508
+
509
+ ### Stage gates: re-entry and reuse
510
+
511
+ Treat each lifecycle phase as its own persisted gate. The phase projection is
512
+ bound to the candidate/tree, module scope, dependencies, artifact and
513
+ environment, map hashes, evidence IDs, and phase-specific mainline or cleanup
514
+ identity. On a new invocation, validate the current projection and upstream
515
+ records before doing work.
516
+
517
+ - A matching PASS projection with unexpired evidence returns `reused: true`
518
+ and skips the external action that produced it. Keep the lightweight
519
+ integrity, identity, and freshness checks; `reused` is not fresh test,
520
+ deployment, merge, or publication evidence.
521
+ - If any bound input drifts, the current phase and its downstream phases are
522
+ stale. Keep the immutable PASS record and produce a new candidate-bound
523
+ projection; do not rewrite or downgrade the old record.
524
+ - `fail`, `unknown`, malformed, and expired records never count as PASS. The
525
+ same non-PASS identity returns `LIFECYCLE_CHAIN_STAGE_NOT_PASS`; a changed
526
+ identity archives the prior projection and re-enters the phase. Attempt
527
+ history is append-only at
528
+ `.appsdk/records/attempts/<module>/<phase>.jsonl` and is itself validated.
529
+ - `produce-lifecycle-records` reuses the Worktree/Reproduction/baseline set
530
+ only when all three records and the complete declaration match. A partial
531
+ set or drift is an explicit failure; never fill a missing record from a
532
+ guessed cache. `verify` may reread the full graph for integrity without
533
+ rerunning external commands.
534
+
535
+ ## Long-Horizon Goal Subscription & Master Saturation
536
+
537
+ Selected for a long-running, master-scheduled task only. Ordinary development
538
+ never registers a goal or saturation loop and never gates on them.
539
+
540
+ `collab context` returns identity, liveness, tasks, inbox, `next_actions`,
541
+ master/authority state, `role_brief`, and truth. Registration returns the brief
542
+ effective at registration; `collab context` projects the current brief, and
543
+ promotion or delegation returns the replacement brief.
544
+ Treat that brief as the contract. Master dispatches rather than codes: split
545
+ and assign work, allocate resources, keep workers loaded, own blockers, and
546
+ drive verify/merge/cleanup/close.
547
+ Independent worker owns its task end to end and evaluates master collaboration
548
+ requests against current ownership/capacity—accept non-conflicting work or
549
+ negotiate explicitly. Managed subworker executes its assigned scope and reports
550
+ evidence to parent/master. On trouble, worker/subworker first investigates, then
551
+ reports root cause, attempts, proposed fix, and exact decision needed.
552
+
553
+ Notifications are interrupts, not completion. Follow the `P0/P1/P2 ACTION`,
554
+ then resume current work; with no task, run `appsdk longhorizon show`. Never end
555
+ on ACK, read, or summary.
556
+
557
+ For a live peer, `collab context` is the authority and task-state query and
558
+ returns the canonical `role_brief`. When no work is owned, run
559
+ `appsdk longhorizon show --json`. Long waits must use the supported timer/wake
560
+ path and then stop; do not poll in a loop.
561
+
562
+ Register complex or long-running goals only after the plan file exists and the
563
+ master has verified its live role. The goal is a one-shot deadline that must be
564
+ rearmed explicitly:
565
+
566
+ ```bash
567
+ appsdk goal subscribe --goal docs/goals/<feature>-plan.md --interval 10m
568
+ ```
569
+ - Path must point to an existing markdown file (`.md`).
570
+ - A goal prompt is only an execution pointer to that plan; it does not contain
571
+ a second plan or register itself. Follow
572
+ [goal-prompt.md](references/goal-prompt.md) and emit the prompt only after
573
+ the plan exists and the goal is confirmed/admitted.
574
+ - For an MVP→M1 migration or closeout, the referenced plan must bind the MVP
575
+ baseline, M1 target, owner/scope, legacy inventory and authorized route,
576
+ identity/route proof, the Loop's Trigger/Work/Gate/State/Stop components,
577
+ exact positive/negative gates, and post-merge/install/restart replay. The
578
+ canonical migration state machine remains in the
579
+ [AppSDK migration Skill](../appsdk-migration/SKILL.md).
580
+ - Desktop must not call `appsdk goal subscribe`. Goal registration belongs to
581
+ the authorized live TUI/master endpoint; a prompt, appserver status, or
582
+ daemon health cannot substitute for that authority.
583
+ - Master is awakened periodically to:
584
+ 1. Inspect worker states with `collab context` and `appsdk subworker status`; dispatch decomposed tasks to keep workers saturated whenever any worker is idle.
585
+ 2. Enforce AppSDK lifecycle governance across all subworker tasks.
586
+ 3. Report any upstream AppSDK framework issues via `appsdk bug new --upstream`.
587
+ 4. Conclude only when all goal DoD conditions pass.
588
+
589
+ The master's primary responsibilities are task decomposition, resource
590
+ allocation and recovery, worker saturation, blocker ownership, independent
591
+ review routing, merge/integration, bug management, final acceptance, and
592
+ cleanup. The master owns the P0/P1 queue and dirty `main`: triage and dispatch
593
+ the highest-priority open bugs, resolve or explicitly contain `main` dirt
594
+ before integration, and do not leave either queue waiting for a worker to
595
+ volunteer. The master does not write ordinary product code; implementation
596
+ belongs to the task owner. The master keeps architecture, integration and
597
+ critical repair only. Every assignment must state done-iff, allowed and
598
+ forbidden paths, worktree/branch, exact test commands, expected result, and
599
+ evidence location.
600
+
601
+ ## Evidence and state ownership
602
+
603
+ - Project AGENTS owns project facts; Skills own procedure; declared machine
604
+ contracts own enforceable gates. Existing lifecycle records remain the sole
605
+ evidence truth. Plans, notes and Collab statuses do not duplicate PASS.
606
+ - Runtime review admission retains whitebox, public-entrypoint blackbox and
607
+ exact candidate/artifact/environment identity. Module `deployment_operations`
608
+ declares required `install`/`restart` receipts; omission retains both for
609
+ compatibility, `[]` means neither operation applies. Bind this choice before
610
+ validation; changes invalidate artifact identity. Every supplied receipt is
611
+ checked. A missing required capability remains a blocker.
612
+ - Review confidence scores are optional annotation, never proof of quality.
613
+ - Freeze/Active/Protected apply when immutable artifact publication is in
614
+ scope. Do not require freezing for a documentation edit or ordinary review.
615
+ - Engineering delivery may complete with a retained worktree. Keep ownership
616
+ and cleanup obligations explicit; only claim resource closure after actual
617
+ safe cleanup. No forced deletion to make a task appear complete.
618
+ - Memory is optional. No automatic durable memory/rule promotion. Long tasks
619
+ and handoffs may record concise decisions and references to existing evidence.
620
+ Memory migration and re-entry are explicit independent operations: use
621
+ `project-memory migrate` for a source-preserving, resumable schema move and
622
+ `project-memory index|export` to render old and current raw records as a
623
+ Markdown index/details directory; after an intentional detail edit, use
624
+ `project-memory import` to append the change back to raw history. Markdown
625
+ is an interchange view, not a second truth store.
626
+ Normal memory writes use one `project-memory entry` invocation, which writes
627
+ the raw event and regenerates detail/index/projection together; do not hand
628
+ write one of those derived files as a separate step.
629
+ `project-memory reentry [project] --run <run-id>` to resume the same run after
630
+ interruption. A missing or rebuilding memory index is not a governance
631
+ failure, and memory state must not be reconstructed from Guide, debug,
632
+ develop, or log payloads.
633
+
634
+ ## Persistent user requirements
635
+
636
+ The project-owned `.appsdk/requirements.json` ledger retains original user
637
+ requirements, explicit conversation change instructions, and every version.
638
+ Read it with `appsdk requirements show [project]` or `history`. Only an explicit
639
+ user instruction may create, replace, or revoke an item. Submit that original
640
+ instruction and its conversation source with `appsdk requirements apply
641
+ [project] --input <json>`; do not infer authorization from implementation work
642
+ or a review PASS. Ambiguous changes stay pending until the user specifies them.
643
+ No biometric, signature, or external identity check is required.
644
+
645
+ Bind the task goal's `requirements_version` to the current ledger version.
646
+ After an authorized change, update the task reference and rerun the affected
647
+ validation. `review-context` loads all items and history for independent
648
+ review. A task close, SDK refresh, or governance reset does not revoke or erase
649
+ requirements. A legacy project without a ledger reports `not_established`;
650
+ do not silently convert its old goal into an authorized requirement baseline.
651
+
652
+ ## References: load only the relevant domain
653
+
654
+ - Initialization or migration: [bootstrap-migration.md](references/bootstrap-migration.md).
655
+ - Development/debug: [development-debug.md](references/development-debug.md).
656
+ - Runtime review/delivery/freeze: [review-delivery.md](references/review-delivery.md).
657
+ - Authoritative requirement review: [authoritative-review-template.md](references/authoritative-review-template.md).
658
+ - Selected persistent planning: [process-control-harness.md](references/process-control-harness.md).
659
+ - Contract errors/compatibility: [contracts-and-failures.md](references/contracts-and-failures.md).
660
+ - Explicit goal-prompt request: [goal-prompt.md](references/goal-prompt.md).
661
+
662
+ Failure reports name the failed applicable gate, preserved state, owner and next
663
+ action. Never infer deployed success, merge, freeze or cleanup from an earlier
664
+ test or an auxiliary workflow close.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "AppSDK Project Governance"
3
+ short_description: "Guide and govern the full project lifecycle"
4
+ default_prompt: "Use $appsdk-project-governance to compare project rules, Skills, tests, and CI/hook entrypoints with the versioned template. Reuse covered authorization, run only affected checks, and use init only to refresh SDK resources; Guidance, freeze, and runtime flows apply only when selected."