@cassiomc1/forgeloop 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.forgeloop/forgeloop.gitignore +1 -0
  2. package/DOCS_INDEX.md +60 -0
  3. package/EXECUTION_STATE.md +9 -0
  4. package/LOOP_ENGINEERING.md +44 -6
  5. package/LOOP_SYSTEM_DESIGN.md +8 -0
  6. package/PROTOCOL_INTEGRATION.md +41 -0
  7. package/QUALITY_SCORECARD.md +2 -0
  8. package/README.md +183 -643
  9. package/TERMINOLOGY.md +4 -0
  10. package/THREAT_MODEL.md +14 -0
  11. package/docs/assets/forgeloop-flow.svg +1 -0
  12. package/docs/forgeloop-flow.mmd +51 -0
  13. package/package.json +16 -3
  14. package/schemas/check.schema.json +2 -0
  15. package/schemas/continuity.schema.json +57 -0
  16. package/schemas/execution.schema.json +63 -0
  17. package/scripts/CI_VALIDATORS.md +32 -0
  18. package/src/cli.js +351 -196
  19. package/src/commands/clear-continuity.js +9 -0
  20. package/src/commands/continuity.js +25 -0
  21. package/src/commands/doctor.js +17 -2
  22. package/src/commands/reconcile-continuity.js +23 -0
  23. package/src/commands/record-continuity.js +63 -0
  24. package/src/commands/run-check.js +83 -0
  25. package/src/commands/status.js +14 -1
  26. package/src/commands/update.js +12 -13
  27. package/src/commands/validate-protocol.js +37 -0
  28. package/src/core/artifacts.js +9 -0
  29. package/src/core/bundles.js +78 -0
  30. package/src/core/checks.js +16 -0
  31. package/src/core/command-resolution.js +295 -0
  32. package/src/core/command-tokenizer.js +122 -0
  33. package/src/core/completion-artifacts.js +229 -47
  34. package/src/core/completion.js +19 -1
  35. package/src/core/conformance.js +8 -2
  36. package/src/core/continuity-cli-options.js +58 -0
  37. package/src/core/continuity-conformance.js +46 -0
  38. package/src/core/continuity-observability.js +20 -0
  39. package/src/core/continuity-reconciliation.js +224 -0
  40. package/src/core/continuity.js +245 -0
  41. package/src/core/evidence-readiness.js +26 -1
  42. package/src/core/execution.js +185 -0
  43. package/src/core/inspect.js +9 -1
  44. package/src/core/installation-authority.js +178 -0
  45. package/src/core/json-safety.js +17 -13
  46. package/src/core/next-action-artifacts.js +118 -0
  47. package/src/core/next-action-continuity.js +65 -0
  48. package/src/core/next-action-model.js +127 -0
  49. package/src/core/next-action-phases.js +12 -0
  50. package/src/core/next-action.js +22 -249
  51. package/src/core/npm-classifier.js +343 -0
  52. package/src/core/package-manager-classifiers.js +37 -0
  53. package/src/core/preflight-consistency.js +221 -0
  54. package/src/core/preflight-loaders.js +112 -0
  55. package/src/core/preflight-model.js +83 -0
  56. package/src/core/preflight.js +34 -444
  57. package/src/core/protocol.js +7 -0
  58. package/src/core/schema-validation.js +16 -1
  59. package/src/core/templates.js +3 -0
  60. package/src/core/verification-capability.js +31 -495
  61. package/src/core/verification-constants.js +61 -0
@@ -1,2 +1,3 @@
1
1
  # Local resumable task state is untrusted, target-specific data.
2
2
  work-state.json
