@patronage/software-factory 1.0.0-alpha.46 → 1.0.0-alpha.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ A stacked release train has one terminal release-owning slice. Interior slices d
41
41
  A stable cut has two phases. Phase 1 is the verified package candidate: steps 1 through 4 below, ending in the attended npm publish, tag, and GitHub release. Phase 2 is post-publication stable-doc convergence: steps 5 and 6, a normal admitted docs PR followed by the read-only convergence assertion from a clean `main`. Stable docs must never claim an unpublished version, so they cannot land in the phase-1 change. Prerelease behavior is unchanged: prerelease notes may land before publish while stable docs keep naming the prior stable version.
42
42
 
43
43
  1. Bump `package.json` to valid SemVer. The assertion derives its expected stable or prerelease channel from the version; it accepts no channel flag. Before publishing, prove production HQ accepts this candidate's proof schema. The manifest bump triggers the CI-only `HQ Deploy` workflow because HQ bundles this package's public schemas. From a clean `main`, record `RELEASE_SHA="$(git rev-parse HEAD)"`, find the `HQ Deploy` run with `gh run list --workflow "HQ Deploy" --commit "$RELEASE_SHA"`, and use `gh run watch <run-id> --exit-status`; an older green deployment does not count. One exception is defined: when the version bump merged earlier inside the release boundary and the release-owning PR touches no `HQ Deploy` path, no run can exist at the release SHA. The gate then binds to the most recent merge that modified an `HQ Deploy`-triggering path; that run must be green at its exact SHA, every later merge up to the release SHA must be outside those paths, and the release notes record which SHA satisfied the gate. Then, outside a sandbox, run `psf hq:flush --cwd <candidate-worktree>` against the candidate's retained `pr-verify-proof`. The release may proceed only when the current proof exists, the exact-SHA deployment passed, and the drain reports that proof `delivered` or `duplicate` (or no pending spool because its original delivery already succeeded), with `rejected 0` and no event remaining. This is an attended release-compatibility gate; it does not make HQ authoritative for ordinary admission.
