@patronage/factory-ci 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +713 -11
- package/dist/.build-fingerprint.json +3 -0
- package/dist/alchemy/index.d.ts +1174 -0
- package/dist/alchemy/index.js +2142 -0
- package/dist/bundle-alchemy-entry-CT5hCphA.js +112 -0
- package/dist/execute-alchemy-entry-B0lBN-YZ.js +160 -0
- package/dist/execute-alchemy-entry-B397GSk5.d.ts +134 -0
- package/dist/index.d.ts +1218 -93
- package/dist/index.js +2841 -333
- package/package.json +28 -10
- package/src/actions.ts +13 -0
- package/src/alchemy/child-diagnostics.ts +148 -0
- package/src/alchemy/credential-preflight.ts +428 -0
- package/src/alchemy/destroy-postcondition.ts +103 -0
- package/src/alchemy/evaluate-stack.ts +153 -0
- package/src/alchemy/first-deploy-authorization.ts +194 -0
- package/src/alchemy/index.ts +144 -0
- package/src/alchemy/lifecycle-failure.ts +174 -0
- package/src/alchemy/lifecycle.ts +1330 -0
- package/src/alchemy/local-emulation.ts +89 -0
- package/src/alchemy/plan-effects.ts +510 -0
- package/src/alchemy/retained-identity.ts +248 -0
- package/src/alchemy/secret-name-policy.ts +96 -0
- package/src/alchemy/stage-policy.ts +269 -0
- package/src/alchemy/state-tree.ts +168 -0
- package/src/alchemy/url-implies-auth.ts +264 -0
- package/src/alchemy-baseline.ts +75 -0
- package/src/bundle-alchemy-entry.ts +5 -0
- package/src/candidate-impact-workflow.ts +110 -0
- package/src/candidate-lifecycle.ts +29 -0
- package/src/cursor-oidc.ts +33 -0
- package/src/execute-alchemy-entry.ts +128 -8
- package/src/factory-workflow.ts +83 -40
- package/src/github-app-token.ts +131 -22
- package/src/github-transport.ts +186 -0
- package/src/impact-demand-condition.ts +67 -0
- package/src/index.ts +174 -0
- package/src/lifecycle-contract-lane.ts +113 -0
- package/src/merge-freeze-job.ts +253 -0
- package/src/pinned-action.ts +30 -0
- package/src/pr-status-hud-workflow.ts +96 -0
- package/src/preview-cleanup-topology.ts +115 -0
- package/src/preview-proof-inventory.ts +1092 -0
- package/src/preview-proof-lifecycle.ts +328 -0
- package/src/preview-receipt-workflow.ts +83 -0
- package/src/production-impact-workflow.ts +181 -0
- package/src/proof-reuse-gate.ts +297 -63
- package/src/proof-reuse-presentation.ts +131 -0
- package/src/push-identity-workflow.ts +463 -0
- package/src/runnable-cli.ts +27 -0
- package/src/verify-runner-policy.ts +290 -0
- package/src/vitest-profile-reader.test.ts +208 -0
- package/src/vitest-profile-reader.ts +225 -0
- package/src/vitest-profile.ts +631 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lifecycle failure envelope (#1077).
|
|
3
|
+
*
|
|
4
|
+
* Every failure `runAlchemyLifecycle` raises is one of these. The code, the
|
|
5
|
+
* phase, and the mutation certainty are enumerated; the message is a fixed
|
|
6
|
+
* sentence looked up by code. Nothing a child process printed, nothing a
|
|
7
|
+
* state store said, and nothing a credential resolver quoted ever reaches
|
|
8
|
+
* the message, and no failure carries a `cause`. Evidence sinks (`--json`,
|
|
9
|
+
* the job summary) can print any field of this error verbatim. The one thing
|
|
10
|
+
* a failure may say about a child's output is where a consumer asked for it
|
|
11
|
+
* to be written (`childDiagnosticsPath`), which is a path the consumer chose
|
|
12
|
+
* and never the output.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export type AlchemyLifecycleOperation = "plan" | "deploy" | "destroy";
|
|
16
|
+
|
|
17
|
+
/** Where in the sequence the failure was raised. */
|
|
18
|
+
export type AlchemyLifecyclePhase =
|
|
19
|
+
/** The request itself or the policy is malformed. */
|
|
20
|
+
| "request"
|
|
21
|
+
/** A pre-mutation check refused the operation. */
|
|
22
|
+
| "admission"
|
|
23
|
+
/** The state store could not be read or owned. */
|
|
24
|
+
| "state"
|
|
25
|
+
/** The Alchemy child failed. */
|
|
26
|
+
| "execution"
|
|
27
|
+
/** A check after the child ran did not hold. */
|
|
28
|
+
| "postcondition";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* What the failure says about the target stage. `not-started` means no
|
|
32
|
+
* child ran. `read-only-started` means only a planning child ran: no child
|
|
33
|
+
* that can mutate was started. `mutation-may-have-occurred` means a deploy
|
|
34
|
+
* or destroy child was started, so the stage may differ from before.
|
|
35
|
+
*/
|
|
36
|
+
export type MutationCertainty =
|
|
37
|
+
| "not-started"
|
|
38
|
+
| "read-only-started"
|
|
39
|
+
| "mutation-may-have-occurred";
|
|
40
|
+
|
|
41
|
+
export type AlchemyLifecycleFailureCode =
|
|
42
|
+
| "INVALID_REQUEST"
|
|
43
|
+
| "INVALID_POLICY"
|
|
44
|
+
| "UNSUPPORTED_ALCHEMY_VERSION"
|
|
45
|
+
| "UNKNOWN_STAGE"
|
|
46
|
+
| "AMBIGUOUS_STAGE"
|
|
47
|
+
| "PROTECTED_STAGE"
|
|
48
|
+
| "UNKNOWN_STACK"
|
|
49
|
+
| "STAGE_NOT_OWNED"
|
|
50
|
+
| "PREPARATION_FAILED"
|
|
51
|
+
| "STAGE_HELD"
|
|
52
|
+
| "OWNERSHIP_LOST"
|
|
53
|
+
| "LEASE_RELEASE_FAILED"
|
|
54
|
+
| "STATE_STORE_UNAVAILABLE"
|
|
55
|
+
| "STATE_STORE_INVALID"
|
|
56
|
+
| "STATE_CHANGED"
|
|
57
|
+
| "RESOURCE_IDENTITY_MISMATCH"
|
|
58
|
+
| "FIRST_DEPLOY_UNAUTHORIZED"
|
|
59
|
+
| "EFFECT_NOT_PERMITTED"
|
|
60
|
+
| "UNKNOWN_EFFECT"
|
|
61
|
+
| "AMBIGUOUS_RESOURCE"
|
|
62
|
+
| "CHILD_FAILED"
|
|
63
|
+
| "CHILD_DIAGNOSTICS_UNWRITABLE"
|
|
64
|
+
| "DEPLOY_INCOMPLETE"
|
|
65
|
+
| "NOT_CONVERGED"
|
|
66
|
+
| "DESTROY_RESIDUE";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The one sentence each code is reported with. The table is the whole
|
|
70
|
+
* vocabulary: a message that is not in it cannot be raised.
|
|
71
|
+
*/
|
|
72
|
+
export const LIFECYCLE_FAILURE_MESSAGES: Readonly<
|
|
73
|
+
Record<AlchemyLifecycleFailureCode, string>
|
|
74
|
+
> = {
|
|
75
|
+
AMBIGUOUS_RESOURCE:
|
|
76
|
+
"The plan prints one resource id for more than one resource.",
|
|
77
|
+
AMBIGUOUS_STAGE:
|
|
78
|
+
"The stage table declares the stage both protected and disposable.",
|
|
79
|
+
CHILD_DIAGNOSTICS_UNWRITABLE:
|
|
80
|
+
"The requested child diagnostics file could not be written.",
|
|
81
|
+
CHILD_FAILED: "The Alchemy child did not exit successfully.",
|
|
82
|
+
DEPLOY_INCOMPLETE:
|
|
83
|
+
"The deploy completed without the persisted state its plan described.",
|
|
84
|
+
DESTROY_RESIDUE: "The destroy left persisted state registered for the stage.",
|
|
85
|
+
EFFECT_NOT_PERMITTED:
|
|
86
|
+
"The plan holds a resource effect the policy does not permit.",
|
|
87
|
+
FIRST_DEPLOY_UNAUTHORIZED:
|
|
88
|
+
"The first deploy of the stage is not authorized for this plan.",
|
|
89
|
+
INVALID_POLICY: "The lifecycle policy is malformed.",
|
|
90
|
+
INVALID_REQUEST: "The lifecycle request is malformed.",
|
|
91
|
+
LEASE_RELEASE_FAILED:
|
|
92
|
+
"The stage lease could not be released and may still be held.",
|
|
93
|
+
NOT_CONVERGED: "The post-deploy plan is not a no-op.",
|
|
94
|
+
OWNERSHIP_LOST: "The stage ownership lease was lost during the operation.",
|
|
95
|
+
PREPARATION_FAILED: "The Alchemy entry could not be prepared.",
|
|
96
|
+
PROTECTED_STAGE: "The stage is protected and refuses destructive operations.",
|
|
97
|
+
RESOURCE_IDENTITY_MISMATCH:
|
|
98
|
+
"A retained resource identity does not hold for the stage.",
|
|
99
|
+
STAGE_HELD: "Another holder owns the stage.",
|
|
100
|
+
STAGE_NOT_OWNED: "The stack does not own the stage.",
|
|
101
|
+
STATE_CHANGED: "Persisted state changed during a read-only operation.",
|
|
102
|
+
STATE_STORE_INVALID: "The state store returned state that cannot be read.",
|
|
103
|
+
STATE_STORE_UNAVAILABLE: "The state store could not be read.",
|
|
104
|
+
UNKNOWN_EFFECT: "The Alchemy output holds an effect the adapter cannot read.",
|
|
105
|
+
UNKNOWN_STACK: "The stack is not in the stage table.",
|
|
106
|
+
UNKNOWN_STAGE: "The stage is not in the stage table.",
|
|
107
|
+
UNSUPPORTED_ALCHEMY_VERSION:
|
|
108
|
+
"The installed Alchemy is not the version this adapter reads.",
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export interface AlchemyLifecycleFailureFields {
|
|
112
|
+
/**
|
|
113
|
+
* The file the run's child output was being written to, on a child
|
|
114
|
+
* failure of a run that asked for one. It is a path, so an operator knows
|
|
115
|
+
* where to look; the output itself is never here and never in the message.
|
|
116
|
+
*/
|
|
117
|
+
readonly childDiagnosticsPath?: string;
|
|
118
|
+
readonly code: AlchemyLifecycleFailureCode;
|
|
119
|
+
readonly mutation: MutationCertainty;
|
|
120
|
+
readonly operation: AlchemyLifecycleOperation;
|
|
121
|
+
readonly phase: AlchemyLifecyclePhase;
|
|
122
|
+
/**
|
|
123
|
+
* The reviewed plan hash, on `FIRST_DEPLOY_UNAUTHORIZED` only. It is the
|
|
124
|
+
* value an operator authorizes, and it is a hash, never plan text.
|
|
125
|
+
*/
|
|
126
|
+
readonly planHash?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** A sanitized lifecycle failure. See the module comment. */
|
|
130
|
+
export class AlchemyLifecycleError
|
|
131
|
+
extends Error
|
|
132
|
+
implements AlchemyLifecycleFailureFields
|
|
133
|
+
{
|
|
134
|
+
readonly childDiagnosticsPath?: string;
|
|
135
|
+
readonly code: AlchemyLifecycleFailureCode;
|
|
136
|
+
readonly mutation: MutationCertainty;
|
|
137
|
+
readonly operation: AlchemyLifecycleOperation;
|
|
138
|
+
readonly phase: AlchemyLifecyclePhase;
|
|
139
|
+
readonly planHash?: string;
|
|
140
|
+
|
|
141
|
+
constructor(fields: AlchemyLifecycleFailureFields) {
|
|
142
|
+
super(LIFECYCLE_FAILURE_MESSAGES[fields.code]);
|
|
143
|
+
this.name = "AlchemyLifecycleError";
|
|
144
|
+
this.code = fields.code;
|
|
145
|
+
this.mutation = fields.mutation;
|
|
146
|
+
this.operation = fields.operation;
|
|
147
|
+
this.phase = fields.phase;
|
|
148
|
+
if (fields.childDiagnosticsPath !== undefined) {
|
|
149
|
+
this.childDiagnosticsPath = fields.childDiagnosticsPath;
|
|
150
|
+
}
|
|
151
|
+
if (fields.planHash !== undefined) {
|
|
152
|
+
this.planHash = fields.planHash;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The fields an evidence sink prints. Fixed shape, fixed words. */
|
|
157
|
+
toJSON(): AlchemyLifecycleFailureFields & { readonly message: string } {
|
|
158
|
+
return {
|
|
159
|
+
...(this.childDiagnosticsPath === undefined
|
|
160
|
+
? {}
|
|
161
|
+
: { childDiagnosticsPath: this.childDiagnosticsPath }),
|
|
162
|
+
code: this.code,
|
|
163
|
+
message: this.message,
|
|
164
|
+
mutation: this.mutation,
|
|
165
|
+
operation: this.operation,
|
|
166
|
+
phase: this.phase,
|
|
167
|
+
...(this.planHash === undefined ? {} : { planHash: this.planHash }),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export const isAlchemyLifecycleError = (
|
|
173
|
+
error: unknown
|
|
174
|
+
): error is AlchemyLifecycleError => error instanceof AlchemyLifecycleError;
|