3
+ executions/
package/DOCS_INDEX.md ADDED
@@ -0,0 +1,60 @@
1
+ # Documentation index
2
+
3
+ ForgeLoop keeps one canonical process and separates protocol behavior from
4
+ integration and guide context. Use this map before editing documentation.
5
+
6
+ ## Ownership map
7
+
8
+ | Need | Canonical source | Boundary |
9
+ | --- | --- | --- |
10
+ | Lifecycle, gates, planning, verification, and recovery | [`LOOP_ENGINEERING.md`](./LOOP_ENGINEERING.md) | Normative process for agents and developer workflows |
11
+ | Capability levels, discovery, and degradation | [`PROTOCOL_INTEGRATION.md`](./PROTOCOL_INTEGRATION.md) | Vendor-neutral harness contract |
12
+ | Durable project facts | [`PROJECT_PROFILE.md`](./PROJECT_PROFILE.md) | Target-specific facts only; no prompts or secrets |
13
+ | Guide selection | [`GUIDE_ROUTER.md`](./GUIDE_ROUTER.md) | Deterministic routing and exclusions |
14
+ | Architecture and safety boundaries | [`LOOP_SYSTEM_DESIGN.md`](./LOOP_SYSTEM_DESIGN.md) and [`THREAT_MODEL.md`](./THREAT_MODEL.md) | Design rationale and residual risk |
15
+ | Artifact and phase schemas | [`schemas/`](./schemas/) and [`CONTRACT_COVERAGE.md`](./CONTRACT_COVERAGE.md) | Versioned machine-readable contract |
16
+ | CLI/package behavior | [`src/`](./src/) and [`tests/`](./tests/) | Executable implementation and regression evidence |
17
+ | Guide content | [`ENG/`](./ENG/) | Context-specific, English-only operational guides |
18
+ | Diagram | [`docs/forgeloop-flow.mmd`](./docs/forgeloop-flow.mmd) | Canonical Mermaid source; SVG is generated output |
19
+
20
+ `README.md` is intentionally a catalog and quickstart. Do not copy the full
21
+ process into adapters or README sections; link to the canonical source.
22
+
23
+ ## Lifecycle reading order
24
+
25
+ 1. Read [`README.md`](./README.md) for scope and quickstart.
26
+ 2. Read [`LOOP_ENGINEERING.md`](./LOOP_ENGINEERING.md) for the process gates.
27
+ 3. Read [`PROTOCOL_INTEGRATION.md`](./PROTOCOL_INTEGRATION.md) for the active
28
+ runtime or harness boundary.
29
+ 4. Inspect [`PROJECT_PROFILE.md`](./PROJECT_PROFILE.md) and confirm facts from
30
+ the repository before using them.
31
+ 5. Use [`GUIDE_ROUTER.md`](./GUIDE_ROUTER.md) to select only relevant guides.
32
+ 6. Use [`LOOP_SYSTEM_DESIGN.md`](./LOOP_SYSTEM_DESIGN.md) and schemas when a
33
+ change affects protocol invariants or artifact shape.
34
+
35
+ ## Verification and release
36
+
37
+ The Node regression suite, ESLint, c8, dependency policy, package boundary,
38
+ and Mermaid render are the local executable checks. Python validators remain
39
+ frozen CI-only compatibility tools because they cover historical Markdown,
40
+ loop, and secret-scanning contracts that have not been migrated to Node. Their
41
+ scope, exact commands, and migration boundary are recorded in
42
+ [`scripts/CI_VALIDATORS.md`](./scripts/CI_VALIDATORS.md).
43
+
44
+ The package has no runtime dependencies. Development dependencies are limited
45
+ to ESLint, c8, and Mermaid CLI and are checked by
46
+ `npm run dependency:policy`. GitHub Actions use `npm ci`, pinned action SHAs,
47
+ CodeQL, dependency review, and generated-release notes; npm publication still
48
+ uses trusted OIDC publishing and is not implied by local verification.
49
+
50
+ ## Editing rules
51
+
52
+ - Keep lifecycle prose, the Mermaid source, and the text-only README fallback
53
+ synchronized.
54
+ - Keep generated `docs/assets/forgeloop-flow.svg` synchronized with the Mermaid
55
+ source by running `npm run docs:flow` and `npm run docs:check`. CI validates
56
+ the source fingerprint instead of comparing renderer-specific SVG geometry.
57
+ - Preserve the distinction between implemented behavior, local evidence, and
58
+ external publication or production state.
59
+ - Run `npm run lint`, `npm run coverage`, `npm run pack:check`, and the Python
60
+ CI-only validators proportionally to the change.
@@ -112,3 +112,12 @@ forgeloop clear-state
112
112
  `clear-state` affects only `.forgeloop/work-state.json` and prints the exact