44
- 2. Build and review one pnpm tarball, then publish that exact tarball with `pnpm release:publish` per the [repository operations runbook](../docs/repository-operations.md#publishing). The command is attended: it asks for the exact `name@version` before it publishes. Publishing the workspace directory is not allowed because it rebuilds during `prepack` after the artifact review, and the command refuses a directory. **Always pass `--tag` explicitly, on every publish, prerelease or stable**: `pnpm release:publish "$SOFTWARE_FACTORY_TARBALL" --tag next` for a prerelease, `--tag latest` for a stable cut. The command refuses a missing tag or one that disagrees with the version, checks that pnpm published the reviewed bytes, and reads the tag and integrity back from the registry. A filtered directory publish takes pnpm's recursive path, which passes its own `--tag` (defaulting to `latest`) to npm and therefore ignores the `publishConfig.tag: next` pin both factory packages carry; that is how 1.0.0-alpha.6 briefly took `latest` (#658). The pins stay as belt and braces, but they are not the control. For a raw `pnpm publish`, omitting the flag is not a safe failure: it moves `latest`, which the convergence assertion can only report after the fact. The attended token path does not promise an npm provenance attestation; the source SHA and reviewed tarball SRI are its operational provenance.
44
+ 2. Publish through the `Publish factory packages` workflow (dispatch on `main` with the exact version, review its dry run, then approve the `npm-release` environment), or, as the fallback, build and review one pnpm tarball, then publish that exact tarball with `pnpm release:publish` per the [repository operations runbook](../docs/repository-operations.md#publishing). The command is attended: it asks for the exact `name@version` before it publishes. Publishing the workspace directory is not allowed because it rebuilds during `prepack` after the artifact review, and the command refuses a directory. **Always pass `--tag` explicitly, on every publish, prerelease or stable**: `pnpm release:publish "$SOFTWARE_FACTORY_TARBALL" --tag next` for a prerelease, `--tag latest` for a stable cut. The command refuses a missing tag or one that disagrees with the version, checks that pnpm published the reviewed bytes, and reads the tag and integrity back from the registry. A filtered directory publish takes pnpm's recursive path, which passes its own `--tag` (defaulting to `latest`) to npm and therefore ignores the `publishConfig.tag: next` pin both factory packages carry; that is how 1.0.0-alpha.6 briefly took `latest` (#658). The pins stay as belt and braces, but they are not the control. For a raw `pnpm publish`, omitting the flag is not a safe failure: it moves `latest`, which the convergence assertion can only report after the fact. The attended token path does not promise an npm provenance attestation; the source SHA and reviewed tarball SRI are its operational provenance.
45
45
  3. Cut the `software-factory-vX.Y.Z` tag and push it.
46
46
  4. Cut the GitHub release for that tag, with notes covering features, deletions, breaking changes, and closed issues. Mark it as a prerelease exactly when its SemVer version has a prerelease component. When the release changes the profile `schemaVersion`, state it in the notes — the profile schema version is a separate axis from the package version.
47
47
  5. Converge the stable docs after publication. Update affected `software-factory-docs/` pages through a normal admitted docs PR. Stable docs must state the current stable version. Prerelease docs may record the candidate and its migration notes, but must not represent it as the current stable release.
@@ -77,3 +77,30 @@ npx skills add https://github.com/patronage/software-factory -g --all
77
77
  They provide procedure and link back to the documentation site; they are not a second command reference.
78
78
 
79
79
  `assembleReviewPrompt` puts a repository-root `CODING_STANDARDS.md` into the correctness prompt when the file exists and is not blank. It reads the file at the candidate head, not from the working tree, and emits one `coding-standards` section that names the head SHA. A repository without the file gets an unchanged prompt. `pr:review --assemble` writes that factory-owned prompt under `.factory-memory/pr-review-prompt.json`. `pr:review --findings` copies the recorded sections onto the proof when the artifact's patch-id matches.
80
+
81
+ ## Cloud credential adapters
82
+
83
+ The `@patronage/software-factory/cloud` subpath provides `cloudCredentialEnvironment(env, references)` and `readCloudSecret(ref, env)`. Repository adapters supply an explicit map from child environment variable names to reviewed `op://vault/item/field` references. The module supplies no vault, item, runtime, command or deployment defaults. It uses only `op-fast item get`, keeps values in memory, suppresses resolver output in errors, and strips 1Password authority, reference variables and unrelated Factory HQ/D1/npm credentials from the returned child environment. The caller's environment is unchanged. This is credential delivery, not a general environment sandbox.
84
+
85
+ ```js
86
+ import { spawnSync } from "node:child_process";
87
+
88
+ import { cloudCredentialEnvironment } from "@patronage/software-factory/cloud";
89
+
90
+ // Repository-owned policy selects its runtime and approved item references.
91
+ const env = cloudCredentialEnvironment(process.env, {
92
+ CF_ACCESS_CLIENT_ID: process.env.FACTORY_HQ_CLIENT_ID_REF,
93
+ CF_ACCESS_CLIENT_SECRET: process.env.FACTORY_HQ_CLIENT_SECRET_REF,
94
+ });
95
+ const result = spawnSync("psf", ["doctor", "--preflight"], {
96
+ env,
97
+ stdio: "inherit",
98
+ });
99
+ process.exitCode = result.status ?? 1;
100
+ ```
101
+
102
+ Install tools without credentials during the environment build, after the repository's own dependency installation. Resolve the shipped installer with `import.meta.resolve("@patronage/software-factory/cloud/install-tools.sh")`, convert that file URL with `fileURLToPath`, and run it through Bash with an absolute bin directory argument. It installs checksum-pinned Linux binaries; macOS, unsupported architectures and archive mismatches fail closed. Put that bin directory on the runtime PATH using the repository's existing setup path. Never resolve secrets during the build or write resolved values to shell profiles or hook export files. The module needs Node 24 and a runtime `OP_SERVICE_ACCOUNT_TOKEN`; it does not install tools or select a runtime.
103
+
104
+ These exports ship from `1.0.0-alpha.47`; `1.0.0-alpha.46` and earlier do not have them. Consumer adoption must pin alpha.47 or later and validate its packed artifact before changing live startup paths. See the source repository's `docs/agents/cloud-setup.md` for Factory-only rollout policy and acceptance.
105
+
106
+ `@patronage/software-factory/cloud/run.sh` (from `1.0.0-alpha.48`) is the launcher for Factory commands in a Claude cloud project thread, which runs no repository `SessionStart` hook: `bash node_modules/@patronage/software-factory/dist/cloud/run.sh <command>`. It sets `FACTORY_SESSION_ID` and the HQ relay settings when the egress proxy injects HQ access, and puts the packaged `gh` shim (HQ read relay for GraphQL, REST and proxy routes for writes) first on `PATH` for that one command. It installs nothing and reads no credential value. See the docs site's "Admit from a Claude cloud thread" page for what a consumer repository adds.
@@ -0,0 +1,21 @@
1
+ /** Explicit, reviewed repository policy: child environment key to op:// reference. */
2
+ export type CloudCredentialReferences = Readonly<Record<string, string>>;
3
+ export type CloudEnvironment = Record<string, string | undefined>;
4
+ export type CloudSecretReader = (
5
+ reference: string,
6
+ env: CloudEnvironment
7
+ ) => string;
8
+ export declare class CloudSecretError extends Error {
9
+ readonly name = "CloudSecretError";
10
+ }
11
+ /** op-fast item get; no kernel keyring, stock-op fallback, or output diagnostics. */
12
+ export function readCloudSecret(
13
+ reference: string,
14
+ env: CloudEnvironment
15
+ ): string;
16
+ /** Resolves selected credentials in memory, strips vault and unrelated provider authority. */
17
+ export function cloudCredentialEnvironment(
18
+ env: CloudEnvironment,
19
+ credentials: CloudCredentialReferences,
20
+ read?: CloudSecretReader
21
+ ): CloudEnvironment;
@@ -0,0 +1,136 @@
1
+ // Shared cloud credential mechanics. Callers own references and runtime policy.
2
+ import { spawnSync } from "node:child_process";
3
+
4
+ export class CloudSecretError extends Error {
5
+ name = "CloudSecretError";
6
+ }
7
+
8
+ // Capture both streams: resolver errors can quote secret material. Never attach
9
+ // an underlying error/cause or include captured output in a diagnostic.
10
+ export function readCloudSecret(reference, env) {
11
+ if (!env.OP_SERVICE_ACCOUNT_TOKEN) {
12
+ throw new CloudSecretError(
13
+ "Cloud credentials require OP_SERVICE_ACCOUNT_TOKEN."
14
+ );
15
+ }
16
+ const match =
17
+ /^op:\/\/(?<vault>[^/\r\n]+)\/(?<item>[^/\r\n]+)\/(?<field>[^/\r\n]+)$/u.exec(
18
+ reference
19
+ );
20
+ if (!match?.groups) {
21
+ throw new CloudSecretError("Invalid cloud credential reference.");
22
+ }
23
+ const { vault, item, field } = match.groups;
24
+ const resolverEnv = {
25
+ ...Object.fromEntries(
26
+ Object.entries(env).filter(
27
+ ([key]) =>
28
+ !key.startsWith("OP_SESSION") &&
29
+ !["OP_ACCOUNT", "OP_CONNECT_HOST", "OP_CONNECT_TOKEN"].includes(key)
30
+ )
31
+ ),
32
+ OP_BIOMETRIC_UNLOCK_ENABLED: "false",
33
+ };
34
+ let result;
35
+ try {
36
+ result = spawnSync(
37
+ "op-fast",
38
+ ["item", "get", item, "--vault", vault, "--format=json"],
39
+ {
40
+ encoding: "utf-8",
41
+ env: resolverEnv,
42
+ maxBuffer: 256 * 1024,
43
+ stdio: ["ignore", "pipe", "pipe"],
44
+ timeout: 10_000,
45
+ }
46
+ );
47
+ } catch {
48
+ throw new CloudSecretError(
49
+ "Cloud credential resolution failed; check op-fast, vault access and network access."
50
+ );
51
+ }
52
+ let value;
53
+ try {
54
+ const { fields } = JSON.parse(result.stdout);
55
+ const matches = fields.filter(
56
+ (candidate) => candidate.id === field || candidate.label === field
57
+ );
58
+ if (matches.length === 1) {
59
+ [{ value }] = matches;
60
+ }
61
+ } catch {
62
+ // Malformed provider output must not be included in a diagnostic.
63
+ }
64
+ if (
65
+ result.error ||
66
+ result.status !== 0 ||
67
+ typeof value !== "string" ||
68
+ !value ||
69
+ value.startsWith("op://") ||
70
+ /[\r\n\0]/u.test(value)
71
+ ) {
72
+ throw new CloudSecretError(
73
+ "Cloud credential resolution failed; check op-fast, vault access and network access."
74
+ );
75
+ }
76
+ return value;
77
+ }
78
+
79
+ // Resolve only explicitly selected references and hand a consuming child no
80
+ // vault authority or unrelated Factory provider credentials. No defaults here:
81
+ // vault/item choices and the command/purpose decision belong to the repository.
82
+ export function cloudCredentialEnvironment(
83
+ env,
84
+ credentials,
85
+ read = readCloudSecret
86
+ ) {
87
+ if (!env.OP_SERVICE_ACCOUNT_TOKEN) {
88
+ throw new CloudSecretError(
89
+ "Cloud credentials require OP_SERVICE_ACCOUNT_TOKEN."
90
+ );
91
+ }
92
+ if (env.OP_CONNECT_HOST || env.OP_CONNECT_TOKEN) {
93
+ throw new CloudSecretError(
94
+ "Remove 1Password Connect settings before using the cloud service account."
95
+ );
96
+ }
97
+ const entries = Object.entries(credentials);
98
+ if (
99
+ !entries.length ||
100
+ entries.some(
101
+ ([key, ref]) =>
102
+ !key ||
103
+ key.startsWith("OP_") ||
104
+ /^FACTORY_.*_REF$/u.test(key) ||
105
+ !/^op:\/\/[^/\r\n]+\/[^/\r\n]+\/[^/\r\n]+$/u.test(ref)
106
+ )
107
+ ) {
108
+ throw new CloudSecretError(
109
+ "Cloud credentials require explicit environment keys and op:// references."
110
+ );
111
+ }
112
+ const unrelatedCredentials = new Set([
113
+ // Legacy repository tools also read the HTTP header names from env.
114
+ "CF-Access-Client-Id",
115
+ "CF-Access-Client-Secret",
116
+ "CF_ACCESS_CLIENT_ID",
117
+ "CF_ACCESS_CLIENT_SECRET",
118
+ "CLOUDFLARE_API_TOKEN",
119
+ "CLOUDFLARE_READ_ONLY_API_TOKEN",
120
+ "NPM_TOKEN",
121
+ "NODE_AUTH_TOKEN",
122
+ "npm_config_//registry.npmjs.org/:_authToken",
123
+ ]);
124
+ const child = Object.fromEntries(
125
+ Object.entries(env).filter(
126
+ ([key]) =>
127
+ !key.startsWith("OP_") &&
128
+ !/^FACTORY_.*_REF$/u.test(key) &&
129
+ !unrelatedCredentials.has(key)
130
+ )
131
+ );
132
+ for (const [key, ref] of entries) {
133
+ child[key] = read(ref, env);
134
+ }
135
+ return child;
136
+ }