@mindexed/cfact 1.1.8 β†’ 1.1.12

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 (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +99 -78
  3. package/bin/cfact.js +354 -35
  4. package/package.json +68 -5
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 JosΓ© Brenes
3
+ Copyright (c) 2026 Jose Brenes
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,111 +1,132 @@
1
1
  # CFacT 🏭
2
2
 
3
- An agentic software development framework that translates human ideas into highly structured, matrix-aligned codebases using a multi-agent SDLC pipeline.
4
-
5
- CFacT automates software engineering by partitioning the codebase into strict layers, assigning specialized AI subagents (with scoped permissions and tools) to each layer, and checking compliance via automated quality gates.
3
+ **CFacT is a Human–Agent–App architecture engine** β€” a multi-agent framework that turns a
4
+ plain-language product idea into a structured, matrix-aligned codebase, and keeps it that
5
+ way as the codebase grows. It partitions a project into strict architectural layers, assigns
6
+ specialized AI subagents (each scoped to its own directories and tools) to each layer, and
7
+ checks every change against automated quality gates β€” so "a subagent wrote it" and "it
8
+ follows the architecture" are the same statement, not two separate hopes.
9
+
10
+ **The engine runs entirely on its own, offline, with nothing to sign up for.** The
11
+ Orthogonal Architecture Matrix, the quality gates, the subagents, and every command in this
12
+ repo work directly against your own codebase with no account and no network call. A
13
+ separately operated hosted layer β€” a "studio" channel and its MCP bridge β€” adds a pinned
14
+ install path, a shared feedback queue, and a hosted release console on top; it is optional,
15
+ and nothing in the core framework requires it. See [Installing](#installing) and
16
+ [Optional: the hosted studio layer](#optional-the-hosted-studio-layer) below.
6
17
 
7
18
  ---
8
19
 
9
- ## πŸ“ The 5-Layer Orthogonal Architecture Matrix
20
+ ## How it works
10
21
 
11
- All code developed within this framework must strictly align with one of five architectural layers:
22
+ Every file in a project built with CFacT belongs to exactly one cell of a layer Γ— domain
23
+ matrix. The baseline is five layers (a sixth, Agent System, is opt-in):
12
24
 
13
25
  | Layer | Directory | Zone Focus | Key Constraints (Non-Negotiables) |
14
26
  | :--- | :--- | :--- | :--- |
15
- | **1: Presentation** | `app/`, `components/` | UI/UX, forms, API actions | Max 300 lines for components, Max 100 lines for actions/controllers. |
16
- | **2: Application** | `src/application/` | Use cases, DTOs, orchestration | Pure orchestration. Zero direct DB or infrastructure imports. |
17
- | **3: Domain** | `src/domain/` | Domain logic, DDD, entities | **Purity Blocker:** Absolutely zero I/O, DB, HTTP, logging, or external imports. |
18
- | **4: Infrastructure** | `src/infrastructure/` | Repositories, SDK adapters, APIs | Implements Application ports. Zero hardcoded secrets (validated via Zod). |
19
- | **5: Database** | `supabase/` | Schemas, migrations, RLS | 100% Row-Level Security (RLS) coverage on public tables. |
27
+ | **1: Presentation** | `app/`, `components/` | UI/UX, forms, API actions | Max 300 lines for components, max 100 for controllers. |
28
+ | **2: Application** | `src/application/` | Use cases, DTOs, orchestration | Pure orchestration β€” zero direct DB or infrastructure imports. |
29
+ | **3: Domain** | `src/domain/` | Domain logic, DDD, entities | **Purity blocker:** zero I/O, DB, HTTP, logging, or external imports. |
30
+ | **4: Infrastructure** | `src/infrastructure/` | Repositories, SDK adapters, APIs | Implements Application ports; zero hardcoded secrets (Zod-validated). |
31
+ | **5: Database** | `supabase/` | Schemas, migrations, RLS | 100% Row-Level Security coverage on public tables. |
32
+
33
+ Five specialized subagents build against this matrix in Dependency-Rule order β€” one per
34
+ layer, each restricted to its own directories and tools (Architect, Domain Engineer,
35
+ Integration Developer, Frontend Developer, and an opt-in Agent-System owner) β€” and two
36
+ audit-only subagents (Security/QA, Data-Engineering/QA) check their work before anything
37
+ ships. `FRAMEWORK.md` and `rules/` describe the full roster, every zone, and the two more
38
+ subagents (asynchronous maintainers) that sweep a whole repo for drift without ever blocking
39
+ it.
40
+
41
+ A set of scripted audits enforce the matrix boundaries, both at write time and in CI:
42
+
43
+ - `/audit-matrix domain` β€” `src/domain/` has no external dependencies or I/O.
44
+ - `/audit-matrix components` β€” no UI component exceeds the 300-line SRP limit.
45
+ - `/audit-matrix controllers` β€” no API route/action exceeds the 100-line controller limit.
46
+ - `/audit-matrix rls` β€” every Supabase table has Row-Level Security coverage.
47
+ - `/audit-matrix secrets` β€” no hardcoded secret anywhere in the tree.
48
+
49
+ These are the same checks the framework runs against its own code before every change β€” see
50
+ [`CONTRIBUTING.md`](CONTRIBUTING.md) for the full self-consistency gate chain. The engine is
51
+ built the way it asks a consuming project to build.
20
52
 
21
53
  ---
22
54
 
23
- ## πŸ€– The Software Factory Departments
55
+ ## What's in this repo
56
+
57
+ This repo **is** the framework engine β€” the pieces a consuming project resolves through a
58
+ `.claude/engine/` symlink live at the root here, not nested inside `.claude/`.
24
59
 
25
- Development is orchestrated across five specialized agent roles, each with strict directory and tool boundaries:
60
+ ```
61
+ β”œβ”€β”€ matrix.json the layer/domain/zone schema every check is derived from
62
+ β”œβ”€β”€ agents/ the subagent definitions, one per architectural role
63
+ β”œβ”€β”€ commands/ slash-command workflows (/build-feature, /audit-matrix, ...)
64
+ β”œβ”€β”€ rules/ path-scoped constraints for each layer and domain
65
+ β”œβ”€β”€ hooks/ the quality-gate scripts that enforce rules/ at write time
66
+ β”œβ”€β”€ scripts/ full-codebase audits and the derived-projection generators
67
+ β”œβ”€β”€ skills/ reusable agent tools (AST parsing, RLS auditing, ...)
68
+ β”œβ”€β”€ bin/ the npx installer front door
69
+ └── docs/cfact/ design docs and Architecture Decision Records
70
+ ```
26
71
 
27
- * **Architect:** Owns Phase 1 (Planning & Tech Spec). Translates PRD requirements into Layer 2 Application Port interfaces.
28
- * **Domain Engineer:** Owns Phase 2a (Domain Layer). Writes pure, side-effect-free business logic. *Explicitly blocked from database or network access.*
29
- * **Integration Developer:** Owns Phase 2b (Infrastructure/Database). Builds repositories, adapters, and Supabase migrations.
30
- * **Frontend Developer:** Owns Phase 3 (User Experience). Builds React Server Components (RSC) and coordinates client hooks.
31
- * **Security/QA:** Owns Phase 4 (Verification & Release). Audits environment schemas, verifies RLS, and executes tests.
72
+ For what each piece does in depth, how a consuming project resolves this repo, and how the
73
+ pieces fit together, see [`FRAMEWORK.md`](FRAMEWORK.md) β€” that file is the maintainer-depth
74
+ reference; this one is the front door.
32
75
 
33
76
  ---
34
77
 
35
- ## πŸ“‚ Project Structure
78
+ ## Installing
79
+
80
+ Today, materializing a pinned copy of the engine (`npx @mindexed/cfact init`) needs an
81
+ access token β€” there is no public, tokenless install channel yet. If you already have one,
82
+ `FRAMEWORK.md`'s "Authenticating the studio channel" section has the exact steps.
36
83
 
37
- This repo **is** the framework β€” the pieces a consuming project resolves through its git-ignored `.claude/engine/` symlink live at the root here, not nested inside `.claude/`. Consumers track nothing framework-shaped: the pointer-symlinks are generated locally by `maintainer-hooks/setup-local.sh` (ADR-0047). New device? `bash maintainer-hooks/bootstrap-system.sh` installs the system (framework + the agentic-os dashboard) as siblings under one workspace root. See [`FRAMEWORK.md`](FRAMEWORK.md) for the full contract.
84
+ A tokenless, public quick start is planned but not shipped yet: it waits on a short list of
85
+ still-open changes, one of which is a one-time rewrite of this repository's own git history
86
+ to remove names that predate its public release β€” a change its owner is deliberately holding
87
+ as a separate, explicit decision rather than folding it into this one. Until that lands, the
88
+ accurate way to get started as a contributor, or as a maintainer-track adopter who already
89
+ holds a token, is to clone this repo directly and read `FRAMEWORK.md`.
38
90
 
39
91
  ```bash
40
- β”œβ”€β”€ FRAMEWORK.md # What this repo is, and how consuming projects install it
41
- β”œβ”€β”€ CONTRIBUTING.md # Branch-per-change flow, the fourteen self-consistency gates
42
- β”œβ”€β”€ matrix.json # The 6-layer / 36-zone Orthogonal Architecture Matrix schema
43
- β”œβ”€β”€ agents/ # The five phase-owning subagent definitions
44
- β”œβ”€β”€ commands/ # Custom orchestrator prompts (/build-feature, /audit-matrix)
45
- β”œβ”€β”€ rules/ # Path-scoped constraints for Layers 1-5
46
- β”œβ”€β”€ hooks/ # Quality-gate scripts + PreToolUse/PostToolUse enforcement
47
- β”œβ”€β”€ scripts/ # Full-codebase audits (validate-zone.js, sync-env.js)
48
- β”œβ”€β”€ skills/ # Reusable agent tools (verify-domain, audit-rls AST parser)
49
- β”œβ”€β”€ registry/ # Node declarations for everything that is NOT a markdown file here
50
- β”œβ”€β”€ maintainer-hooks/ # This repo's own git hooks for syncing consumers
51
- β”œβ”€β”€ consumers.example.json # Template of the git-ignored consumers.json: registry (name + repo) of projects that resolve this engine
52
- β”œβ”€β”€ cfact-docs/ # This repo's own generated project docs (ACTIVE_PRD.md,
53
- β”‚ # TECH_SPEC.md, PROJECT_STATUS.json, sot-templates/) β€” same
54
- β”‚ # spot any consumer's own generated docs live, see FRAMEWORK.md
55
- β”œβ”€β”€ .mcp.json # Model Context Protocol (MCP) server definitions
56
- β”œβ”€β”€ .claude/
57
- β”‚ β”œβ”€β”€ CLAUDE.md # Router containing Global Hard Rules & path-scoped rule routes
58
- β”‚ β”œβ”€β”€ settings.json # Minimal (enabledMcpjsonServers). No hooks: this repo has no app code
59
- β”‚ β”‚ for the write-time gates to act on β€” see ADR-0226
60
- β”‚ β”œβ”€β”€ state/ # Symlink -> ../cfact-docs (compat path every
61
- β”‚ β”‚ # command/hook still reads/writes)
62
- β”‚ β”œβ”€β”€ rules/, agents/, commands/ # Symlinks back to the root folders above, so Claude Code's
63
- β”‚ β”‚ # `.claude/...`-only autodiscovery picks them up
64
- β”‚ └── skills/ # Per-skill symlinks back to the root skills/ folder
65
- └── docs/
66
- └── claude-factory/ # In-depth design and framework documentation
92
+ git clone <this-repo-url>
93
+ bash maintainer-hooks/setup-local.sh <path-to-your-project>
67
94
  ```
68
95
 
69
96
  ---
70
97
 
71
- ## ⚑ Verification & Quality Gates
98
+ ## Optional: the hosted studio layer
72
99
 
73
- The workspace includes custom verification commands to enforce architectural integrity locally and during CI/CD:
100
+ A separately operated hosted service adds, on top of the free, offline engine:
74
101
 
75
- * `/audit-matrix domain` β€” Checks that `src/domain/` has no external dependencies or I/O.
76
- * `/audit-matrix components` β€” Identifies UI components exceeding the 300-line SRP limit.
77
- * `/audit-matrix controllers` β€” Audits API routes/actions exceeding the 100-line controller limit.
78
- * `/audit-matrix rls` β€” Scans the Supabase schema to ensure 100% RLS policy coverage.
102
+ - a pinned, checksum-verified **vendored install** channel (`npx @mindexed/cfact
103
+ init`/`update`), for a team that wants every member on the exact same engine version
104
+ without anyone holding a clone of this repo;
105
+ - a hosted **release console** and a shared **framework-feedback queue**, so a team's
106
+ friction reports and proposed framework changes land in one place instead of staying
107
+ local to each developer;
108
+ - a remote **MCP bridge** exposing the subset of tools backed by shared, hosted state (as
109
+ opposed to a project's own local files, which only a local MCP server can read).
79
110
 
80
- ---
111
+ None of this is required to use CFacT. The matrix, the gates, every agent and slash command
112
+ in this repo, and a local clone-based install all work with no account, no token, and no
113
+ network access. `FRAMEWORK.md` has the full resolution-mode story β€” symlinked clone,
114
+ CI-cloned, and pinned/vendored β€” and what each one does and doesn't need from the hosted
115
+ layer.
81
116
 
82
- ## πŸ–₯️ CFacT Agentic OS
83
-
84
- The framework features an interactive **Agentic OS** UI control center that runs entirely on your Portable SSD and dynamically adapts to any open development workspace.
85
-
86
- ### Key Visual Features:
87
- * **30-Zone Grid Visualizer:** A 6x5 matrix displaying the real-time compliance status (file size, boundary violations) of each zone.
88
- * **Multi-Project Selector:** Sidebar dropdown dynamically listing all `.claude` projects on the SSD for quick visual switching.
89
- * **Phase & Gate Control Panel:** Visually monitor SDLC stages and toggle Phase/HITL locks.
90
- * **Config Editor:** Interactive form to edit and sync `variables.local.json` environment settings.
91
-
92
- ### How to Run:
93
- Start the local Next.js Visual OS from the framework root:
94
- ```bash
95
- npm run start-os
96
- ```
97
- Open **`http://localhost:3099`** in your browser to access the control panel.
117
+ An optional local, free visual dashboard (Agentic OS) is a separate piece of the same
118
+ toolkit β€” see `FRAMEWORK.md`'s "Installing the system on a new device" section for how to
119
+ clone and run it; it is not part of this repo.
98
120
 
99
121
  ---
100
122
 
101
- ## 🀝 Contributing
123
+ ## Contributing
102
124
 
103
- CFacT is consumed from a local clone (a git-ignored `.claude/engine`
104
- symlink), so a change here reaches every **symlinked** consumer the moment the
105
- clone is pulled β€” a **vendored** consumer follows when a maintainer blesses the
106
- team pin (`rules/engine-promotion.md`). Read [`CONTRIBUTING.md`](CONTRIBUTING.md)
107
- before opening a PR β€” it covers the resolution modes, the `fw/<short-desc>`
108
- branch-per-change flow, and the fourteen self-consistency gates that keep
109
- `matrix.json` and its prose docs from drifting.
110
- Licensed under [MIT](LICENSE), copyright JosΓ© Brenes.
125
+ CFacT is consumed from a local clone (a git-ignored `.claude/engine` symlink), so a change
126
+ here reaches every symlinked consumer the moment the clone is pulled β€” a vendored consumer
127
+ follows once a maintainer blesses the team pin. Read [`CONTRIBUTING.md`](CONTRIBUTING.md)
128
+ before opening a PR β€” it covers the resolution modes, the `fw/<short-desc>` branch-per-change
129
+ flow, and the self-consistency gates that keep `matrix.json` and its prose docs from
130
+ drifting.
111
131
 
132
+ Licensed under [MIT](LICENSE), copyright Jose Brenes.
package/bin/cfact.js CHANGED
@@ -54,6 +54,18 @@
54
54
  * engine tarball becomes the code every gate runs β€” so an UNKNOWN checksum is a
55
55
  * loud warning, and --require-checksum turns it into a refusal.
56
56
  *
57
+ * WHICH VERSION, WHEN NONE IS NAMED (CHG-319/ADR-0453, narrowing ADR-0128)
58
+ * -------------------------------------------------------------------------
59
+ * `opts.version || pin.version` used to be the whole story, with a hard refusal
60
+ * when both were absent. It is now a three-step fallback: `--version` first,
61
+ * then an EXISTING pin's version (ADR-0128's rule β€” a bare `update` NEVER
62
+ * auto-upgrades a pinned consumer, unchanged), and only when NEITHER names one
63
+ * does the installer fetch `cfact-engine-latest.json` from the resolved channel
64
+ * (the SAME base a versioned tarball would use) and install whatever release it
65
+ * names β€” "newest" meaning PUBLICATION TIME, decided server-side by whichever
66
+ * channel wrote that file last, never a client-side version-string compare.
67
+ * See needsLatestResolution()/resolveLatestManifestSource()/fetchLatestManifest().
68
+ *
57
69
  * Unlike ensure-engine.js (build-time, fails OPEN so a deploy degrades rather
58
70
  * than breaks), this is an explicit install step and fails CLOSED: a teammate
59
71
  * running `init` wants the engine present, so a fetch/verify failure is an error.
@@ -87,13 +99,22 @@ const DEFAULT_REPO = 'Mindexed/cfact';
87
99
  const LEGACY_DEFAULT_REPOS = ['Mindexed/claude-factory'];
88
100
  const isDefaultRepo = (r) => r === DEFAULT_REPO || LEGACY_DEFAULT_REPOS.includes(r);
89
101
 
90
- // THE CANONICAL ENGINE CHANNEL BASE β€” DATA, NOT PROSE (ADR-0168, FF-240).
102
+ // THE CANONICAL STUDIO ORIGIN β€” DATA, NOT PROSE (ADR-0168, FF-240; widened from
103
+ // "this installer's own channel" to "the one shared export" by ADR-0439).
91
104
  //
92
105
  // This host was stated in three places and only two of them agreed. Both correct
93
106
  // statements were PROSE IN A CODE COMMENT (resolveSource below, and
94
107
  // publish-release.js's INGEST_URL); the third was agentic-os's Get Started page,
95
108
  // which re-derived it independently, hardcoded the APEX, and is the one a human
96
109
  // copy-pastes. So the two statements that were right were the two nobody read.
110
+ // ADR-0168 fixed and exported this installer's OWN copy as DEFAULT_CHANNEL_URL,
111
+ // but named the other two files' copies (this file's own prose above, and
112
+ // setup-local.sh's AGENTIC_OS_MCP_STUDIO_URL) as correct and explicitly left
113
+ // them unmerged, "since unifying them would need a shared module that does not
114
+ // exist". ADR-0439 is that module: npm ships only bin/, so this file is the one
115
+ // place a vendored install actually receives, and therefore the only place a
116
+ // single export can mean anything to a maintainer-only script like
117
+ // publish-release.js or setup-local.sh.
97
118
  //
98
119
  // NAME THE HOST THAT ANSWERS DIRECTLY β€” NOT ONE THAT REDIRECTS TO IT. A redirect
99
120
  // between the apex and `www.` (or any host change) is CROSS-ORIGIN, and per the
@@ -103,15 +124,21 @@ const isDefaultRepo = (r) => r === DEFAULT_REPO || LEGACY_DEFAULT_REPOS.includes
103
124
  // directly. `crossOriginRedirectTarget` turns that into a self-diagnosing error
104
125
  // rather than an opaque 401.
105
126
  //
106
- // It lives HERE, above HELP, because HELP interpolates it β€” defining it beside
107
- // the resolution logic further down is a temporal-dead-zone ReferenceError at
108
- // module load, which breaks every invocation including `--help`.
127
+ // It lives HERE, above HELP, because HELP interpolates DEFAULT_CHANNEL_URL below
128
+ // β€” defining either beside the resolution logic further down is a temporal-
129
+ // dead-zone ReferenceError at module load, which breaks every invocation
130
+ // including `--help`.
109
131
  //
110
132
  // EXPORTED (see module.exports) so another Node consumer can READ it instead of
111
- // restating it. Note the better fix for the studio is not to import this at all
112
- // but to stop emitting `--channel`: this constant makes the flag optional, and a
113
- // fact nobody restates cannot drift (node-contract Policy 2).
114
- const DEFAULT_CHANNEL_URL = 'https://www.agenticos.studio/api/engine';
133
+ // restating it β€” in this repo, publish-release.js's INGEST_URL and
134
+ // setup-local.sh's inline `node -e` MCP-transport resolution both now
135
+ // `require('../bin/cfact.js')` for STUDIO_ORIGIN rather than carrying their own
136
+ // literal (ADR-0439). Note the better fix for the studio's own Get Started page
137
+ // is not to import this at all but to stop emitting `--channel`: this constant
138
+ // makes the flag optional, and a fact nobody restates cannot drift (node-contract
139
+ // Policy 2).
140
+ const STUDIO_ORIGIN = 'https://www.agenticos.studio';
141
+ const DEFAULT_CHANNEL_URL = `${STUDIO_ORIGIN}/api/engine`;
115
142
  // The one label that opts OUT of the default and back to the GitHub-Releases
116
143
  // fallback. Deliberately read from THIS RUN's flags only β€” never from pin.channel,
117
144
  // which is a DERIVED provenance label (see DERIVED_CHANNEL_LABELS): treating it as
@@ -249,20 +276,27 @@ function parseArgs(argv) {
249
276
  const HELP = `cfact β€” install/update a pinned, vendored CFacT engine
250
277
 
251
278
  Usage:
252
- npx @mindexed/cfact init [consumer-path] --version <v> [options]
279
+ npx @mindexed/cfact init [consumer-path] [--version <v>] [options]
253
280
  npx @mindexed/cfact update [consumer-path] [--version <v>] [options]
254
281
 
255
- Also resolvable as @mindexed/claude-factory (the deprecated legacy name) --
256
- frozen at its last published version as of ADR-0287 and never updated again;
257
- install @mindexed/cfact for anything published from here on.
282
+ (The legacy name @mindexed/claude-factory is deleted, ADR-0486 -- install
283
+ @mindexed/cfact instead; it is no longer resolvable at all.)
258
284
 
259
285
  Materialises .claude/engine as REAL FILES at a pinned version (never a clone or
260
286
  symlink of the private repo), then wires the consumer (pointer-symlinks, the
261
287
  agentic-os MCP entry, the docs folder) via the engine's own setup-local.sh.
262
288
 
263
289
  Version & channel:
264
- --version <v> engine version to pin to (e.g. 3.6). Required for init
265
- unless .claude/engine.pin.json already records one.
290
+ --version <v> engine version to pin to (e.g. 3.6). OPTIONAL β€” when
291
+ omitted and no .claude/engine.pin.json already records
292
+ one, the installer resolves the latest published
293
+ release from the configured channel instead
294
+ (CHG-319/ADR-0453; the studio channel only for now β€”
295
+ GitHub Releases has no "latest" lookup yet). A bare
296
+ \`update\` against an ALREADY-PINNED consumer is
297
+ unaffected and keeps re-requesting the pinned version
298
+ (ADR-0128) β€” "latest" only ever applies when nothing,
299
+ anywhere, names a version.
266
300
  --channel <url|label> engine channel: an https:// BASE (the recommended
267
301
  agenticos.studio endpoint) makes the installer fetch
268
302
  <base>/cfact-engine-<version>.tar.gz; works on
@@ -516,6 +550,16 @@ const ASSET = (version) => `cfact-engine-${version}.tar.gz`;
516
550
  // those releases will ever carry. Used solely as the github-releases 404
517
551
  // fallback below β€” never requested first, and never on the studio channel.
518
552
  const LEGACY_ASSET = (version) => `claude-factory-engine-${version}.tar.gz`;
553
+ // The "latest release" pointer (CHG-319/ADR-0453). ONE well-known name, served
554
+ // under the channel base alongside the versioned tarballs β€” never version-
555
+ // suffixed, since its whole job is to be fetched when no version is known yet.
556
+ // Carries the SAME ADR-0093 metadata shape a versioned release-metadata.json
557
+ // does (version/checksum/channel/…), just for "whichever release is newest" β€”
558
+ // see maintainer-hooks/publish-release.js, which writes/updates it on every
559
+ // publish, and resolveLatestManifestSource()/fetchLatestManifest() below, which
560
+ // consume it. The app-side studio route that SERVES this asset is a separate,
561
+ // already-named app-half (not built here, per CHG-319's own scope).
562
+ const LATEST_MANIFEST_ASSET = 'cfact-engine-latest.json';
519
563
  // The env namespace accepts CFACT_* and CLAUDE_FACTORY_*, the new name winning
520
564
  // WITHIN a source tier (ADR-0189). These are ORDERED EXACT NAMES and must never
521
565
  // become a pattern, prefix, or regex: the two names share the suffix
@@ -625,10 +669,14 @@ function channelBase(opts, pin) {
625
669
  // `requestedVersion` falsy is the whole trigger: when it holds, `targetVersion`
626
670
  // upstream resolves to `opts.version || pin.version` picking `pin.version`, so
627
671
  // `installedVersion` equals `priorVersion` by construction β€” this function does
628
- // not re-derive that equality, it names the case that produces it. A bare
629
- // `update` with no requested version AND no prior pin dies earlier (in
630
- // resolveSource, "no engine version to install"), so that combination never
631
- // reaches here.
672
+ // not re-derive that equality, it names the case that produces it. That can
673
+ // only happen when a prior pin DOES name a version (requestedVersion is falsy
674
+ // only because nothing overrode it) β€” a bare `update` with no requested
675
+ // version AND no prior pin no longer dies before reaching here (CHG-319/
676
+ // ADR-0453): materialise() resolves "latest" first and REWRITES opts.version
677
+ // to the resolved release id before this function is ever called, so by the
678
+ // time it runs, a latest-resolved install always has a truthy
679
+ // `requestedVersion` and is correctly NOT treated as the no-op case below.
632
680
  function describeUpdateOutcome(command, requestedVersion, priorVersion, installedVersion) {
633
681
  if (command === 'update' && !requestedVersion) {
634
682
  return {
@@ -656,6 +704,12 @@ function resolveSource(opts, pin) {
656
704
  const url = opts.url || resolveEnvName(ENGINE_URL_NAMES).value;
657
705
  if (url) return { kind: 'url', via: 'explicit-url', ref: url };
658
706
 
707
+ // Reached only by a DIRECT caller of resolveSource() with no version (every
708
+ // fixture in this repo always passes one). materialise() itself never hits
709
+ // this any more for the plain "nothing named a version" case β€” as of
710
+ // CHG-319/ADR-0453 it resolves "latest" first and calls this with
711
+ // opts.version already filled in β€” so this stays as the pure function's own
712
+ // safety net rather than the CLI's actual refusal path.
659
713
  const version = opts.version || pin.version;
660
714
  if (!version) {
661
715
  die(
@@ -759,6 +813,51 @@ function resolveSource(opts, pin) {
759
813
  };
760
814
  }
761
815
 
816
+ // Is there already an explicit, VERSION-INDEPENDENT source for this run β€” a
817
+ // local tarball (--from) or an exact URL override (--url / $CFACT_ENGINE_URL)?
818
+ // Mirrors resolveSource()'s own first two branches EXACTLY (CHG-319/ADR-0453):
819
+ // those return before ever looking at a version, so a run that supplies one of
820
+ // them must never be routed into a "resolve latest" lookup it does not need β€”
821
+ // materialise() calls this BEFORE deciding whether to fetch the latest-release
822
+ // manifest, precisely so that decision can never drift from resolveSource's own.
823
+ function hasExplicitSource(opts) {
824
+ if (opts.from) return true;
825
+ return Boolean(opts.url || resolveEnvName(ENGINE_URL_NAMES).value);
826
+ }
827
+
828
+ // Does THIS run need a "latest" lookup (CHG-319/ADR-0453)? Pure and exported
829
+ // so the one invariant that matters most here β€” a bare `update` on an
830
+ // ALREADY-PINNED consumer is COMPLETELY UNCHANGED by this feature β€” is
831
+ // testable directly, rather than re-derived from a regex over materialise()'s
832
+ // source. True only when NEITHER an explicit version-independent source
833
+ // (hasExplicitSource) NOR --version NOR an existing pin names a version β€”
834
+ // i.e. exactly the condition that used to be resolveSource's unconditional
835
+ // "no engine version to install" refusal.
836
+ function needsLatestResolution(opts, pin) {
837
+ return !hasExplicitSource(opts) && !opts.version && !pin.version;
838
+ }
839
+
840
+ // Where to fetch the "latest release" manifest from, reusing the IDENTICAL
841
+ // channel-resolution resolveSource() uses for a specific version
842
+ // (channelBase(), which is itself configuredChannelBase() + optsOutOfDefaultChannel())
843
+ // rather than a second copy of that precedence (CHG-319/ADR-0453). Returns
844
+ // null when this run opted OUT of the channel-base channel (an explicit
845
+ // `--channel github-releases` or `--repo`) β€” that fallback is name/tag-keyed
846
+ // per version and has no "latest" concept yet (CHG-322 is the later, separate
847
+ // change that would add one), so the caller falls back to naming a version
848
+ // explicitly rather than this installer guessing at an endpoint it does not
849
+ // build.
850
+ function resolveLatestManifestSource(opts, pin) {
851
+ const base = channelBase(opts, pin);
852
+ if (!base) return null;
853
+ return {
854
+ kind: 'url',
855
+ via: 'studio',
856
+ ref: `${base.replace(/\/+$/, '')}/${LATEST_MANIFEST_ASSET}`,
857
+ bearerEnv: ENGINE_TOKEN_NAMES,
858
+ };
859
+ }
860
+
762
861
  // Did this failed response come back through a CROSS-ORIGIN redirect while we
763
862
  // were sending a bearer? If so the bearer was stripped in flight and the status
764
863
  // says nothing about the token's validity (ADR-0168).
@@ -1160,6 +1259,50 @@ async function fetchToFile(source, destFile) {
1160
1259
  fs.writeFileSync(destFile, buf);
1161
1260
  }
1162
1261
 
1262
+ // Fetches and parses the "latest release" manifest (CHG-319/ADR-0453). Shares
1263
+ // the studio channel's optional bearer (resolveBearer/normalizeBearer, the
1264
+ // same precedence fetchToFile already uses) but deliberately does NOT
1265
+ // replicate fetchToFile's cross-origin-redirect / stripped-bearer self-
1266
+ // diagnosis or its 404-retry-on-legacy-name dance: those exist for the large,
1267
+ // slow tarball transfer, where a wrong diagnosis costs a real debugging cycle.
1268
+ // This is a few hundred bytes of JSON β€” on failure it reports the plain status
1269
+ // and points at --version, rather than duplicating that machinery a second
1270
+ // time for a different asset.
1271
+ async function fetchLatestManifest(source, consumerRoot) {
1272
+ if (typeof fetch !== 'function') {
1273
+ die('global fetch is unavailable β€” Node 18+ is required to resolve the latest engine release.');
1274
+ }
1275
+ const headers = { 'User-Agent': 'claude-factory-installer', Accept: 'application/json' };
1276
+ const bearer = resolveBearer(source.bearerEnv, consumerRoot);
1277
+ if (bearer.value) {
1278
+ const { value } = normalizeBearer(bearer.value);
1279
+ headers.Authorization = `Bearer ${value}`;
1280
+ }
1281
+ info(` resolving the latest engine release from ${source.ref}`);
1282
+ let res;
1283
+ try {
1284
+ res = await fetch(source.ref, { headers, redirect: 'follow' });
1285
+ } catch (e) {
1286
+ die(`could not resolve the latest engine release β€” ${e.message}`);
1287
+ }
1288
+ if (!res.ok) {
1289
+ die(
1290
+ `could not resolve the latest engine release β€” HTTP ${res.status} ${res.statusText} for ${source.ref}\n` +
1291
+ ' Pass --version <v> to install a specific release instead.'
1292
+ );
1293
+ }
1294
+ let manifest;
1295
+ try {
1296
+ manifest = await res.json();
1297
+ } catch (e) {
1298
+ die(`the latest-release manifest at ${source.ref} is not valid JSON β€” ${e.message}`);
1299
+ }
1300
+ if (!manifest || typeof manifest.version !== 'string' || !manifest.version) {
1301
+ die(`the latest-release manifest at ${source.ref} has no "version" field β€” cannot resolve a release to install.`);
1302
+ }
1303
+ return manifest;
1304
+ }
1305
+
1163
1306
  function sha256(file) {
1164
1307
  // Use node's crypto without pulling a dependency.
1165
1308
  const crypto = require('crypto');
@@ -1291,6 +1434,105 @@ function isLockError(e) {
1291
1434
  return Boolean(e) && LOCK_ERROR_CODES.has(e.code);
1292
1435
  }
1293
1436
 
1437
+ // --- short bounded retry around the engine-folder-to-backup rename (CHG-344, FF-392) --------------------------
1438
+ // A transient lock on `.claude/engine` often clears within a few seconds β€” antivirus finishing a scan of a
1439
+ // just-written file, a file-watcher releasing a brief hold β€” so failing the whole update on the FIRST EPERM/EBUSY/
1440
+ // EACCES wastes a run that would have succeeded a moment later. This retries ONLY the one rename the CHG scoped
1441
+ // (moving the current engine aside); every other lock-error site in installStagedEngine below is unchanged and
1442
+ // still fails immediately, exactly as before.
1443
+ const LOCK_RETRY_ATTEMPTS = 5;
1444
+ const LOCK_RETRY_DELAY_MS = 750; // 4 gaps between 5 attempts * 750ms = ~3s total, before giving up
1445
+ // Distinct from die()'s default (1) and the usage-error code (2, parseArgs) β€” checked against every `die(...,
1446
+ // N)` call and every process.exitCode assignment in this file before picking it; nothing in bin/cfact.js uses 3.
1447
+ // A separate code (not a reused 1) is the point: FEAT-308's one-click update reads it to tell "still locked after
1448
+ // retrying" apart from every other installer failure without parsing message text.
1449
+ const ENGINE_LOCK_EXIT_CODE = 3;
1450
+
1451
+ /**
1452
+ * Synchronous sleep β€” the retry above runs inside installStagedEngine, which is synchronous (materialise() awaits
1453
+ * it as a whole, but the swap itself has no await points to yield at). Atomics.wait blocks the calling thread for
1454
+ * up to `ms` without spinning the CPU and needs no native addon. Exported so a caller that cannot use it (none in
1455
+ * this repo) could substitute its own; a fixture substitutes a no-op instead so the retry-exhausted case does not
1456
+ * actually cost ~3s per assertion.
1457
+ */
1458
+ function sleepSync(ms) {
1459
+ try {
1460
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
1461
+ } catch {
1462
+ // No known supported Node build lacks Atomics.wait; kept as a defensive, non-spinning-free fallback rather than
1463
+ // silently skipping the delay outright.
1464
+ const until = Date.now() + ms;
1465
+ while (Date.now() < until) { /* busy-wait */ }
1466
+ }
1467
+ }
1468
+
1469
+ /**
1470
+ * Runs `fn`, retrying only while it throws a LOCK error (`isLockError`), up to `attempts` times with `delayMs`
1471
+ * between tries. A non-lock error, or the lock error on the final attempt, propagates to the caller unchanged β€”
1472
+ * this never swallows a failure, it only buys a transient one a few seconds to clear. `sleepImpl` is injectable so
1473
+ * a fixture can prove both outcomes (clears within the window; still locked after it) without a real wait.
1474
+ */
1475
+ function withLockRetry(fn, { attempts = LOCK_RETRY_ATTEMPTS, delayMs = LOCK_RETRY_DELAY_MS, sleepImpl = sleepSync } = {}) {
1476
+ for (let i = 0; i < attempts; i++) {
1477
+ try {
1478
+ return fn();
1479
+ } catch (e) {
1480
+ if (!isLockError(e) || i === attempts - 1) throw e;
1481
+ sleepImpl(delayMs);
1482
+ }
1483
+ }
1484
+ /* istanbul ignore next β€” unreachable: the loop above always returns or throws */
1485
+ throw new Error('withLockRetry: unreachable');
1486
+ }
1487
+
1488
+ // --- Windows-only best-effort "who might be holding it" candidate scan (CHG-344, FF-392) -----------------------
1489
+ // ADR-0378 reverted naming a single tool as THE cause of a lock β€” the two tools it used to name were, measured,
1490
+ // NOT the actual holder, and asserting a cause that is usually wrong cost real runs. This is a different, narrower
1491
+ // claim and does not reintroduce that framing: it lists processes from a small, named set that are OBSERVED
1492
+ // RUNNING right now via `tasklist`, labelled candidates, never asserted as the cause. The set is the two kinds
1493
+ // CHG-344 itself names as historically implicated (editors/IDEs, antivirus) β€” the same two kinds CLOSE_AND_RERUN
1494
+ // above already describes generically ("an editor with a file from it open") alongside "a dev server or desktop
1495
+ // app" and "a terminal", neither of which has a stable, enumerable process name and so is left out of the scan.
1496
+ const WINDOWS_LOCK_CANDIDATE_PROCESSES = [
1497
+ 'Code.exe', // Visual Studio Code
1498
+ 'Cursor.exe', // Cursor
1499
+ 'devenv.exe', // Visual Studio
1500
+ 'idea64.exe', // IntelliJ-family IDEs
1501
+ 'notepad++.exe', // Notepad++
1502
+ 'sublime_text.exe', // Sublime Text
1503
+ 'MsMpEng.exe', // Windows Defender
1504
+ 'avp.exe', // Kaspersky
1505
+ 'avastsvc.exe', // Avast
1506
+ 'bdagent.exe', // Bitdefender
1507
+ ];
1508
+
1509
+ /**
1510
+ * Best-effort only: never throws. A non-Windows platform, a missing/failing `tasklist`, or any spawn error all
1511
+ * return `[]` β€” this is supporting information for a message that must still print correctly without it.
1512
+ * `execImpl`/`platform` are injectable so the matching logic is testable without a Windows host.
1513
+ */
1514
+ function scanWindowsLockCandidates({ platform = process.platform, execImpl = execFileSync } = {}) {
1515
+ if (platform !== 'win32') return [];
1516
+ let out;
1517
+ try {
1518
+ out = String(execImpl('tasklist', [], { stdio: ['ignore', 'pipe', 'ignore'] }));
1519
+ } catch {
1520
+ return [];
1521
+ }
1522
+ const lower = out.toLowerCase();
1523
+ return WINDOWS_LOCK_CANDIDATE_PROCESSES.filter((name) => lower.includes(name.toLowerCase()));
1524
+ }
1525
+
1526
+ /**
1527
+ * Formats the scan result as an explicitly-labelled, non-causal addendum. Empty when there is nothing to add
1528
+ * (not Windows, the scan failed, or none of the named candidates are running) β€” an empty "candidates:" line would
1529
+ * read as a finding where the scan made none.
1530
+ */
1531
+ function windowsCandidateMessage(candidates) {
1532
+ if (!candidates || !candidates.length) return '';
1533
+ return ` Candidates currently running (not necessarily the cause): ${candidates.join(', ')}.`;
1534
+ }
1535
+
1294
1536
  /**
1295
1537
  * Install a staged engine tree at `enginePath` WITHOUT ever leaving the consumer with no engine, and without leaving
1296
1538
  * residue behind on any failure path (CHG-288, FF-389).
@@ -1307,19 +1549,26 @@ function isLockError(e) {
1307
1549
  * a dry rename-and-restore probe, deliberately: a probe can succeed and the real rename still fail (a handle opened in
1308
1550
  * between), and a probe whose restore half fails is exactly the "no engine" state this function exists to avoid.
1309
1551
  *
1310
- * `fsImpl` is injectable so the failure paths are testable without a locked directory.
1552
+ * `fsImpl` is injectable so the failure paths are testable without a locked directory. `sleepImpl`/`execImpl` are
1553
+ * injectable the same way for the rename's retry delay and the Windows candidate scan (CHG-344) β€” neither is a
1554
+ * real wait or a real `tasklist` call in a fixture.
1555
+ *
1556
+ * CHG-344 (FF-392) added a short bounded retry around the ONE rename that moves the current engine aside β€” a
1557
+ * transient lock there often clears within a few seconds β€” and, only once that retry is exhausted, a distinct
1558
+ * exit code (`ENGINE_LOCK_EXIT_CODE`) plus, on Windows, a best-effort list of named candidate processes observed
1559
+ * running. Every other lock-error site below is unchanged.
1311
1560
  */
1312
- function installStagedEngine({ enginePath, stageDir, tmpDir, fsImpl = fs, platform = process.platform }) {
1561
+ function installStagedEngine({ enginePath, stageDir, tmpDir, fsImpl = fs, platform = process.platform, sleepImpl, execImpl }) {
1313
1562
  const engineParent = path.dirname(enginePath);
1314
1563
  const incoming = path.join(engineParent, '.engine.incoming');
1315
1564
  const backup = path.join(engineParent, '.engine.backup');
1316
1565
  const quietRm = (target) => {
1317
1566
  try { fsImpl.rmSync(target, { recursive: true, force: true }); } catch { /* best effort: never mask the real error */ }
1318
1567
  };
1319
- const abort = (message) => {
1568
+ const abort = (message, code) => {
1320
1569
  quietRm(incoming);
1321
1570
  quietRm(tmpDir);
1322
- die(message);
1571
+ die(message, code);
1323
1572
  };
1324
1573
 
1325
1574
  try {
@@ -1342,11 +1591,22 @@ function installStagedEngine({ enginePath, stageDir, tmpDir, fsImpl = fs, platfo
1342
1591
  const hadOld = fsImpl.existsSync(enginePath);
1343
1592
  if (hadOld) {
1344
1593
  try {
1345
- fsImpl.renameSync(enginePath, backup);
1594
+ // CHG-344: this specific rename gets a short bounded retry β€” a transient lock here (antivirus finishing a
1595
+ // scan, a brief file-watcher hold) often clears within the ~3s window, and retrying costs nothing when it
1596
+ // doesn't.
1597
+ withLockRetry(() => fsImpl.renameSync(enginePath, backup), { sleepImpl });
1346
1598
  } catch (e) {
1347
- abort(isLockError(e)
1348
- ? `cannot replace ${enginePath} (${e.code}): another program is holding it open. ${CLOSE_AND_RERUN}${lockHolderGuidance(platform)}${e.code === 'EACCES' ? ' (EACCES can also mean you lack write permission on .claude/; if closing them changes nothing, check that.)' : ''} Your current engine was not touched.`
1349
- : `cannot move the current engine aside β€” ${e.message}. Your current engine was not touched.`);
1599
+ if (isLockError(e)) {
1600
+ // Still locked after retrying: a distinct exit code (never asserted as "the cause" of anything β€” see
1601
+ // scanWindowsLockCandidates) and, on Windows, the best-effort candidate list.
1602
+ const candidates = scanWindowsLockCandidates({ platform, execImpl });
1603
+ abort(
1604
+ `cannot replace ${enginePath} after retrying for ~${LOCK_RETRY_DELAY_MS * (LOCK_RETRY_ATTEMPTS - 1) / 1000}s (${e.code}): another program is holding it open. ${CLOSE_AND_RERUN}${lockHolderGuidance(platform)}${e.code === 'EACCES' ? ' (EACCES can also mean you lack write permission on .claude/; if closing them changes nothing, check that.)' : ''} Your current engine was not touched.${windowsCandidateMessage(candidates)}`,
1605
+ ENGINE_LOCK_EXIT_CODE
1606
+ );
1607
+ } else {
1608
+ abort(`cannot move the current engine aside β€” ${e.message}. Your current engine was not touched.`);
1609
+ }
1350
1610
  }
1351
1611
  }
1352
1612
  try {
@@ -1413,6 +1673,37 @@ async function materialise(opts) {
1413
1673
  }
1414
1674
 
1415
1675
  const pin = readPin(consumerRoot);
1676
+
1677
+ // CHG-319/ADR-0453: resolve "latest" when NEITHER --version NOR an existing
1678
+ // pin names one. Scoped narrowly by hasExplicitSource() (--from/--url/the env
1679
+ // equivalent all still behave exactly as before, unaffected), and a bare
1680
+ // `update` on an ALREADY-PINNED consumer never reaches this branch at all β€”
1681
+ // pin.version being set is one of the two things that turns it off, so
1682
+ // ADR-0128's existing rule (a plain `update` keeps the pin, never auto-
1683
+ // upgrades) is completely unchanged.
1684
+ //
1685
+ // On success this REPLACES opts.version with the resolved release id, so
1686
+ // every line below β€” resolveSource, the checksum verification, the pin write,
1687
+ // describeUpdateOutcome's no-op/real-update split β€” proceeds exactly as if
1688
+ // the user had passed `--version <that version>` explicitly. Nothing
1689
+ // downstream needs to know "latest" was ever involved.
1690
+ let latestManifest = null;
1691
+ if (needsLatestResolution(opts, pin)) {
1692
+ const manifestSource = resolveLatestManifestSource(opts, pin);
1693
+ if (!manifestSource) {
1694
+ die(
1695
+ 'no engine version to install, and the configured channel (GitHub Releases) has no ' +
1696
+ '"latest" lookup yet (that is a later, separate change). Pass --version <v>, or run in ' +
1697
+ 'a consumer whose .claude/engine.pin.json records one, or point at a tarball with ' +
1698
+ '--from / --url, or drop --channel github-releases / --repo to use the studio ' +
1699
+ "channel's latest release."
1700
+ );
1701
+ }
1702
+ latestManifest = await fetchLatestManifest(manifestSource, consumerRoot);
1703
+ info(` resolved latest release: ${latestManifest.version}`);
1704
+ opts = { ...opts, version: latestManifest.version };
1705
+ }
1706
+
1416
1707
  const source = resolveSource(opts, pin);
1417
1708
  // Where to look for .env / .env.local when the bearer is not exported (ADR-0184,
1418
1709
  // FF-265). Stamped here rather than threaded through resolveSource's five return
@@ -1435,21 +1726,34 @@ async function materialise(opts) {
1435
1726
  // `update` β€” where the versions match and this verifies.
1436
1727
  const actual = sha256(tarball);
1437
1728
  const pinDescribesTarget = !opts.version || !pin.version || opts.version === pin.version;
1438
- const expected = pinDescribesTarget ? (pin.checksum || '').replace(/^sha256:/, '') : '';
1729
+ // CHG-319/ADR-0453: a latest-RESOLVED install verifies against the MANIFEST's
1730
+ // own checksum, never the pin's. The pin has no version/checksum to compare
1731
+ // in this branch by construction β€” that absence is exactly what triggered the
1732
+ // latest lookup above β€” so pinDescribesTarget's fallback-to-pin logic would
1733
+ // otherwise silently verify nothing. The manifest is the one source that
1734
+ // actually describes the version just downloaded, "the same way it already
1735
+ // verifies a specific-version install" (CHG-319's own scope).
1736
+ const expected = latestManifest
1737
+ ? (latestManifest.checksum || '').replace(/^sha256:/, '')
1738
+ : pinDescribesTarget
1739
+ ? (pin.checksum || '').replace(/^sha256:/, '')
1740
+ : '';
1439
1741
  if (expected) {
1440
1742
  if (actual !== expected) {
1441
1743
  die(
1442
1744
  `checksum mismatch β€” expected sha256:${expected}, got sha256:${actual}. ` +
1443
- `The tarball does not match the pinned checksum. Refusing to install.`
1745
+ `The tarball does not match the ${latestManifest ? "latest-release manifest's" : 'pinned'} checksum. Refusing to install.`
1444
1746
  );
1445
1747
  }
1446
1748
  info(`βœ… checksum verified (sha256:${actual.slice(0, 12)}…)`);
1447
1749
  } else if (opts.requireChecksum) {
1448
1750
  die(
1449
- pinDescribesTarget
1450
- ? 'no checksum recorded in .claude/engine.pin.json and --require-checksum was given.'
1451
- : `--require-checksum was given but the pin's checksum describes version ${pin.version}, ` +
1452
- `not the requested ${opts.version}. Update the pin (version + checksum) and re-run.`
1751
+ latestManifest
1752
+ ? 'no checksum recorded in the latest-release manifest and --require-checksum was given.'
1753
+ : pinDescribesTarget
1754
+ ? 'no checksum recorded in .claude/engine.pin.json and --require-checksum was given.'
1755
+ : `--require-checksum was given but the pin's checksum describes version ${pin.version}, ` +
1756
+ `not the requested ${opts.version}. Update the pin (version + checksum) and re-run.`
1453
1757
  );
1454
1758
  } else {
1455
1759
  // The remedy half of this line must describe what THIS RUN does, not a
@@ -1483,9 +1787,11 @@ async function materialise(opts) {
1483
1787
  // no pin, so there the instruction is the only thing that resolves it.
1484
1788
  info(
1485
1789
  `⚠️ checksum not verified β€” ${
1486
- pinDescribesTarget
1487
- ? 'no checksum recorded in the pin file'
1488
- : `the pin's checksum describes version ${pin.version}, not ${opts.version}`
1790
+ latestManifest
1791
+ ? 'the latest-release manifest has no checksum field'
1792
+ : pinDescribesTarget
1793
+ ? 'no checksum recorded in the pin file'
1794
+ : `the pin's checksum describes version ${pin.version}, not ${opts.version}`
1489
1795
  }. Computed sha256:${actual.slice(0, 12)}… β€” on success this run records it ` +
1490
1796
  `in .claude/engine.pin.json.`
1491
1797
  );
@@ -1771,7 +2077,12 @@ module.exports = {
1771
2077
  tarExtractInvocation,
1772
2078
  ASSET,
1773
2079
  LEGACY_ASSET,
2080
+ LATEST_MANIFEST_ASSET,
1774
2081
  resolveSource,
2082
+ hasExplicitSource,
2083
+ needsLatestResolution,
2084
+ resolveLatestManifestSource,
2085
+ STUDIO_ORIGIN,
1775
2086
  DEFAULT_CHANNEL_URL,
1776
2087
  GITHUB_CHANNEL_LABEL,
1777
2088
  channelBase,
@@ -1797,4 +2108,12 @@ module.exports = {
1797
2108
  isLockError,
1798
2109
  lockHolderGuidance,
1799
2110
  installStagedEngine,
2111
+ withLockRetry,
2112
+ sleepSync,
2113
+ scanWindowsLockCandidates,
2114
+ windowsCandidateMessage,
2115
+ WINDOWS_LOCK_CANDIDATE_PROCESSES,
2116
+ ENGINE_LOCK_EXIT_CODE,
2117
+ LOCK_RETRY_ATTEMPTS,
2118
+ LOCK_RETRY_DELAY_MS,
1800
2119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindexed/cfact",
3
- "version": "1.1.8",
3
+ "version": "1.1.12",
4
4
  "description": "Clean Orthogonal Architecture Software Factory Framework",
5
5
  "bin": {
6
6
  "claude-factory": "bin/cfact.js",
@@ -37,6 +37,7 @@
37
37
  "gate:document-freshness": "node scripts/check-document-freshness.js",
38
38
  "gate:registry": "node scripts/check-registry.js",
39
39
  "gate:rule-records": "node scripts/check-rule-records.js",
40
+ "gate:integrations": "node scripts/check-integrations.js",
40
41
  "audit:record-text": "node scripts/check-record-text.js",
41
42
  "gate:graph-coverage": "node scripts/check-graph-coverage.js",
42
43
  "gate:adr-template-edges": "node scripts/check-adr-template-edges.js",
@@ -57,9 +58,19 @@
57
58
  "test:parse-ast": "node skills/ast-parser/scripts/test-parse-ast.js",
58
59
  "test:git-tree-sweep": "node scripts/test-git-tree-sweep.js",
59
60
  "test:secrets-two-stage": "node scripts/test-secrets-two-stage.js",
61
+ "test:harmful-code": "node scripts/test-harmful-code-check.js",
60
62
  "test:migration-grants-check": "node scripts/test-migration-grants-check.js",
61
63
  "test:profile-paths": "node scripts/verify-profiles.js",
62
64
  "test:registry-gate": "node scripts/test-registry-gate.js",
65
+ "test:capability-schema": "node scripts/test-capability-schema.js",
66
+ "test:integrations-registry": "node scripts/test-integrations-registry.js",
67
+ "test:claim-schema": "node scripts/test-claim-schema.js",
68
+ "test:engine-health": "node scripts/test-engine-health.js",
69
+ "test:session-binding-schema": "node scripts/test-session-binding-schema.js",
70
+ "test:budget-schema": "node scripts/test-budget-schema.js",
71
+ "test:runner-launch-schema": "node scripts/test-runner-launch-schema.js",
72
+ "test:approval-vocabulary": "node scripts/test-approval-vocabulary.js",
73
+ "test:human-only-verbs": "node scripts/test-human-only-verbs.js",
63
74
  "test:rule-resolver": "node scripts/test-rule-resolver.js",
64
75
  "test:adr-template-edges": "node scripts/test-adr-template-edges.js",
65
76
  "test:adr-path-constants": "node scripts/test-adr-path-constants.js",
@@ -76,9 +87,12 @@
76
87
  "test:zone-coverage": "node scripts/test-zone-coverage.js",
77
88
  "test:workflow-spine": "node scripts/test-workflow-spine.js",
78
89
  "test:architecture-size-gate": "node scripts/test-architecture-size-gate.js",
90
+ "test:size-gate-attribution": "node scripts/test-size-gate-attribution.js",
79
91
  "test:command-shape": "node scripts/test-command-shape.js",
80
92
  "test:change-record": "node scripts/test-change-record.js",
81
93
  "test:artifact-timestamps": "node scripts/test-artifact-timestamps.js",
94
+ "test:regen-writes-nothing": "node scripts/test-regen-writes-nothing.js",
95
+ "test:map-fingerprint": "node scripts/test-map-fingerprint.js",
82
96
  "test:engine-write-lock": "node scripts/test-engine-write-lock.js",
83
97
  "test:engine-lock-wiring": "node scripts/test-engine-lock-wiring.js",
84
98
  "test:installer-publish-drift": "node scripts/test-installer-publish-drift.js",
@@ -86,23 +100,48 @@
86
100
  "test:test-capability": "node scripts/test-test-capability.js",
87
101
  "test:installer-lifecycle": "node scripts/test-installer-lifecycle.js",
88
102
  "test:installer-shadowing": "node scripts/test-installer-shadowing.js",
103
+ "test:installer-latest": "node scripts/test-installer-latest.js",
104
+ "test:outside-consumer-mcp-gate": "node scripts/test-outside-consumer-mcp-gate.js",
105
+ "test:relay-fallback": "node scripts/test-relay-fallback.js",
89
106
  "test:feature-record": "node scripts/test-feature-record.js",
90
107
  "test:feature-store": "node scripts/test-feature-store.js",
91
108
  "test:feature-record-v2": "node scripts/test-feature-record-v2.js",
109
+ "test:feature-initial": "node scripts/test-feature-initial.js",
92
110
  "test:feature-v2-switch": "node scripts/test-feature-v2-switch.js",
93
111
  "test:feature-completeness": "node scripts/test-feature-completeness.js",
112
+ "test:experience-context": "node scripts/test-experience-context.js",
113
+ "test:feature-scope-merge": "node scripts/test-feature-scope-merge.js",
114
+ "test:feature-mint-contract": "node scripts/test-feature-mint-contract.js",
115
+ "test:org-manifest": "node scripts/test-org-manifest.js",
116
+ "test:org-manifest-denies": "node scripts/test-org-manifest-denies.js",
117
+ "test:intake-seed": "node scripts/test-intake-seed.js",
118
+ "test:intake-seed-prefill": "node scripts/test-intake-seed-prefill.js",
119
+ "test:design-brief-from-seed": "node scripts/test-design-brief-from-seed.js",
120
+ "test:design-brief-regeneration": "node scripts/test-design-brief-regeneration.js",
121
+ "test:audit-sot-brand-source": "node scripts/test-audit-sot-brand-source.js",
122
+ "test:audit-sot-surfaces": "node scripts/test-audit-sot-surfaces.js",
123
+ "test:audit-sot-tenancy-model": "node scripts/test-audit-sot-tenancy-model.js",
124
+ "test:screen-binding": "node scripts/test-screen-binding.js",
125
+ "test:flow-step-action": "node scripts/test-flow-step-action.js",
94
126
  "test:feature-history": "node scripts/test-feature-history.js",
95
127
  "test:feature-rekey": "node scripts/test-feature-rekey.js",
96
128
  "test:agent-note-dispatch": "node scripts/test-agent-note-dispatch.js",
129
+ "test:subagent-reply-guard": "node scripts/test-subagent-reply-guard.js",
130
+ "test:migrations-block": "node scripts/test-migrations-block.js",
97
131
  "test:stage-loop-next-action": "node scripts/test-stage-loop-next-action.js",
132
+ "test:transition-phase-flags": "node scripts/test-transition-phase-flags.js",
133
+ "test:workflow-flag-allowlist": "node scripts/test-workflow-flag-allowlist.js",
98
134
  "test:check-record-text": "node scripts/test-check-record-text.js",
99
135
  "test:feature-write-guard": "node scripts/test-feature-write-guard.js",
100
136
  "test:trailer-lib": "node scripts/test-trailer-lib.js",
101
137
  "test:feature-write-lock": "node scripts/test-feature-write-lock.js",
102
138
  "test:ci-parity": "node scripts/test-ci-parity.js",
103
139
  "test:generate-ci": "node scripts/test-generate-ci.js",
140
+ "test:verification-targets": "node scripts/test-verification-targets.js",
141
+ "test:generate-capability-map": "node scripts/test-generate-capability-map.js",
142
+ "test:capability-catalogue-gate": "node scripts/test-capability-catalogue-gate.js",
104
143
  "publish:release": "node maintainer-hooks/publish-release.js",
105
- "gate:consistency": "npm run gate:matrix-sync && npm run gate:compliance && npm run gate:doc-links && npm run gate:command-metadata && npm run gate:tracked-symlinks && npm run gate:agents-md-sync && npm run gate:ripple-coverage && npm run gate:profile-docs && npm run gate:registry && npm run gate:rule-records && npm run gate:graph-coverage && npm run gate:adr-template-edges && npm run gate:installer-publish-drift && npm run gate:private-names",
144
+ "gate:consistency": "npm run gate:matrix-sync && npm run gate:compliance && npm run gate:doc-links && npm run gate:command-metadata && npm run gate:tracked-symlinks && npm run gate:agents-md-sync && npm run gate:ripple-coverage && npm run gate:profile-docs && npm run gate:registry && npm run gate:rule-records && npm run gate:integrations && npm run gate:graph-coverage && npm run gate:adr-template-edges && npm run gate:installer-publish-drift && npm run gate:private-names",
106
145
  "gate:boundaries": "bash hooks/check-matrix.sh domain && bash hooks/check-matrix.sh components && bash hooks/check-matrix.sh controllers && bash hooks/check-matrix.sh secrets",
107
146
  "ci": "npm run gate:consistency && npm run gate:boundaries && npm run gate:profile-coverage && npm run gate:document-freshness && npm test",
108
147
  "test:gate-three-state": "node scripts/test-gate-three-state.js",
@@ -114,27 +153,31 @@
114
153
  "test:rules-carrier-schema": "node scripts/test-rules-carrier-schema.js",
115
154
  "test:rule-record-schema": "node scripts/test-rule-record-schema.js",
116
155
  "test:rule-record-concerns-check": "node scripts/test-rule-record-concerns-check.js",
156
+ "test:rule-record-core-check": "node scripts/test-rule-record-core-check.js",
117
157
  "test:external-standard-drift": "node scripts/test-external-standard-drift.js",
118
158
  "test:session-branch": "node scripts/test-session-branch.js",
159
+ "test:git-lock": "node scripts/test-git-lock.js",
119
160
  "test:consumer-docs-migration": "node scripts/test-consumer-docs-migration.js",
120
161
  "test:sot-templates-pointer": "node scripts/test-sot-templates-pointer.js",
121
- "test:npm-deprecation": "node scripts/test-npm-deprecation.js",
122
162
  "test:generate-erd": "node scripts/test-generate-erd.js",
123
163
  "test:surfaces-layerpaths": "node scripts/test-surfaces-layerpaths.js",
124
164
  "test:surfaces-hostmodules": "node scripts/test-surfaces-hostmodules.js",
125
165
  "test:list-feature-files": "node scripts/test-list-feature-files.js",
126
166
  "test:generate-project-analysis": "node scripts/test-generate-project-analysis.js",
127
167
  "test:generate-feature-card": "node scripts/test-generate-feature-card.js",
168
+ "test:zone-view": "node scripts/test-zone-view.js",
128
169
  "test:generate-codex-agents": "node scripts/test-generate-codex-agents.js",
129
170
  "test:context-subject": "node scripts/test-context-subject.js",
130
171
  "test:design-levels": "node scripts/test-design-levels.js",
131
172
  "test:pre-push-unit-ref": "node scripts/test-pre-push-unit-ref.js",
132
173
  "test:pre-push-gate-reach": "node scripts/test-pre-push-gate-reach.js",
174
+ "test:git-identity-check": "node scripts/test-git-identity-check.js",
175
+ "test:mcp-server-name-constant": "node scripts/test-mcp-server-name-constant.js",
133
176
  "test:design-audit": "node scripts/test-design-audit.js",
134
177
  "test:grants-definer-declaration": "node scripts/test-grants-definer-declaration.js",
135
178
  "test:default-ship-pipeline": "node scripts/test-default-ship-pipeline.js",
136
179
  "test:credential-slots": "node scripts/test-credential-slots.js",
137
- "test": "npm run test:dc-generator && npm run test:substance-generator && npm run test:json-flush && npm run test:installer-exit && npm run test:installer-channel && npm run test:installer-update-messaging && npm run test:installer-wiring && npm run test:tar-invocation && npm run test:framework-agents-mcp && npm run test:controller-gates && npm run test:controller-single-file-attribution && npm run test:parse-ast && npm run test:git-tree-sweep && npm run test:secrets-two-stage && npm run test:migration-grants-check && npm run test:profile-paths && npm run test:registry-gate && npm run test:rule-resolver && npm run test:adr-template-edges && npm run test:adr-path-constants && npm run test:resolver-topology && npm run test:graph-strip && npm run test:graph-registry && npm run test:graph-memory-substrate && npm run test:document-freshness && npm run test:frontmatter-readers && npm run test:tarball-reproducible && npm run test:release-version && npm run test:consumer-checklist && npm run test:engine-host && npm run test:zone-coverage && npm run test:workflow-spine && npm run test:architecture-size-gate && npm run test:command-shape && npm run test:change-record && npm run test:engine-write-lock && npm run test:engine-lock-wiring && npm run test:installer-publish-drift && npm run test:grants-authored && npm run test:test-capability && npm run test:installer-lifecycle && npm run test:gate-three-state && npm run test:refresh-compliance && npm run test:gate-coverage && npm run test:policy-lib && npm run test:validate-zone-denylist-bypass && npm run test:validate-zone-ledger-score && npm run test:rules-carrier-schema && npm run test:rule-record-schema && npm run test:rule-record-concerns-check && npm run test:external-standard-drift && npm run test:session-branch && npm run test:installer-shadowing && npm run test:feature-record && npm run test:feature-store && npm run test:feature-record-v2 && npm run test:feature-v2-switch && npm run test:feature-completeness && npm run test:feature-history && npm run test:feature-rekey && npm run test:agent-note-dispatch && npm run test:stage-loop-next-action && npm run test:check-record-text && npm run test:consumer-docs-migration && npm run test:npm-deprecation && npm run test:sot-templates-pointer && npm run test:test-command-gate && npm run test:changelog-adr-refs && npm run test:generate-ci && npm run test:known-frictions-staleness && npm run test:artifact-timestamps && npm run test:generate-flow-map && npm run test:generate-zone-map && npm run test:generate-infra-map && npm run test:generate-legal-map && npm run test:generate-erd && npm run test:surfaces-layerpaths && npm run test:surfaces-hostmodules && npm run test:list-feature-files && npm run test:feature-write-guard && npm run test:feature-write-lock && npm run test:trailer-lib && npm run test:ci-parity && npm run test:context-subject && npm run test:generate-project-analysis && npm run test:generate-feature-card && npm run test:generate-codex-agents && npm run test:generate-agent-cards && npm run test:generate-framework-graph && npm run test:unrecorded-scope && npm run test:profile-reinstated-zones && npm run test:contract-claims && npm run test:plan-crosscheck && npm run test:consumer-alignment && npm run test:check-consumer-alignment && npm run test:design-levels && npm run test:pre-push-unit-ref && npm run test:pre-push-gate-reach && npm run test:design-audit && npm run test:grants-definer-declaration && npm run test:default-ship-pipeline && npm run test:credential-slots && npm run test:licence-holder && npm run test:engine-promotion-rungs-workflow && npm run test:engine-release-workflows && npm run test:split-acceptance && npm run test:private-names",
180
+ "test": "npm run test:dc-generator && npm run test:substance-generator && npm run test:json-flush && npm run test:installer-exit && npm run test:installer-channel && npm run test:installer-update-messaging && npm run test:installer-wiring && npm run test:tar-invocation && npm run test:framework-agents-mcp && npm run test:controller-gates && npm run test:controller-single-file-attribution && npm run test:parse-ast && npm run test:git-tree-sweep && npm run test:secrets-two-stage && npm run test:harmful-code && npm run test:migration-grants-check && npm run test:profile-paths && npm run test:registry-gate && npm run test:capability-schema && npm run test:integrations-registry && npm run test:claim-schema && npm run test:session-binding-schema && npm run test:budget-schema && npm run test:engine-health && npm run test:runner-launch-schema && npm run test:approval-vocabulary && npm run test:human-only-verbs && npm run test:rule-resolver && npm run test:adr-template-edges && npm run test:adr-path-constants && npm run test:resolver-topology && npm run test:graph-strip && npm run test:graph-registry && npm run test:graph-memory-substrate && npm run test:document-freshness && npm run test:frontmatter-readers && npm run test:tarball-reproducible && npm run test:release-version && npm run test:consumer-checklist && npm run test:engine-host && npm run test:zone-coverage && npm run test:workflow-spine && npm run test:architecture-size-gate && npm run test:size-gate-attribution && npm run test:command-shape && npm run test:change-record && npm run test:engine-write-lock && npm run test:engine-lock-wiring && npm run test:installer-publish-drift && npm run test:grants-authored && npm run test:test-capability && npm run test:installer-lifecycle && npm run test:outside-consumer-mcp-gate && npm run test:relay-fallback && npm run test:gate-three-state && npm run test:refresh-compliance && npm run test:gate-coverage && npm run test:policy-lib && npm run test:validate-zone-denylist-bypass && npm run test:validate-zone-ledger-score && npm run test:rules-carrier-schema && npm run test:rule-record-schema && npm run test:rule-record-concerns-check && npm run test:rule-record-core-check && npm run test:external-standard-drift && npm run test:session-branch && npm run test:installer-shadowing && npm run test:installer-latest && npm run test:feature-record && npm run test:feature-store && npm run test:feature-record-v2 && npm run test:feature-initial && npm run test:feature-v2-switch && npm run test:feature-completeness && npm run test:experience-context && npm run test:feature-scope-merge && npm run test:feature-mint-contract && npm run test:org-manifest && npm run test:org-manifest-denies && npm run test:intake-seed && npm run test:intake-seed-prefill && npm run test:design-brief-from-seed && npm run test:design-brief-regeneration && npm run test:audit-sot-brand-source && npm run test:audit-sot-surfaces && npm run test:audit-sot-tenancy-model && npm run test:screen-binding && npm run test:flow-step-action && npm run test:feature-history && npm run test:feature-rekey && npm run test:agent-note-dispatch && npm run test:subagent-reply-guard && npm run test:migrations-block && npm run test:stage-loop-next-action && npm run test:transition-phase-flags && npm run test:workflow-flag-allowlist && npm run test:check-record-text &&npm run test:consumer-docs-migration && npm run test:sot-templates-pointer && npm run test:test-command-gate && npm run test:changelog-adr-refs && npm run test:generate-ci && npm run test:verification-targets && npm run test:known-frictions-staleness && npm run test:artifact-timestamps && npm run test:regen-writes-nothing && npm run test:map-fingerprint && npm run test:generate-flow-map && npm run test:generate-zone-map && npm run test:generate-infra-map && npm run test:generate-legal-map && npm run test:generate-erd && npm run test:surfaces-layerpaths && npm run test:surfaces-hostmodules && npm run test:list-feature-files && npm run test:feature-write-guard && npm run test:feature-write-lock && npm run test:trailer-lib && npm run test:ci-parity && npm run test:context-subject && npm run test:generate-project-analysis && npm run test:generate-feature-card && npm run test:zone-view && npm run test:generate-codex-agents && npm run test:generate-agent-cards && npm run test:generate-capability-map && npm run test:capability-catalogue-gate && npm run test:generate-framework-graph && npm run test:unrecorded-scope && npm run test:profile-reinstated-zones && npm run test:contract-claims && npm run test:plan-crosscheck && npm run test:consumer-alignment && npm run test:check-consumer-alignment && npm run test:design-levels && npm run test:pre-push-unit-ref && npm run test:pre-push-gate-reach && npm run test:git-identity-check && npm run test:mcp-server-name-constant && npm run test:design-audit && npm run test:grants-definer-declaration && npm run test:default-ship-pipeline && npm run test:credential-slots && npm run test:licence-holder && npm run test:engine-promotion-rungs-workflow && npm run test:engine-release-workflows && npm run test:split-acceptance && npm run test:private-names && npm run test:migrate-feature-records && npm run test:depends-on-enforcement && npm run test:integration-adapters && npm run test:sync-env-registry && npm run test:design-audit-gate && npm run test:candidate-flows && npm run test:mcp-auth-probe && npm run test:design-motion-audit && npm run test:design-screens && npm run test:feature-source-notes && npm run test:code-review-log-schema && npm run test:note-alignment && npm run test:design-motion-inputs && npm run test:requirement-promotion && npm run test:programme-note-admission && npm run test:ux-baseline && npm run test:note-promotion-gate && npm run test:proposal-acceptance-mint && npm run test:maintainer-screen-judge && npm run test:ux-qa-review-gate && npm run test:git-lock",
138
181
  "test:test-command-gate": "node scripts/test-test-command-gate.js",
139
182
  "test:changelog-adr-refs": "node scripts/test-changelog-adr-refs.js",
140
183
  "test:known-frictions-staleness": "node scripts/test-known-frictions-staleness.js",
@@ -155,9 +198,29 @@
155
198
  "test:engine-release-workflows": "node scripts/test-engine-release-workflows.js",
156
199
  "test:split-acceptance": "node scripts/test-split-acceptance.js",
157
200
  "test:private-names": "node scripts/test-private-names.js",
201
+ "test:migrate-feature-records": "node scripts/test-migrate-feature-records.js",
202
+ "test:depends-on-enforcement": "node scripts/test-depends-on-enforcement.js",
203
+ "test:integration-adapters": "node scripts/test-integration-adapters.js",
204
+ "test:sync-env-registry": "node scripts/test-sync-env-registry.js",
205
+ "test:design-audit-gate": "node scripts/test-design-audit-gate.js",
206
+ "test:candidate-flows": "node scripts/test-candidate-flows.js",
207
+ "test:mcp-auth-probe": "node scripts/test-mcp-auth-probe.js",
208
+ "test:design-motion-audit": "node scripts/test-design-motion-audit.js",
209
+ "test:design-screens": "node scripts/test-design-screens.js",
210
+ "test:feature-source-notes": "node scripts/test-feature-source-notes.js",
211
+ "test:code-review-log-schema": "node scripts/test-code-review-log-schema.js",
212
+ "test:note-alignment": "node scripts/test-note-alignment.js",
213
+ "test:design-motion-inputs": "node scripts/test-design-motion-inputs.js",
214
+ "test:requirement-promotion": "node scripts/test-requirement-promotion.js",
215
+ "test:programme-note-admission": "node scripts/test-programme-note-admission.js",
216
+ "test:ux-baseline": "node scripts/test-ux-baseline.js",
217
+ "test:note-promotion-gate": "node scripts/test-note-promotion-gate.js",
218
+ "test:proposal-acceptance-mint": "node scripts/test-proposal-acceptance-mint.js",
219
+ "test:maintainer-screen-judge": "node scripts/test-maintainer-screen-judge.js",
220
+ "test:ux-qa-review-gate": "node scripts/test-ux-qa-review-gate.js",
158
221
  "acceptance:split": "node scripts/split-acceptance.js"
159
222
  },
160
223
  "keywords": [],
161
- "author": "JosΓ© Brenes",
224
+ "author": "Jose Brenes",
162
225
  "license": "MIT"
163
226
  }