113
113
  relative path it removed; it never deletes the directory, manifest, or project
114
114
  files.
115
+
116
+ ## Execution continuity companion
117
+
118
+ `.forgeloop/work-state.json` remains the canonical checkpoint and owns phase,
119
+ `completedSteps`, `pendingSteps`, failures, blockers, verification cycles, and
120
+ required artifact fingerprints. `.forgeloop/continuity.json` is an optional
121
+ companion containing only granular implementation-resume context. It is bound
122
+ to the current task, contract fingerprint, work-state fingerprint, phase, and
123
+ repository context and is always operational context rather than evidence.
@@ -52,6 +52,7 @@ the supported ForgeLoop lifecycle commands or canonical ForgeLoop APIs:
52
52
  - `.forgeloop/work-state.json`
53
53
  - `.forgeloop/events.ndjson`
54
54
  - `.forgeloop/execution-receipt.json`
55
+ - `.forgeloop/executions/<executionId>.json`
55
56
  - completion recovery metadata
56
57
  - canonical check/evidence state
57
58
  - terminal-result lifecycle state
@@ -117,11 +118,32 @@ Every verification command path is classified by resolution mode:
117
118
  | `LOCAL_EXECUTABLE` | `node scripts/test.js`, `python3 -m unittest`, `./bin/check` | No | No |
118
119
  | `LOCAL_PACKAGE_BINARY` | `./node_modules/.bin/tool`, `npm test`, `pnpm test`, `yarn test` | No | No |
119
120
  | `NON_INSTALLING_RESOLUTION` | `npx --no-install tool`, `npx --no tool` | No | No |
120
- | `INSTALL_CAPABLE_RESOLUTION` | `npx tool`, `pnpm dlx tool`, `yarn dlx tool`, `bunx tool`, `uvx tool`, `pipx run tool` | Yes | Yes (`E_INSTALLATION_AUTHORITY_REQUIRED`) |
121
+ | `INSTALL_CAPABLE_RESOLUTION` | `npx tool`, `npm exec tool`, `npm x tool`, `pnpm dlx tool`, `yarn dlx tool`, `bunx tool`, `uvx tool`, `pipx run tool` | Yes | Yes (`E_INSTALLATION_AUTHORITY_REQUIRED`) |
121
122
  | `EXPLICIT_INSTALLATION` | `npm install tool`, `pnpm add tool`, `pip install tool`, `cargo install tool` | Yes | Yes (`E_INSTALLATION_AUTHORITY_REQUIRED`) |
122
123
 
123
124
  **Validator-enforced rule**: Any verification command executed via an installation-capable or explicit-installation resolution mode without a valid canonical installation authority grant is rejected by `record-check`, `audit`, and `complete` with error code `E_INSTALLATION_AUTHORITY_REQUIRED`, `E_AUTHORITY_INVALID`, `E_AUTHORITY_SCOPE_MISMATCH`, or `E_AUTHORITY_UNTRUSTED_SOURCE` and cannot contribute to `VALID` completion.
124
125
 
