wendkeep 0.78.0 → 0.79.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.
- package/CHANGELOG.md +41 -0
- package/README.en.md +57 -2
- package/README.md +57 -2
- package/docs/en/commands/changes-and-verification.md +66 -1
- package/docs/en/commands/operating-profiles.md +49 -5
- package/docs/en/commands/verify.md +45 -0
- package/docs/en/commands/worktrees.md +39 -4
- package/docs/pt-BR/commands/changes-and-verification.md +65 -1
- package/docs/pt-BR/commands/operating-profiles.md +51 -5
- package/docs/pt-BR/commands/verify.md +45 -0
- package/docs/pt-BR/commands/worktrees.md +38 -3
- package/hooks/active-context-store.mjs +530 -2
- package/hooks/change-core.mjs +201 -122
- package/hooks/obsidian-common.mjs +175 -9
- package/hooks/spec-core.mjs +93 -29
- package/package.json +2 -2
- package/schema/wendkeep.provenance-receipt-v2.schema.json +66 -0
- package/src/archive-operation-lock.mjs +235 -0
- package/src/change.mjs +1780 -79
- package/src/delivery.mjs +724 -67
- package/src/memory.mjs +2 -1
- package/src/provenance-gate.mjs +575 -0
- package/src/provenance-sources.mjs +547 -0
- package/src/receipt-ledger.mjs +841 -0
- package/src/release-provenance.mjs +48 -0
- package/src/worktree-cleanup.mjs +1733 -118
- package/src/worktree.mjs +94 -5
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,47 @@ All notable changes to **wendkeep** are documented here. Format based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project follows
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.79.0] — 2026-08-23
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Gate único de proveniência.** Archive, delivery, release e cleanup rederivam a autoridade no
|
|
12
|
+
subject atual com a taxonomia `verified`, `reported`, `legacy-unbound`, `stale`, `conflict` e
|
|
13
|
+
`unproven`; somente `verified` satisfaz prova obrigatória, com códigos e recovery sanitizados.
|
|
14
|
+
- **Fontes verificáveis.** Adapters injetáveis ligam Git, CI, tag, NPM e GitHub Release ao
|
|
15
|
+
repositório, target commit, package/version, integrity e notas esperados sem confiar em URL/claim
|
|
16
|
+
fornecida nem na worktree incidental.
|
|
17
|
+
- **Receipt Ledger v2.** Autorizações de archive e receipts de delivery/cleanup ganham sequência,
|
|
18
|
+
`previous_hash`, `receipt_hash`, lock, publicação atômica e checkpoint separado, com schema
|
|
19
|
+
público e replay idempotente.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- **Archive fail-closed.** Evidence Envelope v2, pacote deep e verdict completos/canônicos agora
|
|
24
|
+
são exigidos mesmo sem sensores; uma autorização v2 é encadeada antes da mutação e `--force`
|
|
25
|
+
continua limitado a tarefa aberta, sem pular proveniência.
|
|
26
|
+
- **Delivery e release ligadas ao destino.** Merge/push observam `<remote>/<branch>`, exigem
|
|
27
|
+
ancestralidade e preservam origin/worktree/branch do start; tag/publish derivam package e artefato
|
|
28
|
+
do target e verificam CI → commit → tag → versão/integrity → GitHub Release. Offline
|
|
29
|
+
permanece `reported` e não grava completion receipt.
|
|
30
|
+
- **Cleanup retomável e causal.** Finish/remove/prune validam o ledger antes da mutação, vinculam
|
|
31
|
+
todos os contextos, PR/head/merge e ator disponível, e retomam o mesmo operation ID após crash
|
|
32
|
+
antes/depois do append ou finalize; texto e `--json` preservam códigos e recovery sanitizados.
|
|
33
|
+
- **Compatibilidade explícita.** Ledgers v1 permanecem read-only como prefixo `legacy-unbound`;
|
|
34
|
+
no Windows com Node 18–22, receipts e operation locks tratam `st_dev=0` como metadado
|
|
35
|
+
indisponível quando o inode continua idêntico, sem aceitar identificadores de dispositivo
|
|
36
|
+
não-zero conflitantes; aquisições e liberações concorrentes relêem rotações e sharing
|
|
37
|
+
violations transitórias com limite estrito, e o release fecha e revalida o marker antes do
|
|
38
|
+
unlink nas runtimes antigas;
|
|
39
|
+
README, contrato do harness e guias de changes/verify/profiles/worktrees foram atualizados em
|
|
40
|
+
PT-BR/EN.
|
|
41
|
+
|
|
42
|
+
### Security
|
|
43
|
+
|
|
44
|
+
- Adulteração intermediária, JSON parcial, cauda/checkpoint removidos, colisão de ID, locks
|
|
45
|
+
trocados por outro owner, writer concorrente e escape por symlink/junction passam a bloquear antes
|
|
46
|
+
da mutação; diagnósticos não persistem tokens nem paths privados.
|
|
47
|
+
|
|
7
48
|
## [0.78.0] — 2026-08-22
|
|
8
49
|
|
|
9
50
|
### Added
|
package/README.en.md
CHANGED
|
@@ -239,7 +239,7 @@ The README is the map; the guides provide syntax, options, exit codes, examples,
|
|
|
239
239
|
| Group | Use it for | Detailed guide |
|
|
240
240
|
|---|---|---|
|
|
241
241
|
| **Installation and updates** | `init`, `sync`, companions, and the first project↔vault binding | [Installation and first use](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/getting-started.md) |
|
|
242
|
-
| **Managed worktrees** | `worktree create/list/status/open/finish/cleanup/remove/prune`, merge proof, preflight, and receipts | [Managed worktrees](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/worktrees.md) |
|
|
242
|
+
| **Managed worktrees** | `worktree create/list/status/open/finish/cleanup/remove/prune`, merge proof, preflight, crash-safe cleanup/common gate, and receipts | [Managed worktrees](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/worktrees.md) |
|
|
243
243
|
| **Active context** | `active_contexts` by `repository_id`/`worktree_id`/`work_session_id`, causal transition, quarantine, and explicit recovery | [Active context](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/context.md) |
|
|
244
244
|
| **Operating profiles** | `profile`, `flow`, always-on Keep Core, and Wend Runtime governance | [Operating profiles](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/operating-profiles.md) |
|
|
245
245
|
| **Changes and verification** | `change`, specs, sensors, TDD, evidence, and archive | [Changes and verification](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/changes-and-verification.md) |
|
|
@@ -352,9 +352,28 @@ an initialized registry never copies a global authorization without proven ident
|
|
|
352
352
|
```bash
|
|
353
353
|
npx wendkeep delivery start release-0-74-0 --allow git:merge --allow git:push --allow publish --source-change <slug> --source-commit <sha> --session <id>
|
|
354
354
|
npx wendkeep delivery status release-0-74-0 --session <id>
|
|
355
|
-
npx wendkeep delivery finish release-0-74-0 --target main --ci-url <url> --version 0.74.0 --npm-integrity <sha512> --release-url <url> --session <id>
|
|
355
|
+
npx wendkeep delivery finish release-0-74-0 --target origin/main --ci-url <url> --version 0.74.0 --npm-integrity <sha512> --release-url <url> --session <id>
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
+
For `git:merge` and `git:push` capabilities, `delivery finish` requires
|
|
359
|
+
`--target <remote>/<branch>` (for example, `--target origin/main`). `delivery start` binds the
|
|
360
|
+
`origin` remote to the expected `repository`; during finish, the target is resolved again with
|
|
361
|
+
`git ls-remote`. If the target cannot be resolved or the origin/repository binding diverges, the
|
|
362
|
+
delivery is blocked before provenance adapters run.
|
|
363
|
+
|
|
364
|
+
The provenance gate re-derives authority against the current subject before archive, delivery,
|
|
365
|
+
release, or cleanup. Its single taxonomy is `verified`, `reported`, `legacy-unbound`, `stale`,
|
|
366
|
+
`conflict`, and `unproven`; only `verified` authorizes required proof. Evidence, a verdict, or a
|
|
367
|
+
receipt captured before amend/rebase, from another branch/worktree/session, or backed only by a
|
|
368
|
+
reported/offline external claim fails closed with objective recovery. New receipts use schema v2,
|
|
369
|
+
`previous_hash`, `receipt_hash`, and a separate checkpoint to detect tampering and truncation.
|
|
370
|
+
Stable codes are `WENDKEEP_PROVENANCE_GATE_BLOCKED`, `WENDKEEP_RECEIPT_LEDGER_BUSY`,
|
|
371
|
+
`WENDKEEP_RECEIPT_LEDGER_CONFLICT`, `WENDKEEP_RECEIPT_LEDGER_CORRUPT`, and
|
|
372
|
+
`WENDKEEP_RECEIPT_LEDGER_TRUNCATED`. Safe recovery reads `state`, `reasonCodes`, `diagnostics`,
|
|
373
|
+
and `repair.command` in `--json` output, runs `npx --no-install wendkeep verify --deep --json` or
|
|
374
|
+
the indicated status command, and recaptures proof; it never prints raw stderr, tokens, private URLs,
|
|
375
|
+
or Vault paths, and never edits the ledger/checkpoint.
|
|
376
|
+
|
|
358
377
|
If the harness does not record a lease, a small fix remains under the configured profile —
|
|
359
378
|
`GOVERN` by default. `OFF` does not mean “simple task”: it is a persistent human choice that hands
|
|
360
379
|
governance to the native harness. The LLM may temporarily elevate an `OFF` base to a Wend route,
|
|
@@ -536,6 +555,42 @@ explore → propose → apply (TDD) → verify → archive
|
|
|
536
555
|
|
|
537
556
|
> The gate blocks unless the scaffold is filled, no task is open, evidence is fresh, and every declared requirement is covered. **`--force` waives exactly one of those — the open-task check — and is the human's call, never the agent's.** An unfilled scaffold, a red critical sensor, stale evidence, an orphan requirement or a missing verdict block regardless.
|
|
538
557
|
|
|
558
|
+
After the fix, archive requires a **final** recapture with
|
|
559
|
+
`wendkeep verify --deep --change <slug>`. The package is complete and canonical; the verdict must
|
|
560
|
+
also be complete and canonical, with both bound to the same checkout, change, tasks, spec, and sensors. Before any mutation, the command
|
|
561
|
+
writes an authorization receipt to the separate `change-archive-receipts-v2` ledger; only after
|
|
562
|
+
that receipt is valid may it promote the spec/ADR or move the change. `change archive --json`
|
|
563
|
+
returns the serializable `state`, `reason_codes`, `diagnostics`, and `repair` fields. Corruption
|
|
564
|
+
or truncation in any ledger fails closed before mutation. `--force` does not bypass provenance,
|
|
565
|
+
integrity, package, verdict, corruption, or truncation; the exact recovery is the recapture above.
|
|
566
|
+
|
|
567
|
+
Archive sealing uses the runtime lock and a private ASCII transaction at
|
|
568
|
+
`.brain/runtime/archive-transactions/<uuid>/{original,authorized}`: it atomically renames the live
|
|
569
|
+
change to `original`, checks the digest, and promotes only `authorized`. On a seal or divergence
|
|
570
|
+
failure, it removes the snapshot and restores `original` without partial promotion. Multi-spec
|
|
571
|
+
promotion is one atomic unit: it captures before-images/digests, rolls back before/after writes,
|
|
572
|
+
and permits retry only after reconciliation and fresh verification. The post-release finalizer
|
|
573
|
+
validates original/destination digests, but the `completed` journal keeps the `original` retained;
|
|
574
|
+
no destructive cleanup is automatic. A failure leaves `published-recovery-required`. Text and --json
|
|
575
|
+
keep the same sanitized diagnostic (code, operation, state, blocker, expected, observed, recovery).
|
|
576
|
+
|
|
577
|
+
The archive uses a `directory lock` with a token-specific marker and lease: acquisition prepares a
|
|
578
|
+
sibling `.pending` directory and publishes it by atomic rename, uses no hardlink, and allows at most
|
|
579
|
+
3 topology attempts. A live owner returns `WENDKEEP_ARCHIVE_BUSY`, a dead owner is safely reaped,
|
|
580
|
+
an invalid marker returns `WENDKEEP_ARCHIVE_LOCK_UNAVAILABLE`, and ownership loss returns
|
|
581
|
+
`WENDKEEP_ARCHIVE_LOCK_OWNERSHIP_LOST`. The transaction keeps `archive-transaction.json` with
|
|
582
|
+
phases `prepared` → `isolated` → `copied` → `sealed` → `published` → `promotion-prepared` →
|
|
583
|
+
`promotion-applied` → `completed` or `recovery-required`. A pending journal blocks a new archive for
|
|
584
|
+
the same slug before the gate. On
|
|
585
|
+
a collision/post-publication failure, `original` is retained and the state is
|
|
586
|
+
`published-recovery-required`; `operation_id` and `transaction_phase` are sanitized. Inspect it
|
|
587
|
+
with `wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]`:
|
|
588
|
+
without `--spec-action`, this is a read-only, fail-closed, idempotent operation that returns
|
|
589
|
+
sanitized actions without promoting or deleting. `rollback` restores before-images and `resume`
|
|
590
|
+
converges after-images for a `promotion-prepared` promotion, while retaining the journal for
|
|
591
|
+
reconciliation. When an operation ID exists, `repair.command` points to that recovery; do not treat
|
|
592
|
+
`command:null` as the normal flow.
|
|
593
|
+
|
|
539
594
|
`wendkeep init` seeds process skills into the vault's `.brain/skills` and delivers identical copies to `.claude/skills/` and `.agents/skills/`; Codex gets the agent definitions (`.brain/agents/*.toml` → `.codex/agents/`) plus a managed section in `AGENTS.md` that indexes the skills. Every skill carries source hash/version metadata; `doctor` warns when reseed + agent restart is required.
|
|
540
595
|
|
|
541
596
|
### The loop in five minutes
|
package/README.md
CHANGED
|
@@ -239,7 +239,7 @@ The README is the map; the guides provide syntax, options, exit codes, examples,
|
|
|
239
239
|
| Group | Use it for | Detailed guide |
|
|
240
240
|
|---|---|---|
|
|
241
241
|
| **Installation and updates** | `init`, `sync`, companions, and the first project↔vault binding | [Installation and first use](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/getting-started.md) |
|
|
242
|
-
| **Managed worktrees** | `worktree create/list/status/open/finish/cleanup/remove/prune`, merge proof, preflight, and receipts | [Managed worktrees](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/worktrees.md) |
|
|
242
|
+
| **Managed worktrees** | `worktree create/list/status/open/finish/cleanup/remove/prune`, merge proof, preflight, crash-safe cleanup/common gate, and receipts | [Managed worktrees](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/worktrees.md) |
|
|
243
243
|
| **Active context** | `active_contexts` by `repository_id`/`worktree_id`/`work_session_id`, causal transition, quarantine, and explicit recovery | [Active context](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/context.md) |
|
|
244
244
|
| **Operating profiles** | `profile`, `flow`, always-on Keep Core, and Wend Runtime governance | [Operating profiles](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/operating-profiles.md) |
|
|
245
245
|
| **Changes and verification** | `change`, specs, sensors, TDD, evidence, and archive | [Changes and verification](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/changes-and-verification.md) |
|
|
@@ -352,9 +352,28 @@ an initialized registry never copies a global authorization without proven ident
|
|
|
352
352
|
```bash
|
|
353
353
|
npx wendkeep delivery start release-0-74-0 --allow git:merge --allow git:push --allow publish --source-change <slug> --source-commit <sha> --session <id>
|
|
354
354
|
npx wendkeep delivery status release-0-74-0 --session <id>
|
|
355
|
-
npx wendkeep delivery finish release-0-74-0 --target main --ci-url <url> --version 0.74.0 --npm-integrity <sha512> --release-url <url> --session <id>
|
|
355
|
+
npx wendkeep delivery finish release-0-74-0 --target origin/main --ci-url <url> --version 0.74.0 --npm-integrity <sha512> --release-url <url> --session <id>
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
+
For `git:merge` and `git:push` capabilities, `delivery finish` requires
|
|
359
|
+
`--target <remote>/<branch>` (for example, `--target origin/main`). `delivery start` binds the
|
|
360
|
+
`origin` remote to the expected `repository`; during finish, the target is resolved again with
|
|
361
|
+
`git ls-remote`. If the target cannot be resolved or the origin/repository binding diverges, the
|
|
362
|
+
delivery is blocked before provenance adapters run.
|
|
363
|
+
|
|
364
|
+
The provenance gate re-derives authority against the current subject before archive, delivery,
|
|
365
|
+
release, or cleanup. Its single taxonomy is `verified`, `reported`, `legacy-unbound`, `stale`,
|
|
366
|
+
`conflict`, and `unproven`; only `verified` authorizes required proof. Evidence, a verdict, or a
|
|
367
|
+
receipt captured before amend/rebase, from another branch/worktree/session, or backed only by a
|
|
368
|
+
reported/offline external claim fails closed with objective recovery. New receipts use schema v2,
|
|
369
|
+
`previous_hash`, `receipt_hash`, and a separate checkpoint to detect tampering and truncation.
|
|
370
|
+
Stable codes are `WENDKEEP_PROVENANCE_GATE_BLOCKED`, `WENDKEEP_RECEIPT_LEDGER_BUSY`,
|
|
371
|
+
`WENDKEEP_RECEIPT_LEDGER_CONFLICT`, `WENDKEEP_RECEIPT_LEDGER_CORRUPT`, and
|
|
372
|
+
`WENDKEEP_RECEIPT_LEDGER_TRUNCATED`. Safe recovery reads `state`, `reasonCodes`, `diagnostics`,
|
|
373
|
+
and `repair.command` in `--json` output, runs `npx --no-install wendkeep verify --deep --json` or
|
|
374
|
+
the indicated status command, and recaptures proof; it never prints raw stderr, tokens, private URLs,
|
|
375
|
+
or Vault paths, and never edits the ledger/checkpoint.
|
|
376
|
+
|
|
358
377
|
If the harness does not record a lease, a small fix remains under the configured profile —
|
|
359
378
|
`GOVERN` by default. `OFF` does not mean “simple task”: it is a persistent human choice that hands
|
|
360
379
|
governance to the native harness. The LLM may temporarily elevate an `OFF` base to a Wend route,
|
|
@@ -536,6 +555,42 @@ explore → propose → apply (TDD) → verify → archive
|
|
|
536
555
|
|
|
537
556
|
> The gate blocks unless the scaffold is filled, no task is open, evidence is fresh, and every declared requirement is covered. **`--force` waives exactly one of those — the open-task check — and is the human's call, never the agent's.** An unfilled scaffold, a red critical sensor, stale evidence, an orphan requirement or a missing verdict block regardless.
|
|
538
557
|
|
|
558
|
+
After the fix, archive requires a **final** recapture with
|
|
559
|
+
`wendkeep verify --deep --change <slug>`. The package is complete and canonical; the verdict must
|
|
560
|
+
also be complete and canonical, with both bound to the same checkout, change, tasks, spec, and sensors. Before any mutation, the command
|
|
561
|
+
writes an authorization receipt to the separate `change-archive-receipts-v2` ledger; only after
|
|
562
|
+
that receipt is valid may it promote the spec/ADR or move the change. `change archive --json`
|
|
563
|
+
returns the serializable `state`, `reason_codes`, `diagnostics`, and `repair` fields. Corruption
|
|
564
|
+
or truncation in any ledger fails closed before mutation. `--force` does not bypass provenance,
|
|
565
|
+
integrity, package, verdict, corruption, or truncation; the exact recovery is the recapture above.
|
|
566
|
+
|
|
567
|
+
Archive sealing uses the runtime lock and a private ASCII transaction at
|
|
568
|
+
`.brain/runtime/archive-transactions/<uuid>/{original,authorized}`: it atomically renames the live
|
|
569
|
+
change to `original`, checks the digest, and promotes only `authorized`. On a seal or divergence
|
|
570
|
+
failure, it removes the snapshot and restores `original` without partial promotion. Multi-spec
|
|
571
|
+
promotion is one atomic unit: it captures before-images/digests, rolls back before/after writes,
|
|
572
|
+
and permits retry only after reconciliation and fresh verification. The post-release finalizer
|
|
573
|
+
validates original/destination digests, but the `completed` journal keeps the `original` retained;
|
|
574
|
+
no destructive cleanup is automatic. A failure leaves `published-recovery-required`. Text and --json
|
|
575
|
+
keep the same sanitized diagnostic (code, operation, state, blocker, expected, observed, recovery).
|
|
576
|
+
|
|
577
|
+
The archive uses a `directory lock` with a token-specific marker and lease: acquisition prepares a
|
|
578
|
+
sibling `.pending` directory and publishes it by atomic rename, uses no hardlink, and allows at most
|
|
579
|
+
3 topology attempts. A live owner returns `WENDKEEP_ARCHIVE_BUSY`, a dead owner is safely reaped,
|
|
580
|
+
an invalid marker returns `WENDKEEP_ARCHIVE_LOCK_UNAVAILABLE`, and ownership loss returns
|
|
581
|
+
`WENDKEEP_ARCHIVE_LOCK_OWNERSHIP_LOST`. The transaction keeps `archive-transaction.json` with
|
|
582
|
+
phases `prepared` → `isolated` → `copied` → `sealed` → `published` → `promotion-prepared` →
|
|
583
|
+
`promotion-applied` → `completed` or `recovery-required`. A pending journal blocks a new archive for
|
|
584
|
+
the same slug before the gate. On
|
|
585
|
+
a collision/post-publication failure, `original` is retained and the state is
|
|
586
|
+
`published-recovery-required`; `operation_id` and `transaction_phase` are sanitized. Inspect it
|
|
587
|
+
with `wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]`:
|
|
588
|
+
without `--spec-action`, this is a read-only, fail-closed, idempotent operation that returns
|
|
589
|
+
sanitized actions without promoting or deleting. `rollback` restores before-images and `resume`
|
|
590
|
+
converges after-images for a `promotion-prepared` promotion, while retaining the journal for
|
|
591
|
+
reconciliation. When an operation ID exists, `repair.command` points to that recovery; do not treat
|
|
592
|
+
`command:null` as the normal flow.
|
|
593
|
+
|
|
539
594
|
`wendkeep init` seeds process skills into the vault's `.brain/skills` and delivers identical copies to `.claude/skills/` and `.agents/skills/`; Codex gets the agent definitions (`.brain/agents/*.toml` → `.codex/agents/`) plus a managed section in `AGENTS.md` that indexes the skills. Every skill carries source hash/version metadata; `doctor` warns when reseed + agent restart is required.
|
|
540
595
|
|
|
541
596
|
### The loop in five minutes
|
|
@@ -30,7 +30,8 @@ npx wendkeep change status [slug] [--session <id>]
|
|
|
30
30
|
npx wendkeep spec effective [--change <slug>] [--session <id>]
|
|
31
31
|
npx wendkeep sensors list
|
|
32
32
|
npx wendkeep verify [--deep] [--change <slug>] [--session <id>]
|
|
33
|
-
npx wendkeep change archive <slug> [--session <id>]
|
|
33
|
+
npx wendkeep change archive <slug> [--json] [--session <id>]
|
|
34
|
+
npx wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
## Options and exit codes
|
|
@@ -47,6 +48,10 @@ npx wendkeep change archive <slug> [--session <id>]
|
|
|
47
48
|
only one unambiguous active context for the worktree is accepted; ambiguity returns exit `2`.
|
|
48
49
|
- `change relink [--apply]` and `change backlink [--apply]` repair graph links; preview is default.
|
|
49
50
|
- `change abandon <slug>` drops work without an ADR; `archive --force` needs explicit human choice.
|
|
51
|
+
- `change archive recover <operation-id> --change <slug> [--spec-action rollback|resume]` inspects a
|
|
52
|
+
pending transaction by default; with `rollback` or `resume`, it converges only the spec
|
|
53
|
+
promotion prepared in the journal, under the operation lock and validation. It never promotes the
|
|
54
|
+
change, deletes the journal, or invents reconciliation.
|
|
50
55
|
- `wendkeep spec list|show|effective|migrate|rebase` manages living contracts and deltas.
|
|
51
56
|
- `wendkeep sensors list|add` manages executable proof.
|
|
52
57
|
- Exit `0` means completion; gates use exit `1` for red proof and exit `2` for invalid
|
|
@@ -83,6 +88,66 @@ proven checkout. On a mismatch, return to the correct worktree/session and rerun
|
|
|
83
88
|
`verify --deep`, and `wk-verify`. Fields, text/binary normalization, error codes, and recovery are
|
|
84
89
|
detailed in the [verify guide](verify.md).
|
|
85
90
|
|
|
91
|
+
The common gate reclassifies the envelope, package, and verdict as `verified`, `reported`,
|
|
92
|
+
`legacy-unbound`, `stale`, `conflict`, or `unproven`; only `verified` permits archive. A block
|
|
93
|
+
returns `WENDKEEP_PROVENANCE_GATE_BLOCKED`: stabilize/recover the context, run `verify`, then
|
|
94
|
+
`verify --deep`, and request a fresh `wk-verify` pass. `--force` may waive only an open task; for
|
|
95
|
+
provenance, integrity, package, and verdict it does **not** change the result or promote a spec/ADR.
|
|
96
|
+
Ledger errors are `WENDKEEP_RECEIPT_LEDGER_BUSY`, `WENDKEEP_RECEIPT_LEDGER_CONFLICT`,
|
|
97
|
+
`WENDKEEP_RECEIPT_LEDGER_CORRUPT`, and `WENDKEEP_RECEIPT_LEDGER_TRUNCATED`. On a block, use the
|
|
98
|
+
sanitized `--json` output (`state`, `reasonCodes`, `diagnostics`, `repair.command`), execute the
|
|
99
|
+
indicated recovery, and run `npx --no-install wendkeep verify --deep --json`; preserve and recapture
|
|
100
|
+
proof without editing the ledger/checkpoint or exposing stderr, tokens, private URLs, or Vault paths.
|
|
101
|
+
|
|
102
|
+
### Post-fix archive contract
|
|
103
|
+
|
|
104
|
+
Before mutation, perform the final recapture with `wendkeep verify --deep --change <slug>`. The
|
|
105
|
+
package and verdict must be complete and canonical, bound to the same checkout, change, tasks,
|
|
106
|
+
spec, and sensors. Archive first writes an authorization receipt to the separate
|
|
107
|
+
`change-archive-receipts-v2` ledger; only after it validates may it promote the spec/ADR or move
|
|
108
|
+
the change. `change archive --json` returns the serializable `state`, `reason_codes`,
|
|
109
|
+
`diagnostics`, and `repair` fields. Corruption or truncation in the proof or archive ledger fails
|
|
110
|
+
closed before any write. `--force` does not bypass provenance or integrity, package/verdict,
|
|
111
|
+
corruption, or truncation. The exact recovery is to repeat
|
|
112
|
+
`wendkeep verify --deep --change <slug>` in the correct checkout.
|
|
113
|
+
|
|
114
|
+
The mutation acquires the runtime lock `.brain/runtime/change-archive-operation.lock` and opens a
|
|
115
|
+
private ASCII transaction at `.brain/runtime/archive-transactions/<uuid>/{original,authorized}`.
|
|
116
|
+
It atomically renames the live change to `original`, checks the digest, and promotes only the
|
|
117
|
+
`authorized` copy; the public namespace is never a publication source. On a seal or divergence
|
|
118
|
+
failure with `WENDKEEP_ARCHIVE_INPUT_CHANGED` before promotion, the `authorized` snapshot is
|
|
119
|
+
removed and `original` is restored without partial promotion. A successful archive keeps the
|
|
120
|
+
`completed` journal; the post-release finalizer validates the digests of `original` and the
|
|
121
|
+
published destination but retains `original` and the transaction, with no automatic destructive
|
|
122
|
+
cleanup.
|
|
123
|
+
|
|
124
|
+
The archive lock is a `directory lock`: the canonical directory contains a token-specific marker
|
|
125
|
+
and lease. Acquisition prepares a sibling `.pending` directory, writes owner/lease, and publishes
|
|
126
|
+
it by atomic rename; it uses no hardlink and re-observes collisions for at most 3 topology attempts.
|
|
127
|
+
A live owner returns `WENDKEEP_ARCHIVE_BUSY`; a dead owner may be safely reaped without deleting a
|
|
128
|
+
successor. Invalid structure or marker returns `WENDKEEP_ARCHIVE_LOCK_UNAVAILABLE`; ownership loss
|
|
129
|
+
returns `WENDKEEP_ARCHIVE_LOCK_OWNERSHIP_LOST`.
|
|
130
|
+
|
|
131
|
+
Each operation keeps an `archive-transaction.json` manifest with phases `prepared` → `isolated` →
|
|
132
|
+
`copied` → `sealed` → `published` → `promotion-prepared` → `promotion-applied` → `completed` or
|
|
133
|
+
`recovery-required`. A pending journal blocks a new archive for the same slug before the gate. On a
|
|
134
|
+
collision or post-publication failure, `original` is retained and the state is
|
|
135
|
+
`published-recovery-required`. Use the fail-closed, idempotent inspection
|
|
136
|
+
`wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]`;
|
|
137
|
+
without `--spec-action` it only returns sanitized actions. `rollback` converges before-images and
|
|
138
|
+
`resume` converges after-images for a `promotion-prepared` promotion; both retain the journal for
|
|
139
|
+
further reconciliation.
|
|
140
|
+
|
|
141
|
+
Multi-spec promotion is one atomic unit: it captures before-images/digests for every capability,
|
|
142
|
+
rolls back every target (including state/README) on a before- or after-write failure, and permits a
|
|
143
|
+
retry only after journal reconciliation and fresh verification. The post-release finalizer validates
|
|
144
|
+
the original/destination digests but retains the `completed` journal and `original`; no destructive
|
|
145
|
+
cleanup is automatic. Sanitized `operation_id` and
|
|
146
|
+
`transaction_phase` fields accompany the diagnostic; `repair.command` points to
|
|
147
|
+
`wendkeep change archive recover <operation-id> --change <slug>` when an operation is identified.
|
|
148
|
+
Text and --json use the same sanitized diagnostic with code, operation, state, blocker, expected,
|
|
149
|
+
observed, recovery, reason_codes, diagnostics, and repair.
|
|
150
|
+
|
|
86
151
|
## Tool-scope fence
|
|
87
152
|
|
|
88
153
|
`change-guard` is also projected to Codex `PreToolUse`. Before a Git mutation or supported writing
|
|
@@ -59,7 +59,7 @@ npx wendkeep flow finish <id> [--session <id>]
|
|
|
59
59
|
npx wendkeep flow promote <id> [--change-slug <slug>] [--session <id>]
|
|
60
60
|
npx wendkeep delivery start [id] --allow <capability> [--source-change <slug>] [--source-commit <sha>] [--session <id>]
|
|
61
61
|
npx wendkeep delivery status [id] [--session <id>]
|
|
62
|
-
npx wendkeep delivery finish [id] [--target <
|
|
62
|
+
npx wendkeep delivery finish [id] [--target <remote>/<branch>] [--ci-url <url>] [--version <x.y.z>] [--npm-integrity <sha512>] [--release-url <url>] [--session <id>]
|
|
63
63
|
npx wendkeep delivery abandon [id] --reason <text> [--session <id>]
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -180,13 +180,36 @@ ownership to the native LLM harness.
|
|
|
180
180
|
`contract_impact`, and `operation_risk` are independent dimensions. `delivery start` captures
|
|
181
181
|
repo, branch/worktree, SHA, source change, and capabilities in `.brain/runtime/deliveries/`;
|
|
182
182
|
it creates no `08-Changes` folder, delta, spec, or ADR.
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
- For `git:merge` and `git:push` capabilities, `delivery finish` requires `--target
|
|
184
|
+
<remote>/<branch>` (for example, `--target origin/main`). `delivery start` binds the `origin`
|
|
185
|
+
remote to the expected `repository`; `finish` resolves the target with `git ls-remote` and blocks
|
|
186
|
+
the delivery before provenance adapters if the target cannot be resolved or the binding diverges.
|
|
187
|
+
- `delivery finish` requires a clean worktree and re-derives source/target. Merge/push proves
|
|
188
|
+
ancestry; tag proves package/version and the target tag; `publish` queries CI, NPM, and GitHub
|
|
189
|
+
Release bound to the same commit, version, integrity, and notes. Offline, a claim remains
|
|
190
|
+
`reported` and never becomes `verified`; completion blocks without writing a receipt. New
|
|
191
|
+
receipts form `.brain/runtime/delivery-receipts-v2.jsonl`, with a hash chain and checkpoint; v1
|
|
192
|
+
is only `legacy-unbound`. `WENDKEEP_PROVENANCE_GATE_BLOCKED` provides recovery. If code/config
|
|
193
|
+
must change, `WENDKEEP_DELIVERY_IMPLEMENTATION_REQUIRED` returns work to implementation.
|
|
194
|
+
The gate uses the same taxonomy: `verified`, `reported`, `legacy-unbound`, `stale`, `conflict`, and
|
|
195
|
+
`unproven`. Ledger errors are `WENDKEEP_RECEIPT_LEDGER_BUSY`,
|
|
196
|
+
`WENDKEEP_RECEIPT_LEDGER_CONFLICT`, `WENDKEEP_RECEIPT_LEDGER_CORRUPT`, and
|
|
197
|
+
`WENDKEEP_RECEIPT_LEDGER_TRUNCATED`; inspect sanitized `state`, `reasonCodes`, `diagnostics`, and
|
|
198
|
+
`repair.command` in `--json`, execute the indicated recovery, and recapture proof without editing
|
|
199
|
+
the ledger/checkpoint or exposing stderr, tokens, private URLs, or Vault paths.
|
|
187
200
|
- In a multi-context Vault, `active_contexts[].delivery_id` is authoritative. `--session <id>`
|
|
188
201
|
selects the work session explicitly; without it, only one unambiguous active context for the
|
|
189
202
|
worktree may be used. Implicit status, finish, and abandon resolve that binding, not a global pointer.
|
|
203
|
+
- `delivery` failures expose the same PROV-8 diagnostic in text and in `delivery --json`: a stable
|
|
204
|
+
`code`, `operation`, `state`, first `blocker`, sanitized `expected`/`observed`, and an objective
|
|
205
|
+
`recovery`. Git stderr, tokens, private URLs, and private paths are not propagated.
|
|
206
|
+
- `delivery.completed` and `delivery.abandoned` receipts bind `repository_id`, the public
|
|
207
|
+
`repository` in `owner/repo` form, `worktree_id`, `work_session_id`, `change_slug`, and `branch`.
|
|
208
|
+
The private worktree path never enters the receipt. During contextual finalization, the receipt
|
|
209
|
+
enters the ledger and durable state is written before clearing `active_contexts[].delivery_id`.
|
|
210
|
+
A retry converges to the same receipt whether the binding is already clear or still bound. For
|
|
211
|
+
`delivery abandon`, the free-form reason becomes `reason_digest`; raw text does not enter the
|
|
212
|
+
ledger or state.
|
|
190
213
|
- `CURRENT_DELIVERY` is only a derived projection: it contains the ID for one single, unambiguous
|
|
191
214
|
active context with delivery and stays empty with zero or multiple contexts.
|
|
192
215
|
`WENDKEEP_DELIVERY_CONTEXT_MISMATCH` means the explicit ID belongs to another context; neither
|
|
@@ -275,6 +298,27 @@ remain available and run their own contracts. A completed FLOW leaves a durable,
|
|
|
275
298
|
receipt; a promoted FLOW enters the normal change lifecycle. Completed delivery leaves a receipt
|
|
276
299
|
without an ADR; compact GUIDE archives its result without artificial spec/design/ADR.
|
|
277
300
|
|
|
301
|
+
For archive in GOVERN/ASSURE, the `directory lock` uses a token-specific marker and lease:
|
|
302
|
+
acquisition prepares a sibling `.pending` directory and publishes it by atomic rename, uses no
|
|
303
|
+
hardlink, and allows at most 3 topology attempts. A live owner returns `WENDKEEP_ARCHIVE_BUSY`, a
|
|
304
|
+
dead owner may be safely reaped, an invalid marker returns `WENDKEEP_ARCHIVE_LOCK_UNAVAILABLE`, and
|
|
305
|
+
ownership loss returns `WENDKEEP_ARCHIVE_LOCK_OWNERSHIP_LOST`. The `archive-transaction.json`
|
|
306
|
+
journal moves through `prepared` → `isolated` → `copied` → `sealed` → `published` →
|
|
307
|
+
`promotion-prepared` → `promotion-applied` → `completed` or `recovery-required`; a pending journal
|
|
308
|
+
blocks a new archive for the same slug before the gate.
|
|
309
|
+
`original` is retained on collision/post-publication failure and `published-recovery-required`
|
|
310
|
+
requires inspection. `operation_id` and `transaction_phase` appear only sanitized. Use
|
|
311
|
+
`wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]`:
|
|
312
|
+
without `--spec-action`, read-only, fail-closed, idempotent inspection with no promotion, deletion,
|
|
313
|
+
or invented reconciliation; `rollback` restores before-images and `resume` converges after-images
|
|
314
|
+
for `promotion-prepared`, retaining the journal. When an operation ID exists, `repair.command` points
|
|
315
|
+
to that recovery; do not treat `command:null` as the normal flow.
|
|
316
|
+
|
|
317
|
+
Multi-spec promotion is atomic, with before-images/digests, rollback of targets before/after writes,
|
|
318
|
+
and retry only after reconciliation and fresh verification. The post-release finalizer validates
|
|
319
|
+
original/destination digests, but the `completed` journal keeps the `original` retained; no
|
|
320
|
+
destructive cleanup is automatic.
|
|
321
|
+
|
|
278
322
|
## Common errors and diagnosis
|
|
279
323
|
|
|
280
324
|
- Unknown profile: use exactly `OFF`, `FLOW`, `GUIDE`, `GOVERN`, or `ASSURE`.
|
|
@@ -90,6 +90,44 @@ reviewer must preserve both.
|
|
|
90
90
|
V1 evidence remains readable as `legacy-unbound`, never as equivalent authority. Run
|
|
91
91
|
`wendkeep change status <slug>` to inspect `bound`, `stale`, or `context-mismatch`.
|
|
92
92
|
|
|
93
|
+
The provenance gate normalizes that legacy view into one taxonomy: `verified` when every required
|
|
94
|
+
proof is fresh and bound; `reported` for a recorded claim without an authoritative observation;
|
|
95
|
+
`legacy-unbound` for v1; `stale` for an earlier snapshot; `conflict` for incompatible identity or
|
|
96
|
+
content; and `unproven` for missing or insufficient proof. Precedence is `conflict` > `stale` >
|
|
97
|
+
`legacy-unbound` > `unproven` > `reported` > `verified`, and only `verified` closes the gate.
|
|
98
|
+
|
|
99
|
+
For post-fix archive, the final pass is `wendkeep verify --deep --change <slug>`. It must leave a
|
|
100
|
+
complete and canonical package and verdict bound to the same checkout, change, tasks, spec, and
|
|
101
|
+
sensors. Archive writes the authorization receipt before mutation to the separate
|
|
102
|
+
`change-archive-receipts-v2` ledger. Its `change archive --json` output is serializable and
|
|
103
|
+
exposes `state`, `reason_codes`, `diagnostics`, and `repair`; ledger corruption or truncation
|
|
104
|
+
fails closed. `--force` does not bypass provenance or integrity. The exact recovery is to repeat
|
|
105
|
+
`wendkeep verify --deep --change <slug>` after stabilizing the context.
|
|
106
|
+
|
|
107
|
+
Archive uses a `directory lock` with a token-specific marker and lease. Acquisition prepares a
|
|
108
|
+
sibling `.pending` directory and publishes it by atomic rename, uses no hardlink, and allows at most
|
|
109
|
+
3 topology attempts. A live owner produces `WENDKEEP_ARCHIVE_BUSY`; a dead owner is reaped only
|
|
110
|
+
after safe observation; invalid marker/structure produces `WENDKEEP_ARCHIVE_LOCK_UNAVAILABLE`;
|
|
111
|
+
ownership loss produces `WENDKEEP_ARCHIVE_LOCK_OWNERSHIP_LOST`. The `archive-transaction.json`
|
|
112
|
+
manifest records `prepared` → `isolated` → `copied` → `sealed` → `published` → `promotion-prepared` →
|
|
113
|
+
`promotion-applied` → `completed` or `recovery-required`. A pending journal blocks a new archive for
|
|
114
|
+
the same slug before the gate. On a
|
|
115
|
+
collision or post-publication failure, `original` is retained and the
|
|
116
|
+
`published-recovery-required` state blocks destructive retry. `operation_id` and `transaction_phase`
|
|
117
|
+
are sanitized fields. Inspect it with
|
|
118
|
+
`wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]`:
|
|
119
|
+
without `--spec-action`, this is a read-only, fail-closed, idempotent operation with no promotion,
|
|
120
|
+
deletion, or invented reconciliation. `rollback` restores before-images and `resume` converges
|
|
121
|
+
after-images for a `promotion-prepared` promotion while retaining the journal for reconciliation.
|
|
122
|
+
When an operation ID exists, `repair.command` points to `wendkeep change archive recover <operation-id>
|
|
123
|
+
--change <slug>`; do not treat `command:null` as the normal flow.
|
|
124
|
+
|
|
125
|
+
Multi-spec promotion is one atomic unit: it captures before-images/digests for every capability,
|
|
126
|
+
rolls back every target (including state/README) on a before- or after-write failure, and permits a
|
|
127
|
+
retry only after journal reconciliation and fresh verification. The post-release finalizer validates
|
|
128
|
+
original/destination digests, but the `completed` journal keeps the `original` retained; no
|
|
129
|
+
destructive cleanup is automatic. A failure retains `published-recovery-required`.
|
|
130
|
+
|
|
93
131
|
## Common errors and diagnosis
|
|
94
132
|
|
|
95
133
|
- `no change`: this is exit 2 and a valid idle state; create/use a change or skip verify.
|
|
@@ -102,6 +140,13 @@ V1 evidence remains readable as `legacy-unbound`, never as equivalent authority.
|
|
|
102
140
|
The previous evidence was not replaced.
|
|
103
141
|
- `legacy-unbound`, `stale`, or `context-mismatch`: return to the correct worktree/session, recover
|
|
104
142
|
the context when needed, and rerun `verify` plus `verify --deep`.
|
|
143
|
+
- `WENDKEEP_PROVENANCE_GATE_BLOCKED`: inspect `state`, `reasonCodes`, and `repair`; do not reuse
|
|
144
|
+
proof from another branch/worktree/session. Run the proposed command and recapture the envelope.
|
|
145
|
+
- `WENDKEEP_RECEIPT_LEDGER_BUSY`, `WENDKEEP_RECEIPT_LEDGER_CONFLICT`,
|
|
146
|
+
`WENDKEEP_RECEIPT_LEDGER_CORRUPT`, and `WENDKEEP_RECEIPT_LEDGER_TRUNCATED` require preserving
|
|
147
|
+
the ledger/checkpoint and executing the objective recovery in `repair.command` (or
|
|
148
|
+
`npx --no-install wendkeep verify --deep --json` for fresh proof); text/JSON output remains
|
|
149
|
+
sanitized and contains no raw stderr, tokens, private URLs, or Vault paths.
|
|
105
150
|
- Surviving mutants: strengthen the discriminating test; after three rounds, review manually.
|
|
106
151
|
|
|
107
152
|
## Next steps
|
|
@@ -58,6 +58,31 @@ idempotent; when the directory vanished between steps, the interrupted reservati
|
|
|
58
58
|
the proven head; divergence or an unavailable network blocks the operation. An already-absent branch
|
|
59
59
|
is idempotent success. `--open-main` opens the main worktree only after completion.
|
|
60
60
|
|
|
61
|
+
### Post-fix cleanup: crash-safe resume
|
|
62
|
+
|
|
63
|
+
Cleanup is **crash-safe** and resumable before the receipt, after the receipt and before
|
|
64
|
+
finalize, and after finalize: a crash at any boundary preserves operation/state and lets the same
|
|
65
|
+
proof be retried without duplicating removal or a receipt. Every operation subject includes all
|
|
66
|
+
active contexts, actor, pr, head, and merge. The canonical PR authority is the PR resolved by the
|
|
67
|
+
GitHub adapter; caller-provided text cannot replace that authority.
|
|
68
|
+
|
|
69
|
+
HEAD is re-derived before finalize from the checkout and compared with the proven head/merge. The
|
|
70
|
+
reason is sanitized and receives a digest for audit, without storing private paths, tokens, or
|
|
71
|
+
stderr. An absent or invalid checkpoint is WENDKEEP_RECEIPT_LEDGER_TRUNCATED. V1 remains
|
|
72
|
+
legacy-unbound and never authorizes cleanup.
|
|
73
|
+
|
|
74
|
+
Text and --json always expose operation, state, blocker, recovery, and the stable codes
|
|
75
|
+
WENDKEEP_WORKTREE_CLEANUP_BUSY, WENDKEEP_RECEIPT_LEDGER_CORRUPT, and
|
|
76
|
+
WENDKEEP_RECEIPT_LEDGER_TRUNCATED; recovery resumes the reservation or names the objective repair.
|
|
77
|
+
|
|
78
|
+
The common cleanup gate classifies the operation and blocks before mutation, including finish,
|
|
79
|
+
remove, and cleanup --apply. After append, the receipt is classified by the same gate before
|
|
80
|
+
finalize; a provenance failure neither finalizes nor reports success. A cleaned state without a v2
|
|
81
|
+
receipt is blocked as unproven; a v1 receipt never authorizes and remains legacy-unbound.
|
|
82
|
+
|
|
83
|
+
Text and --json blockers keep the same sanitized diagnostic: code, operation, state, blocker,
|
|
84
|
+
expected, observed, recovery, reason_codes, diagnostics, and repair.
|
|
85
|
+
|
|
61
86
|
## Cleanup, remove, and prune
|
|
62
87
|
|
|
63
88
|
`cleanup --merged` and `prune` are dry-run by default. `--dry-run` makes that intent explicit; only
|
|
@@ -70,10 +95,20 @@ keeps every preflight and preserves both local and remote branches.
|
|
|
70
95
|
|
|
71
96
|
The registry lives in the Git common-dir at `wendkeep/worktrees-v1.json`, protected by a
|
|
72
97
|
multi-process lock. It stores repository/worktree identity, canonical binding, PR, and transient
|
|
73
|
-
cleanup state; `.wendkeep.json` stays unchanged.
|
|
74
|
-
`wendkeep/worktree-cleanup-receipts-
|
|
75
|
-
|
|
76
|
-
|
|
98
|
+
cleanup state; `.wendkeep.json` stays unchanged. New receipts live at
|
|
99
|
+
`wendkeep/worktree-cleanup-receipts-v2.jsonl`: every line carries `previous_hash` and
|
|
100
|
+
`receipt_hash`, while a separate checkpoint fixes the last validated sequence/hash/byte length.
|
|
101
|
+
V1 remains readable as `legacy-unbound`, with no silent append or rewrite.
|
|
102
|
+
`WENDKEEP_RECEIPT_LEDGER_CORRUPT` reports tampering/partial JSON and
|
|
103
|
+
`WENDKEEP_RECEIPT_LEDGER_TRUNCATED` reports a removed tail. Both block before removal and require
|
|
104
|
+
diagnosing the store, never inventing a receipt. `.worktrees/` is added to the versioned ignore and
|
|
105
|
+
repository-private exclude; JSON `list`/`status` exposes neither Vault paths nor contents.
|
|
106
|
+
Cleanup uses the `verified`, `reported`, `legacy-unbound`, `stale`, `conflict`, and `unproven` states;
|
|
107
|
+
`WENDKEEP_PROVENANCE_GATE_BLOCKED` and `WENDKEEP_RECEIPT_LEDGER_BUSY`,
|
|
108
|
+
`WENDKEEP_RECEIPT_LEDGER_CONFLICT`, `WENDKEEP_RECEIPT_LEDGER_CORRUPT`, and
|
|
109
|
+
`WENDKEEP_RECEIPT_LEDGER_TRUNCATED` fail closed. Objective recovery reads sanitized
|
|
110
|
+
`worktree status <slug> --json`, executes `repair.command` when present, and recaptures proof; never
|
|
111
|
+
edit the ledger/checkpoint or expose stderr, tokens, private URLs, or Vault paths.
|
|
77
112
|
|
|
78
113
|
`create` is idempotent when slug, path, and branch already match. Collisions fail closed. Failures
|
|
79
114
|
after reservation remain `failed`; run `worktree status <slug>` and follow `recovery`. `doctor`
|
|
@@ -30,7 +30,8 @@ npx wendkeep change status [slug] [--session <id>]
|
|
|
30
30
|
npx wendkeep spec effective [--change <slug>] [--session <id>]
|
|
31
31
|
npx wendkeep sensors list
|
|
32
32
|
npx wendkeep verify [--deep] [--change <slug>] [--session <id>]
|
|
33
|
-
npx wendkeep change archive <slug> [--session <id>]
|
|
33
|
+
npx wendkeep change archive <slug> [--json] [--session <id>]
|
|
34
|
+
npx wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
## Opções e códigos de saída
|
|
@@ -47,6 +48,10 @@ npx wendkeep change archive <slug> [--session <id>]
|
|
|
47
48
|
somente um contexto ativo inequívoco da worktree é aceito; ambiguidade retorna exit `2`.
|
|
48
49
|
- `change relink [--apply]` e `change backlink [--apply]` reparam o grafo; dry-run é o padrão.
|
|
49
50
|
- `change abandon <slug>` descarta sem ADR; `archive --force` exige decisão humana explícita.
|
|
51
|
+
- `change archive recover <operation-id> --change <slug> [--spec-action rollback|resume]` inspeciona
|
|
52
|
+
uma transação pendente por padrão; com `rollback` ou `resume`, converge somente a promoção de
|
|
53
|
+
specs preparada no journal, sob lock e validação. Não promove a change, não apaga o journal e não
|
|
54
|
+
inventa reconciliação.
|
|
50
55
|
- `wendkeep spec list|show|effective|migrate|rebase` administra contratos vivos e deltas.
|
|
51
56
|
- `wendkeep sensors list|add` administra provas executáveis.
|
|
52
57
|
- Exit `0` indica comando concluído; os gates usam exit `1` para prova vermelha e exit `2` para
|
|
@@ -83,6 +88,65 @@ checkout provado. Se houver divergência, volte à worktree/sessão correta e ro
|
|
|
83
88
|
`verify --deep` e `wk-verify` novamente. Campos, normalização textual/binária, códigos e recovery
|
|
84
89
|
estão detalhados no [guia de verify](verify.md).
|
|
85
90
|
|
|
91
|
+
O gate comum reclassifica envelope, package e verdict como `verified`, `reported`,
|
|
92
|
+
`legacy-unbound`, `stale`, `conflict` ou `unproven`; somente `verified` permite archive. Um bloqueio
|
|
93
|
+
retorna `WENDKEEP_PROVENANCE_GATE_BLOCKED`: estabilize/recupere o contexto, rode `verify`, depois
|
|
94
|
+
`verify --deep` e obtenha novo passe `wk-verify`. `--force` pode dispensar somente tarefa aberta;
|
|
95
|
+
para proveniência, integridade, package e verdict ele **não** altera o resultado nem promove spec/ADR.
|
|
96
|
+
Os erros de ledger são `WENDKEEP_RECEIPT_LEDGER_BUSY`, `WENDKEEP_RECEIPT_LEDGER_CONFLICT`,
|
|
97
|
+
`WENDKEEP_RECEIPT_LEDGER_CORRUPT` e `WENDKEEP_RECEIPT_LEDGER_TRUNCATED`. No bloqueio, use a saída
|
|
98
|
+
`--json` sanitizada (`state`, `reasonCodes`, `diagnostics`, `repair.command`), execute o recovery
|
|
99
|
+
indicado e rode `npx --no-install wendkeep verify --deep --json`; preserve e recapture a prova, sem
|
|
100
|
+
editar ledger/checkpoint ou expor stderr, token, URL privada ou path do Vault.
|
|
101
|
+
|
|
102
|
+
### Contrato pós-fix do archive
|
|
103
|
+
|
|
104
|
+
Antes da mutação, faça a recaptura final com `wendkeep verify --deep --change <slug>`. O package
|
|
105
|
+
e o verdict devem estar completos e canônicos, com binding do mesmo checkout, change, tarefas,
|
|
106
|
+
spec e sensores. O archive grava primeiro um receipt de autorização no ledger separado
|
|
107
|
+
`change-archive-receipts-v2`; só depois de validá-lo pode promover spec/ADR ou mover a change.
|
|
108
|
+
`change archive --json` expõe o resultado serializável com os campos `state`, `reason_codes`,
|
|
109
|
+
`diagnostics` e `repair`. Corrupção ou truncamento no ledger de prova ou no ledger de archive
|
|
110
|
+
bloqueia fechado antes de qualquer escrita. `--force` não bypassa proveniência nem integridade,
|
|
111
|
+
nem package/verdict, corrupção ou truncamento. O recovery exato é repetir
|
|
112
|
+
`wendkeep verify --deep --change <slug>` no checkout correto.
|
|
113
|
+
|
|
114
|
+
A mutação adquire o lock do runtime `.brain/runtime/change-archive-operation.lock` e abre uma
|
|
115
|
+
transação privada ASCII em `.brain/runtime/archive-transactions/<uuid>/{original,authorized}`.
|
|
116
|
+
Ela renomeia atomicamente a change viva para `original`, confere o digest e promove somente a
|
|
117
|
+
cópia `authorized`; o namespace público nunca é fonte de publicação. Em caso de falha de
|
|
118
|
+
selagem ou divergência `WENDKEEP_ARCHIVE_INPUT_CHANGED` antes da promoção, o snapshot
|
|
119
|
+
`authorized` é removido e `original` é restaurado sem promoção parcial. O archive bem-sucedido
|
|
120
|
+
mantém o journal `completed`; o finalizer pós-release valida os digests de `original` e do destino
|
|
121
|
+
publicado, mas retém `original` e a transação, sem cleanup destrutivo automático.
|
|
122
|
+
|
|
123
|
+
O lock do archive é um `directory lock`: o diretório canônico contém marker específico do token e
|
|
124
|
+
lease. A aquisição prepara um diretório irmão `.pending`, escreve owner/lease e publica por rename
|
|
125
|
+
atômico para o lock; não usa hardlink e reobserva colisões com no máximo 3 tentativas de topologia.
|
|
126
|
+
Owner vivo retorna `WENDKEEP_ARCHIVE_BUSY`; owner morto pode sofrer reap seguro sem apagar sucessor.
|
|
127
|
+
Estrutura/marker inválido retorna `WENDKEEP_ARCHIVE_LOCK_UNAVAILABLE`; perda de ownership retorna
|
|
128
|
+
`WENDKEEP_ARCHIVE_LOCK_OWNERSHIP_LOST`.
|
|
129
|
+
|
|
130
|
+
Cada operação mantém `archive-transaction.json` com as fases `prepared` → `isolated` → `copied` →
|
|
131
|
+
`sealed` → `published` → `promotion-prepared` → `promotion-applied` → `completed` ou
|
|
132
|
+
`recovery-required`. Um journal pending bloqueia novo archive do mesmo slug antes do gate. Em
|
|
133
|
+
colisão ou falha pós-publicação, `original` permanece retido e o estado é
|
|
134
|
+
`published-recovery-required`. Use a inspeção fail-closed e idempotente
|
|
135
|
+
`wendkeep change archive recover <operation-id> --change <slug> [--spec-action rollback|resume] [--json]`;
|
|
136
|
+
sem `--spec-action`, só retorna ações sanitizadas. `rollback` restaura before-images e `resume`
|
|
137
|
+
converge after-images de uma promoção `promotion-prepared`; ambos preservam o journal para nova
|
|
138
|
+
reconciliação.
|
|
139
|
+
|
|
140
|
+
A promoção multi-spec é uma unidade atômica: captura before-images/digests de todos os capabilities,
|
|
141
|
+
faz rollback de todos os alvos (incluindo estado/README) em falha antes ou depois da escrita e só
|
|
142
|
+
permite retry após a reconciliação do journal e nova verificação. O finalizer pós-release valida os
|
|
143
|
+
digests do original e do destino, mas retém o journal `completed` e `original`; sem cleanup
|
|
144
|
+
destrutivo automático. Os campos sanitizados
|
|
145
|
+
`operation_id` e `transaction_phase` acompanham o diagnóstico; `repair.command` aponta para
|
|
146
|
+
`wendkeep change archive recover <operation-id> --change <slug>` quando há operação identificada.
|
|
147
|
+
Texto e --json usam o mesmo diagnóstico sanitizado com code, operation, state, blocker, expected,
|
|
148
|
+
observed, recovery, reason_codes, diagnostics e repair.
|
|
149
|
+
|
|
86
150
|
## Cerca de escopo para ferramentas
|
|
87
151
|
|
|
88
152
|
O `change-guard` também é projetado para o `PreToolUse` do Codex. Antes de uma mutação Git ou de
|