@raindancers/raindancers-crew 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # @raindancers/raindancers-crew
2
+
3
+ A CDK construct that provisions a **self-hosted [KiroCrew](https://github.com/kirodotdev/KiroCrew) gateway** on a single EC2 instance in your own AWS account, reached over **SSM Session Manager** — no inbound ports, no SSH key.
4
+
5
+ It is a pipeline-native, version-controlled port of the upstream `kirocrew-ec2` CloudFormation template. Where the native `kirocrew cloud launch` is an imperative one-shot, this construct lets you deploy the same shape **through your own CDK pipeline**, under **your** naming, permissions boundary, and OIDC deploy role — so a remote crew becomes a reviewed, repeatable, diffable artifact like everything else you ship.
6
+
7
+ ## Getting started
8
+
9
+ ### 1. Install
10
+
11
+ ```bash
12
+ npm install @raindancers/raindancers-crew
13
+ ```
14
+
15
+ The package targets `aws-cdk-lib` ^2.260.0 and `constructs` ^10 (peer dependencies — your app supplies them).
16
+
17
+ ### 2. Define a stack
18
+
19
+ A complete stack that stands up an EC2 crew with off-box backup. Everything is
20
+ typed and compiles as-is — fill in your account, region, VPC lookup, and
21
+ permissions-boundary ARN.
22
+
23
+ ```ts
24
+ import { App, Stack, StackProps } from 'aws-cdk-lib';
25
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
26
+ import { Construct } from 'constructs';
27
+ import {
28
+ RemoteCrewInstance,
29
+ CrewArchitecture,
30
+ CrewBackupBucket,
31
+ } from '@raindancers/raindancers-crew';
32
+
33
+ class CrewStack extends Stack {
34
+ constructor(scope: Construct, id: string, props: StackProps) {
35
+ super(scope, id, props);
36
+
37
+ // Your existing VPC (or ec2.Vpc.fromLookup(...)).
38
+ const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
39
+
40
+ // Durable, versioned, KMS-encrypted backup destination.
41
+ const backup = new CrewBackupBucket(this, 'CrewBackup');
42
+
43
+ new RemoteCrewInstance(this, 'Crew', {
44
+ vpc,
45
+ // REQUIRED: the instance runs a prompt-injectable agent, so its role
46
+ // must be capped by a permissions boundary you pre-create.
47
+ permissionsBoundaryArn:
48
+ 'arn:aws:iam::123456789012:policy/kirocrew-ec2-boundary',
49
+ architecture: CrewArchitecture.ARM64,
50
+ instanceType: new ec2.InstanceType('m7g.2xlarge'),
51
+ // Pin a released tag for reproducible deploys — the default `main` drifts.
52
+ source: { kirocrewRef: 'v0.8.0' },
53
+ // Off-box backup: grants scoped write + installs a daily snapshot timer.
54
+ backupBucket: backup,
55
+ backupSchedule: 'daily',
56
+ });
57
+ }
58
+ }
59
+
60
+ const app = new App();
61
+ new CrewStack(app, 'RemoteCrew', {
62
+ env: { account: '123456789012', region: 'eu-west-2' },
63
+ });
64
+ app.synth();
65
+ ```
66
+
67
+ ### 3. Deploy through your pipeline
68
+
69
+ This is a plain CDK stack — deploy it however you deploy everything else
70
+ (a CDK Pipelines / agentl stage, or `cdk deploy` from a keyless-OIDC CI job).
71
+ The `WaitCondition` blocks stack completion until the gateway is actually
72
+ serving, so a green deploy means a live crew (and a failed bootstrap rolls the
73
+ stack back with the setup-log tail in the failure reason).
74
+
75
+ ```bash
76
+ cdk deploy RemoteCrew
77
+ ```
78
+
79
+ ### 4. Connect
80
+
81
+ Access is **SSM-only** — no inbound ports. Open a port-forward to the
82
+ loopback dashboard and browse `http://127.0.0.1:5476`:
83
+
84
+ ```bash
85
+ # The construct exports the instance id under a stable name derived from the
86
+ # stackTag (default 'kirocrew'): kirocrew-<stackTag>-instance-id
87
+ INSTANCE_ID=$(aws cloudformation list-exports \
88
+ --query "Exports[?Name=='kirocrew-kirocrew-instance-id'].Value" --output text)
89
+
90
+ aws ssm start-session --target "$INSTANCE_ID" \
91
+ --document-name AWS-StartPortForwardingSession \
92
+ --parameters '{"portNumber":["5476"],"localPortNumber":["5476"]}'
93
+ ```
94
+
95
+ (Or use the upstream `kirocrew cloud connect`, which mints the dashboard token
96
+ on the box and opens the tunnel for you.)
97
+
98
+ ### 5. Verify backup
99
+
100
+ The daily timer pushes a redaction-scrubbed snapshot to the backup bucket. Fire
101
+ one immediately and confirm it landed:
102
+
103
+ ```bash
104
+ # On the instance (via SSM Session Manager):
105
+ sudo systemctl start kirocrew-backup.service
106
+ sudo journalctl -u kirocrew-backup.service --no-pager | tail
107
+
108
+ # From your workstation — the stable key a replacement instance restores from:
109
+ aws s3 ls "s3://<backup-bucket>/crew-snapshots/latest.tar"
110
+ ```
111
+
112
+ To rebuild a **replacement** instance from backup, deploy a fresh `CrewStack`
113
+ pointing at the same bucket, then on the new box run
114
+ `sudo kirocrew-restore-from-s3` (pulls `latest.tar`, stops the gateway,
115
+ restores in replace mode, restarts).
116
+
117
+ > **Container crew instead of an instance?** See [Fargate lane](#fargate-lane)
118
+ > below — swap `RemoteCrewInstance` for `FargateCrewBase` + `FargateCrew`.
119
+
120
+ The sections below are the per-construct reference.
121
+
122
+ ## What it creates
123
+
124
+ | Resource | Notes |
125
+ |---|---|
126
+ | IAM role + instance profile | `AmazonSSMManagedInstanceCore` + a **required permissions boundary**; scoped `s3:GetObject` only when an S3 source is used |
127
+ | Security group | **No inbound** by default (SSM-only); optional `tcp/22` from `allowSshCidr` (≤ /16); optional webhook port from a single source SG via `webhookIngress`; IPv6 egress when `enableIpv6` |
128
+ | EC2 instance | Amazon Linux 2023, arch-aware AMI, **IMDSv2 enforced**, **encrypted gp3** root |
129
+ | WaitConditionHandle + WaitCondition | Blocks stack completion until the gateway is actually serving on the loopback dashboard port |
130
+
131
+ ## Security posture (preserved from upstream)
132
+
133
+ - **SSM-only access.** No inbound rules unless you explicitly pass `allowSshCidr`. Access is via SSM port-forward; the public DNS is diagnostics only.
134
+ - **IMDSv2 required, hop limit 1.** KiroCrew runs a prompt-injectable agent that executes arbitrary tools — an SSRF/injection reaching the metadata endpoint must not be able to read the role's STS credentials via IMDSv1.
135
+ - **Permissions boundary is mandatory** on the instance role.
136
+ - **Node.js tarball is SHA-256-pinned** and verified before root extraction.
137
+ - **Encrypted EBS root.**
138
+
139
+ ## Private dual-stack brain (55minutes posture)
140
+
141
+ For an always-on brain that egresses over IPv6 with **no public IPv4**, is woken
142
+ by the native KiroCrew webhook, and runs as an autopilot crew that never
143
+ idle-closes, compose the additive props below. Everything here is optional and
144
+ defaults off — omit it all and you get the SSM-only public-subnet box above.
145
+
146
+ ```ts
147
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
148
+ import { RemoteCrewInstance, CrewArchitecture } from '@raindancers/raindancers-crew';
149
+
150
+ // vpc: a dual-stack VPC whose private subnets carry IPv6 CIDRs and route
151
+ // ::/0 to an Egress-Only Internet Gateway (see "What stays yours" below).
152
+ // ingestLambdaSg: the SG of the consumer's ingest Lambda / reverse proxy —
153
+ // imported, this construct never creates it.
154
+ new RemoteCrewInstance(this, 'Brain', {
155
+ vpc,
156
+ permissionsBoundaryArn:
157
+ 'arn:aws:iam::123456789012:policy/kirocrew-ec2-boundary',
158
+ architecture: CrewArchitecture.ARM64,
159
+ source: { kirocrewRef: 'v0.8.0' },
160
+
161
+ // Private + dual-stack: IPv6 egress, no public IPv4.
162
+ vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
163
+ associatePublicIp: false,
164
+ enableIpv6: true,
165
+
166
+ // Webhook reach from ONE source SG only (never a CIDR), authenticated by a
167
+ // Bearer token fetched from Secrets Manager at boot (written to config.json
168
+ // as hooks.webhook_token; the instance role gets GetSecretValue on this ARN).
169
+ webhookIngress: { source: ingestLambdaSg },
170
+ webhookTokenSecretArn:
171
+ 'arn:aws:secretsmanager:eu-west-2:123456789012:secret:kc/webhook-token-AbCdEf',
172
+
173
+ // Always-on: autopilot + never idle-close.
174
+ crewRuntime: { autopilot: true, disableIdleClose: true },
175
+ });
176
+ ```
177
+
178
+ ### What stays yours (this construct provisions none of it)
179
+
180
+ `RemoteCrewInstance` consumes an `IVpc` and provisions no routing, so these live
181
+ in your VPC / app, not the library:
182
+
183
+ - **Egress-Only Internet Gateway** and the `::/0` IPv6 egress route — the VPC's
184
+ concern. `enableIpv6` assigns the instance an IPv6 address and opens IPv6
185
+ egress on its SG, but the route to the internet is yours.
186
+ - **fck-nat (or managed NAT)** for any IPv4 egress you still need.
187
+ - **The ingest Lambda and its security group** — you build it and pass its SG as
188
+ `webhookIngress.source`. The construct only accepts it.
189
+ - **Routable exposure of the webhook.** The KiroCrew gateway binds `127.0.0.1`
190
+ only (it has no routable listener), so `webhookIngress` opens the SG but a
191
+ **consumer-owned reverse proxy or SSH tunnel on the box** is what actually
192
+ forwards `POST /api/hooks/agent` from the source SG to the loopback gateway.
193
+ The dashboard stays loopback/SSM-only regardless.
194
+
195
+ ## Connecting
196
+
197
+ `RemoteCrewInstance` provisions the box; **connection stays an operator action** (it is inherently imperative — mint a short-lived token on the instance and open an SSM port-forward). Use the upstream `kirocrew cloud connect` against the deployed instance id, or your own SSM `start-session` / port-forward wrapper.
198
+
199
+ ## Fargate lane
200
+
201
+ For a container-based crew there are two sibling constructs, mirroring the upstream `kirocrew-fargate-base` + `kirocrew-fargate-crew` split:
202
+
203
+ - **`FargateCrewBase`** — one per account/region: the ECS cluster crew tasks run on plus an egress-only (no-inbound) task security group. Deleting a crew must not delete the shared cluster, so this is separate.
204
+ - **`FargateCrew`** — one per crew: the execution role (secret read scoped to `kirocrew/crew/<crew>/*`, log write, optional private-ECR pull), the **zero-policy task role** (the running container's blast radius — it must never gain `secretsmanager:GetSecretValue`), and the crew's log group. All names are derived from the crew name.
205
+
206
+ ```ts
207
+ import { FargateCrewBase, FargateCrew } from '@raindancers/raindancers-crew';
208
+
209
+ const base = new FargateCrewBase(this, 'CrewBase', { vpc });
210
+ new FargateCrew(this, 'Crew', {
211
+ crew: 'fiftyfive',
212
+ // permissionsBoundaryArn: '...', // optional until the shared boundary creator lands
213
+ // ecrRepositoryArn: '...', // only for a private image; public registry needs no grant
214
+ });
215
+ ```
216
+
217
+ Security invariants preserved from upstream: task role has no policies and never reads secrets; execution-role secret read is crew-scoped with individually-listed actions (no prefix wildcards); both assume-role trusts carry an `aws:SourceAccount` condition. The permissions boundary is **optional** here (a declared degraded mode) because no creator for the crew boundary exists yet — unlike the EC2 lane, where it is mandatory.
218
+
219
+ **EC2 vs Fargate:** EC2 gives a persistent box with local disk (the crew's memory/knowledge DBs live on the instance) and is the native launcher's default; Fargate is more ephemeral and expects external persistence. For a remote crew that remembers across sessions, EC2 is usually the better fit.
220
+
221
+ ## Backing up the crew's learnings
222
+
223
+ A remote crew's value is its accumulated memory, lessons, and knowledge — which on the EC2 lane live on the instance's local disk. KiroCrew's built-in backup (`kirocrew snapshot`) produces a redaction-scrubbed bundle (the signing key, `.env`, and execution logs never ship), but writes it **locally** — so it survives corruption, not instance loss. These constructs add the missing **off-box durability**.
224
+
225
+ `CrewBackupBucket` provisions a hardened destination: SSE-KMS (rotating key), all public access blocked, TLS-only, **versioned**, with a lifecycle rule expiring stale noncurrent versions. Bucket and key `RETAIN` on stack delete, so the backups outlive a teardown.
226
+
227
+ ```ts
228
+ import { CrewBackupBucket, RemoteCrewInstance } from '@raindancers/raindancers-crew';
229
+
230
+ const backup = new CrewBackupBucket(this, 'CrewBackup');
231
+
232
+ new RemoteCrewInstance(this, 'Crew', {
233
+ vpc,
234
+ permissionsBoundaryArn: '...',
235
+ backupBucket: backup, // grants scoped write + installs a daily timer
236
+ backupSchedule: 'daily', // systemd OnCalendar
237
+ });
238
+ ```
239
+
240
+ On the **EC2 lane** this grants the instance role scoped write, installs a **systemd timer** that runs `kirocrew snapshot --purpose backup` and uploads the newest bundle to S3 (a timestamped key for history plus a stable `latest.tar`), and installs a `kirocrew-restore-from-s3` helper. On the **Fargate lane**, pass the same bucket to `FargateCrew` — it grants the **task role** (the running container) write, since the container runs its own snapshot push.
241
+
242
+ ### Restore (rebuilding a replacement crew)
243
+
244
+ `kirocrew restore <bundle> --mode replace|merge`:
245
+
246
+ - **replace** clears the target's memory/knowledge trees and rebuilds them from the bundle (the knowledge DB and memory stores are replaced wholesale, not row-merged). Restore validates database integrity and refuses a truncated bundle; `sel_hmac.key` is regenerated (not restored). Use on a fresh replacement instance.
247
+ - **merge** layers the bundle onto existing state without clearing. Use to seed a crew you want to keep.
248
+
249
+ On an EC2 instance provisioned with a backup bucket, `sudo kirocrew-restore-from-s3` pulls `latest.tar`, stops the gateway, restores in **replace** mode, and restarts — a one-command rebuild.
250
+
251
+ ## License
252
+
253
+ Apache-2.0
@@ -0,0 +1,62 @@
1
+ import { RemovalPolicy } from 'aws-cdk-lib';
2
+ import * as iam from 'aws-cdk-lib/aws-iam';
3
+ import * as kms from 'aws-cdk-lib/aws-kms';
4
+ import * as s3 from 'aws-cdk-lib/aws-s3';
5
+ import { Construct } from 'constructs';
6
+ import { ICrewBackupBucket } from './remote-crew-instance-props';
7
+ /**
8
+ * Properties for {@link CrewBackupBucket}.
9
+ */
10
+ export interface CrewBackupBucketProps {
11
+ /**
12
+ * Explicit bucket name. Omit to let CloudFormation generate one.
13
+ *
14
+ * @default - CloudFormation-generated
15
+ */
16
+ readonly bucketName?: string;
17
+ /**
18
+ * Days after which a NONCURRENT snapshot version is expired. Current
19
+ * versions are always kept. Set 0 to keep all versions forever.
20
+ *
21
+ * @default 90
22
+ */
23
+ readonly noncurrentVersionExpirationDays?: number;
24
+ /**
25
+ * What happens to the bucket when the stack is destroyed. Defaults to
26
+ * RETAIN — the whole point is that the crew's learnings outlive the
27
+ * instance, so the backup must outlive a stack teardown too.
28
+ *
29
+ * @default RemovalPolicy.RETAIN
30
+ */
31
+ readonly removalPolicy?: RemovalPolicy;
32
+ }
33
+ /**
34
+ * A hardened S3 bucket for KiroCrew snapshot backups.
35
+ *
36
+ * The snapshot bundle produced by `kirocrew snapshot --purpose backup` is
37
+ * already redaction-scrubbed (the signing key, `.env`, and execution logs
38
+ * never ship), so this stores portable crew state, not raw secrets. The bucket
39
+ * is nonetheless locked down as if it did: SSE-KMS at rest, all public access
40
+ * blocked, TLS-only access, versioned so an overwrite cannot destroy history,
41
+ * and a lifecycle rule that expires stale noncurrent versions.
42
+ *
43
+ * Use {@link grantWrite} to let an instance/task role push snapshots, and
44
+ * {@link grantRead} to let a replacement instance pull them for restore.
45
+ */
46
+ export declare class CrewBackupBucket extends Construct implements ICrewBackupBucket {
47
+ /** The backup bucket. */
48
+ readonly bucket: s3.IBucket;
49
+ /** The KMS key encrypting the bucket. */
50
+ readonly key: kms.Key;
51
+ constructor(scope: Construct, id: string, props?: CrewBackupBucketProps);
52
+ /**
53
+ * Grant a principal permission to WRITE snapshots (and the KMS encrypt it
54
+ * needs). Used by the crew instance/task role that pushes backups.
55
+ */
56
+ grantWrite(grantee: iam.IGrantable): void;
57
+ /**
58
+ * Grant a principal permission to READ snapshots (and the KMS decrypt it
59
+ * needs). Used by a replacement instance restoring from backup.
60
+ */
61
+ grantRead(grantee: iam.IGrantable): void;
62
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CrewBackupBucket = void 0;
37
+ const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
38
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
39
+ const kms = __importStar(require("aws-cdk-lib/aws-kms"));
40
+ const s3 = __importStar(require("aws-cdk-lib/aws-s3"));
41
+ const constructs_1 = require("constructs");
42
+ /**
43
+ * A hardened S3 bucket for KiroCrew snapshot backups.
44
+ *
45
+ * The snapshot bundle produced by `kirocrew snapshot --purpose backup` is
46
+ * already redaction-scrubbed (the signing key, `.env`, and execution logs
47
+ * never ship), so this stores portable crew state, not raw secrets. The bucket
48
+ * is nonetheless locked down as if it did: SSE-KMS at rest, all public access
49
+ * blocked, TLS-only access, versioned so an overwrite cannot destroy history,
50
+ * and a lifecycle rule that expires stale noncurrent versions.
51
+ *
52
+ * Use {@link grantWrite} to let an instance/task role push snapshots, and
53
+ * {@link grantRead} to let a replacement instance pull them for restore.
54
+ */
55
+ class CrewBackupBucket extends constructs_1.Construct {
56
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@raindancers/raindancers-crew.CrewBackupBucket", version: "0.0.0" };
57
+ /** The backup bucket. */
58
+ bucket;
59
+ /** The KMS key encrypting the bucket. */
60
+ key;
61
+ constructor(scope, id, props = {}) {
62
+ super(scope, id);
63
+ this.key = new kms.Key(this, 'Key', {
64
+ description: 'KiroCrew snapshot backup bucket encryption key',
65
+ enableKeyRotation: true,
66
+ removalPolicy: props.removalPolicy ?? aws_cdk_lib_1.RemovalPolicy.RETAIN,
67
+ });
68
+ const noncurrentDays = props.noncurrentVersionExpirationDays ?? 90;
69
+ this.bucket = new s3.Bucket(this, 'Bucket', {
70
+ bucketName: props.bucketName,
71
+ encryption: s3.BucketEncryption.KMS,
72
+ encryptionKey: this.key,
73
+ bucketKeyEnabled: true,
74
+ blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
75
+ enforceSSL: true,
76
+ versioned: true,
77
+ removalPolicy: props.removalPolicy ?? aws_cdk_lib_1.RemovalPolicy.RETAIN,
78
+ lifecycleRules: noncurrentDays > 0
79
+ ? [
80
+ {
81
+ // Keep current snapshots forever; expire superseded versions so
82
+ // the bucket does not grow without bound.
83
+ noncurrentVersionExpiration: aws_cdk_lib_1.Duration.days(noncurrentDays),
84
+ abortIncompleteMultipartUploadAfter: aws_cdk_lib_1.Duration.days(7),
85
+ },
86
+ ]
87
+ : undefined,
88
+ });
89
+ }
90
+ /**
91
+ * Grant a principal permission to WRITE snapshots (and the KMS encrypt it
92
+ * needs). Used by the crew instance/task role that pushes backups.
93
+ */
94
+ grantWrite(grantee) {
95
+ this.bucket.grantWrite(grantee);
96
+ this.key.grantEncryptDecrypt(grantee);
97
+ }
98
+ /**
99
+ * Grant a principal permission to READ snapshots (and the KMS decrypt it
100
+ * needs). Used by a replacement instance restoring from backup.
101
+ */
102
+ grantRead(grantee) {
103
+ this.bucket.grantRead(grantee);
104
+ this.key.grantDecrypt(grantee);
105
+ }
106
+ }
107
+ exports.CrewBackupBucket = CrewBackupBucket;
108
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3Jldy1iYWNrdXAtYnVja2V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NyZXctYmFja3VwLWJ1Y2tldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsNkNBQXNEO0FB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