126
+ Recognized command dispatchers (such as `npm test`, `npm start`, `npm stop`, `npm restart`, `npm run <script>`, `npm run-script <script>`, `npm rum <script>`, `npm urn <script>`) are classified by their effective package resolution behavior across recognized lifecycle scripts before process launch. npm invocation parsing recognizes options (e.g. `--silent`, `--loglevel=error`) before the subcommand. Recognized npm-script dispatch is resolved recursively before process launch. `npm restart` uses npm's restart-specific lifecycle semantics (`prerestart`, `prestop`, `stop`, `poststop`, `prestart`, `start`, `poststart`, `postrestart` when `restart` is absent; `prerestart`, `restart`, `postrestart` when `restart` is present) rather than generic pre/main/post handling. ForgeLoop fails closed (`mayInstall: true`) when recursive npm-script resolution encounters a cycle or exceeds its maximum resolution depth (16). ForgeLoop does not resolve npm workspace selection in `run-check` for `0.1.15`. npm script executions using `--workspace`, `-w`, `--workspaces`, or `--ws` fail closed (`E_COMMAND_RESOLUTION_AMBIGUOUS`) because the effective `package.json` execution context may differ from the current ForgeLoop target. Run ForgeLoop against the selected workspace directory directly instead. If any nested lifecycle script invokes an installation-capable command (such as `npx`, `npm exec`, or `pnpm dlx`), the execution is elevated to `INSTALL_CAPABLE_RESOLUTION` and blocked before launch without authority.
127
+
128
+ **npm Classification Model**: npm classification is semantic and fail-closed. Unknown npm commands are not assumed safe. The classifier specifically identifies install-capable families including: `exec`/`x`, `install` aliases, `ci` aliases, `install-test` families, `install-ci-test` families, `update` aliases, `audit fix`, and conditional `init`/`create`/`innit` invocations. Unknown or ambiguous semantics fail closed (`E_COMMAND_RESOLUTION_AMBIGUOUS`).
129
+
130
+ Use `forgeloop run-check --id <id> --requirement <requirement> -- <argv>` for
131
+ observed command evidence. ForgeLoop preserves the exact argv vector, target
132
+ cwd, resolution classification, timestamps, exit status, and task/check
133
+ binding in `.forgeloop/executions/<executionId>.json` before recording the
134
+ check. Resolution is classified before process launch; install-capable
135
+ resolution is rejected without a valid host-attested authority, while
136
+ `npx --no-install` remains a non-installing path and may fail honestly when a
137
+ tool is absent. `run-check` launches the supplied argv without a shell.
138
+
139
+ `forgeloop record-check` is serialization-only. Its `--command` value is
140
+ metadata and is never executed. A `kind: command`, `evidenceKind: OBSERVED`
141
+ check must carry `provenance: FORGELOOP_EXECUTED` and a valid `executionRef`;
142
+ manual or actor-reported observations must use an explicit non-command kind or
143
+ provenance and must not be upgraded to command execution evidence. Completion,
144
+ audit, protocol validation, and bundles revalidate the referenced artifact and
145
+ its task, check, requirement, cycle, cwd, status, and exit-code binding.
146
+
125
147
  Authority cannot be self-issued by the actor consuming it. Boolean fields inside verification evidence (such as `installationAuthorized: true`) are not sufficient proof of installation authority. Installation authority must be established via a canonical authority grant supplied by a host/operator trust boundary and referenced via `installationAuthorityRef`.
126
148
 
127
149
  The runtime authority context has two modes:
@@ -509,7 +531,7 @@ prepare-completion
509
531
 
510
532
  run applicable project checks
511
533
 
512
- record observed results with record-check
534
+ run commands with run-check; record manual observations with record-check
513
535
  ↓ forgeloop next
514
536
  advance --to REVIEWING
515
537
  ↓ forgeloop next
@@ -524,10 +546,11 @@ subsequent `record-check` operations; completion remains invalid until required
524
546
  observed evidence, review state, chronology, and validator requirements are
525
547
  satisfied.
526
548
 
527
- The host agent runs applicable checks after the receipt exists, records their
528
- observed results with `record-check`, and queries `forgeloop next` before each
529
- subsequent lifecycle action. `record-check` records results already observed by
530
- the agent; it never executes the supplied command text.
549
+ The host agent runs applicable checks after the receipt exists, uses `run-check`
550
+ for commands, and uses `record-check` for manual or non-command observations.
551
+ `run-check` records exact command provenance; `record-check` records supplied
552
+ metadata only and never executes its `--command` value. Query `forgeloop next`
553
+ before each subsequent lifecycle action.
531
554
 
532
555
  Continue until the terminal outcome is either validator-backed `COMPLETE` or
533
556
  an explicitly reported `BLOCKED` / `PARTIALLY VERIFIED` result with exact
@@ -1140,3 +1163,18 @@ Publication:
1140
1163
  Never claim that a test, build, platform, device, or integration passed without
1141
1164
  a compatible check. The final response must distinguish local implementation
1142
1165
  from external publication.
1166
+
1167
+ ## Cross-harness execution continuity
1168
+
1169
+ A change of model, provider, IDE, process, terminal, or context window does not
1170
+ create a new task when a valid resumable ForgeLoop task already exists.
1171
+ `work-state.json` remains the sole owner of lifecycle progress. An optional
1172
+ `.forgeloop/continuity.json` may record bounded granular implementation context
1173
+ such as current focus, remaining implementation work, known issues, and paths
1174
+ to inspect first.
1175
+
1176
+ `CONTINUITY_CONTEXT_IS_NOT_EVIDENCE`: continuity may guide inspection but can
1177
+ never satisfy verification coverage, publication, production readiness, or
1178
+ completion. `CONTINUITY_CANNOT_GRANT_AUTHORITY`: continuity cannot authorize an
1179
+ installation or external action. The receiving harness MUST reconcile
1180
+ continuity against the current work state and checkout before acting on it.
@@ -399,3 +399,11 @@ update practice.
399
399
  - Structural, Markdown, link, and secret checks pass locally and in CI.
400
400
  - Portable-copy instructions always include third-party notices.
401
401
  - The package does not alter destination commands, dependencies, or behavior without need and applicable authority.
402
+
403
+ ## Cross-harness continuity boundary
404
+
405
+ Execution continuity is intentionally a companion artifact, not a second state
406
+ machine and not a general memory subsystem. Work state owns lifecycle truth;
407
+ the checkout owns implementation truth; checks/executions own verification
408
+ truth; completion owns certification. Continuity only narrows what a receiving
409
+ executor should inspect and continue.
@@ -128,6 +128,7 @@ The following protocol artifacts are strictly owned by ForgeLoop:
128
128
  - `.forgeloop/work-state.json`
129
129
  - `.forgeloop/events.ndjson`
130
130
  - `.forgeloop/execution-receipt.json`
131
+ - `.forgeloop/executions/<executionId>.json`
131
132
  - Canonical check, evidence, and terminal-result state
132
133
 
133
134
  If the required CLI or API capability cannot be resolved:
@@ -140,6 +141,38 @@ If the required CLI or API capability cannot be resolved:
140
141
 
141
142
  Report the corresponding ForgeLoop dimension as `NOT_VERIFIED` / `E_FORGELOOP_CLI_UNAVAILABLE`.
142
143
 
144
+ ## Trusted command provenance
145
+
146
+ Command verification has two explicit paths:
147
+
148
+ - `forgeloop run-check --id <id> --requirement <requirement> -- <argv>` owns
149
+ execution. It classifies the exact argv before launch, uses a non-shell
150
+ process boundary, records the target cwd, resolution mode, timestamps,
151
+ exit status, and task/check binding in
152
+ `.forgeloop/executions/<executionId>.json`, then records an `OBSERVED` check
153
+ with `provenance: FORGELOOP_EXECUTED`.
154
+ - `forgeloop record-check` owns serialization only. `--command` is metadata and
155
+ is never launched. A `kind: command` check with `evidenceKind: OBSERVED`
156
+ requires both `executionRef` and `FORGELOOP_EXECUTED`; manual or actor-reported
157
+ observations use their explicit non-command/provenance values and remain
158
+ distinguishable from process execution.
159
+
160
+ `run-check` rejects install-capable resolution before process launch unless the
161
+ host supplies a valid trusted authority context. `npm exec` and `npm x` are
162
+ installation-capable resolution paths. Recognized command dispatchers (such as
163
+ `npm test`, `npm restart`, `npm run`, `npm rum`, `npm urn`) are resolved
164
+ recursively across recognized lifecycle scripts before launch with cycle
165
+ detection, leading option normalization, and restart-specific lifecycle fallback.
166
+ npm workspace script executions (`--workspace`, `-w`, `--workspaces`, `--ws`) fail
167
+ closed before launch with `E_COMMAND_RESOLUTION_AMBIGUOUS` because the effective
168
+ `package.json` context cannot be proven from the root target. Unknown npm command semantics are rejected before execution rather than downgraded to local execution. ForgeLoop uses an explicit non-installing allowlist instead of assuming that unrecognized npm commands are safe. `npx --no-install` is
169
+ an allowed non-installing resolution and can return a normal failed result when
170
+ the requested tool is unavailable. Completion, audit, `validate-protocol`, and task
171
+ bundles revalidate execution references rather than trusting duplicated check
172
+ metadata. Invalid or missing references return `E_EXECUTION_REF_INVALID`; an
173
+ observed command without ForgeLoop provenance returns
174
+ `E_COMMAND_PROVENANCE_UNATTESTED`.
175
+
143
176
  ## Missing tool capability
144
177
 
145
178
  A missing tool is a capability gap, not installation authority.
@@ -268,3 +301,11 @@ External planning, interview, or review workflows (such as `/grill-me`, `/plan`,
268
301
  review gates) may assist in clarifying requirements, but they must not silently
269
302
  redefine ForgeLoop `NON_BLOCKING` decisions as `BLOCKING` in autonomous mode.
270
303
  Consult `LOOP_ENGINEERING.md#external-workflow-interaction` for the complete boundary.
304
+
305
+ ## Harness and session continuity
306
+
307
+ Harness identity is not task identity. Session identity is not task identity.
308
+ A compatible environment reopening a resumable task SHOULD inspect the current
309
+ work state, reconcile optional execution continuity, inspect the checkout, and
310
+ continue the existing lifecycle instead of replacing the contract merely
311
+ because the executor changed.
@@ -23,6 +23,8 @@ policy are all present.
23
23
  | Autonomous-mode precedence — structural | Explicit `autonomousMode=true` boundary, explicit interactive opt-in, preservation of `NON_BLOCKING`, and no silent workflow-induced mode switch. |
24
24
  | Pre-contract autonomy — cross-agent live robustness | Independent live-agent behavior across fresh package installs, exact blind prompts, one-process/no-subagent topology, and separate evidence for non-blocking continuation versus blocking clarification. Structural coverage does not imply live cross-agent robustness. |
25
25
  | Resume/checkpoint | Atomic local state, contract/HEAD/artifact freshness, age warning, schema/secret validation, status, safe validation, and bounded clearing without persisting derived freshness fields. |
26
+ | Cross-harness execution continuity — structural | Optional bounded continuity artifact, task/contract/work-state binding, deterministic reconciliation, current-checkout precedence, non-evidence/non-authority semantics, next/status/inspect integration, bundle portability, and cross-process regression coverage. |
27
+ | Cross-harness live continuity | A fresh Harness B resumes an interrupted Harness A task with no manual user summary and reaches validator-backed completion; structural coverage alone does not prove this dimension. |
26
28
  | Protocol activation resumability | `PREFLIGHT_READY` durably creates or reconciles `work-state.json`, preserves blocked history, and exposes a dedicated repair code when the checkpoint is missing. |
27
29
  | Artifact ↔ lifecycle reconciliation | Contract, route, gates, state, preflight, activation events, fingerprints, and append-only hash chronology agree at READY; audit and validate-protocol detect divergence. |
28
30
  | Planned vs present profile truth | `PROJECT_PROFILE.md` distinguishes planned template fields from observed target facts, with hidden-kit bootstrap and legacy migration checks. |