@intentius/behold 0.29.25 → 0.29.27
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/AGENTS.md +3 -1
- package/demos.json +15 -0
- package/dist/cli.js +697 -371
- package/example-choudoufu-estate/README.md +2 -2
- package/example-choudoufu-estate/scripts/choudoufu-up.sh +2 -2
- package/example-terralith/README.md +33 -0
- package/example-terralith/phases/adopt/migrations/adopt.yml +12 -0
- package/example-terralith/phases/adopt/terralith/main.tf +138 -0
- package/example-terralith/phases/plan/team-a/main.tf +58 -0
- package/example-terralith/phases/plan/team-b/main.tf +58 -0
- package/example-terralith/phases/plan/team-c/main.tf +58 -0
- package/example-terralith/phases/plan/terralith/main.tf +32 -0
- package/example-terralith/phases/split/migrations/split.yml +29 -0
- package/example-terralith/phases/split/team-a/main.tf +52 -0
- package/example-terralith/phases/split/team-b/main.tf +52 -0
- package/example-terralith/phases/split/team-c/main.tf +52 -0
- package/example-terralith/phases/split/terralith/main.tf +27 -0
- package/example-terralith/scripts/lib.sh +65 -0
- package/example-terralith/scripts/terralith-down.sh +9 -0
- package/example-terralith/scripts/terralith-step.sh +139 -0
- package/example-terralith/scripts/terralith-up.sh +50 -0
- package/example-terralith/terralith/main.tf +141 -0
- package/package.json +2 -1
- package/web/app.js +83 -9
- package/web/identity-mark.js +61 -0
- package/web/identity-mark.test.js +32 -0
- package/web/pending.js +54 -0
- package/web/pending.test.js +47 -1
- package/web/terralith-steps.js +142 -0
- package/web/terralith-steps.test.js +97 -0
- package/web/terralith.html +125 -0
- package/web/terralith.js +301 -0
- /package/example-choudoufu-estate/monolith/{carve.json → split.json} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Shared by terralith-up.sh and terralith-step.sh. Sourced, never run.
|
|
2
|
+
#
|
|
3
|
+
# Every phase ends in a snapshot: choudoufu's own documents for each root,
|
|
4
|
+
# written as files under snapshots/<n>-<phase>/, and phase.json written last.
|
|
5
|
+
# behold reads those files (src/terralith-demo.ts) and nothing else, so the
|
|
6
|
+
# walkthrough shows what the tool printed, and the same files can come from a
|
|
7
|
+
# pipeline instead of this script.
|
|
8
|
+
|
|
9
|
+
CONTAINER="${TERRALITH_CONTAINER:-behold-terralith-floci}"
|
|
10
|
+
PORT="${TERRALITH_PORT:-4652}"
|
|
11
|
+
# choudoufu's own pin (live/floci-image in the choudoufu repo).
|
|
12
|
+
IMAGE="ghcr.io/lex00/floci@sha256:ff46eb8d1b73a9727948d1a194a660972e44cc64164a486548da7cb468a09144"
|
|
13
|
+
CHOUDOUFU="${CHOUDOUFU_BIN:-choudoufu}"
|
|
14
|
+
BUCKET=terralith-state
|
|
15
|
+
|
|
16
|
+
export AWS_ENDPOINT_URL="http://127.0.0.1:${PORT}"
|
|
17
|
+
export AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_REGION=us-east-1
|
|
18
|
+
export TF_PLUGIN_CACHE_DIR="${TF_PLUGIN_CACHE_DIR:-$HOME/.terraform.d/plugin-cache}"
|
|
19
|
+
mkdir -p "$TF_PLUGIN_CACHE_DIR"
|
|
20
|
+
|
|
21
|
+
say() { printf '%s\n' "→ $*"; }
|
|
22
|
+
die() { printf 'terralith demo: %s\n' "$*" >&2; exit 1; }
|
|
23
|
+
|
|
24
|
+
need_choudoufu() {
|
|
25
|
+
command -v "$CHOUDOUFU" >/dev/null 2>&1 || die "${CHOUDOUFU} is not on PATH. Install choudoufu 0.28.0 or newer (https://github.com/INTENTIUS/choudoufu/releases), or set CHOUDOUFU_BIN."
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# The estate a root's live block names, or nothing for a stock root.
|
|
29
|
+
estate_of() {
|
|
30
|
+
sed -n '/^ live {/,/^ }/s/^ *estate *= *"\(.*\)"/\1/p' "$1/main.tf" | head -1
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# snap <phase dir> <root>: the root's documents, as choudoufu printed them.
|
|
34
|
+
snap() {
|
|
35
|
+
local dir="$1" root="$2" out estate
|
|
36
|
+
out="$PWD/$dir/$root"
|
|
37
|
+
mkdir -p "$out"
|
|
38
|
+
(cd "$root" && "$CHOUDOUFU" live-check -json >"$out/live-check.json" 2>"$out/live-check.err") || true
|
|
39
|
+
estate="$(estate_of "$root")"
|
|
40
|
+
if [ -z "$estate" ]; then
|
|
41
|
+
(cd "$root" && "$CHOUDOUFU" show -json -no-color >"$out/state.json" 2>"$out/state.err") || true
|
|
42
|
+
else
|
|
43
|
+
(cd "$root" && "$CHOUDOUFU" live-ls -estate="$estate" -consistent -json . >"$out/live-ls.json" 2>"$out/live-ls.err") || true
|
|
44
|
+
# SNAP_PLAN_ARGS: extra live-plan flags, such as -estate-outputs-from in the plan phase.
|
|
45
|
+
(cd "$root" && "$CHOUDOUFU" live-plan -json ${SNAP_PLAN_ARGS:-} >"$out/live-plan.json" 2>"$out/live-plan.err") || true
|
|
46
|
+
fi
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# finish <phase dir> <phase> <n> <roots...>: phase.json, written last, so a
|
|
50
|
+
# reader never sees half a phase.
|
|
51
|
+
finish() {
|
|
52
|
+
local dir="$1" phase="$2" n="$3"
|
|
53
|
+
shift 3
|
|
54
|
+
local roots="" r
|
|
55
|
+
for r in "$@"; do roots="${roots:+$roots, }\"$r\""; done
|
|
56
|
+
local version
|
|
57
|
+
version="$("$CHOUDOUFU" version 2>/dev/null | head -1 | sed 's/"/\\"/g')"
|
|
58
|
+
printf '{\n "phase": "%s",\n "n": %s,\n "at": "%s",\n "choudoufu": "%s",\n "roots": [%s]\n}\n' \
|
|
59
|
+
"$phase" "$n" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$version" "$roots" >"$PWD/$dir/phase.json.tmp"
|
|
60
|
+
mv "$PWD/$dir/phase.json.tmp" "$dir/phase.json"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
init_root() {
|
|
64
|
+
(cd "$1" && "$CHOUDOUFU" init -input=false -no-color "${@:2}" >/dev/null) || die "choudoufu init failed in $1"
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Remove the terralith demo's scratch floci, by its name and no other. The
|
|
3
|
+
# copy and its snapshots stay; they are yours to read, and the next
|
|
4
|
+
# terralith-up.sh in a fresh copy starts over.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
cd "$(dirname "$0")/.."
|
|
7
|
+
. scripts/lib.sh
|
|
8
|
+
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
|
|
9
|
+
echo "terralith demo: ${CONTAINER} removed."
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# The writes of `behold demo terralith`, one phase at a time, run by you.
|
|
3
|
+
# behold shows these lines and reads what they leave; it never runs them.
|
|
4
|
+
#
|
|
5
|
+
# adopt the terragucci `backends:` migration: the root's backend block
|
|
6
|
+
# becomes a live block, and choudoufu live-import reads the old
|
|
7
|
+
# state once and stamps tofu-estate and tofu-address on every
|
|
8
|
+
# resource it verifies. The old state stays in the bucket.
|
|
9
|
+
# split the terragucci `moves:` migration: three team roots appear, and
|
|
10
|
+
# choudoufu live-mv -from-estate rewrites each team resource's
|
|
11
|
+
# markers, run in the root it moves to. One tag write per resource.
|
|
12
|
+
# The record is split.json.
|
|
13
|
+
# plan a change across the new estates, planned the way terragucci
|
|
14
|
+
# plans a pull request: the terralith publishes a shared setting as
|
|
15
|
+
# an output, and each team's first log group reads it. The
|
|
16
|
+
# terralith plans first; each team root plans its cone with
|
|
17
|
+
# -estate-outputs-from, so it reads the terralith's PLANNED output
|
|
18
|
+
# (choudoufu falls back to a full plan there, and says why); the
|
|
19
|
+
# three team plans run as one live-plan-set, and live-summary folds
|
|
20
|
+
# the identical changes into one group. Nothing is applied.
|
|
21
|
+
#
|
|
22
|
+
# Each phase ends in a snapshot under snapshots/<n>-<phase>/.
|
|
23
|
+
set -euo pipefail
|
|
24
|
+
cd "$(dirname "$0")/.."
|
|
25
|
+
. scripts/lib.sh
|
|
26
|
+
need_choudoufu
|
|
27
|
+
|
|
28
|
+
phase="${1:-}"
|
|
29
|
+
WORK=.terralith
|
|
30
|
+
mkdir -p "$WORK"
|
|
31
|
+
|
|
32
|
+
case "$phase" in
|
|
33
|
+
adopt)
|
|
34
|
+
[ -f snapshots/1-stock/phase.json ] || die "phase 1 is not up yet. Run scripts/terralith-up.sh first."
|
|
35
|
+
[ -f snapshots/2-adopt/phase.json ] && { say "adopt already ran (snapshots/2-adopt)."; exit 0; }
|
|
36
|
+
say "the old state, read once from s3://${BUCKET}"
|
|
37
|
+
[ -s "$WORK/terralith.tfstate" ] || (cd terralith && "$CHOUDOUFU" state pull >"../$WORK/terralith.tfstate")
|
|
38
|
+
say "the code change: terralith's backend block becomes a live block, plus migrations/adopt.yml"
|
|
39
|
+
# The s3 backend's settings stay beside .terraform as a record; init under a
|
|
40
|
+
# live block configures no backend.
|
|
41
|
+
[ -f terralith/.terraform/terraform.tfstate ] && mv terralith/.terraform/terraform.tfstate "$WORK/terralith.backend.json"
|
|
42
|
+
mkdir -p migrations
|
|
43
|
+
cp phases/adopt/terralith/main.tf terralith/main.tf
|
|
44
|
+
cp phases/adopt/migrations/adopt.yml migrations/adopt.yml
|
|
45
|
+
init_root terralith
|
|
46
|
+
mkdir -p snapshots/2-adopt/terralith
|
|
47
|
+
say "live-import, read-only: what verifies against the live system"
|
|
48
|
+
(cd terralith && "$CHOUDOUFU" live-import -no-color "-state=$PWD/../$WORK/terralith.tfstate" -estate=terralith \
|
|
49
|
+
>../snapshots/2-adopt/terralith/live-import.txt 2>&1) || die "live-import could not verify the state (snapshots/2-adopt/terralith/live-import.txt)"
|
|
50
|
+
say "live-import -approve: one marker write per verified resource"
|
|
51
|
+
(cd terralith && "$CHOUDOUFU" live-import -no-color "-state=$PWD/../$WORK/terralith.tfstate" -estate=terralith -approve \
|
|
52
|
+
>../snapshots/2-adopt/terralith/live-import-approve.txt 2>&1) || die "live-import could not stamp (snapshots/2-adopt/terralith/live-import-approve.txt)"
|
|
53
|
+
tail -3 snapshots/2-adopt/terralith/live-import-approve.txt | head -1
|
|
54
|
+
say "snapshot: phase 2"
|
|
55
|
+
snap snapshots/2-adopt terralith
|
|
56
|
+
finish snapshots/2-adopt adopt 2 terralith
|
|
57
|
+
say "adopted. Next: bash scripts/terralith-step.sh split"
|
|
58
|
+
;;
|
|
59
|
+
split)
|
|
60
|
+
[ -f snapshots/2-adopt/phase.json ] || die "adopt has not run yet. Run scripts/terralith-step.sh adopt first."
|
|
61
|
+
[ -f snapshots/3-split/phase.json ] && { say "split already ran (snapshots/3-split)."; exit 0; }
|
|
62
|
+
say "the code change: three team roots, the terralith keeps the network, plus migrations/split.yml"
|
|
63
|
+
for root in terralith team-a team-b team-c; do
|
|
64
|
+
mkdir -p "$root"
|
|
65
|
+
cp "phases/split/$root/main.tf" "$root/main.tf"
|
|
66
|
+
done
|
|
67
|
+
cp phases/split/migrations/split.yml migrations/split.yml
|
|
68
|
+
for root in team-a team-b team-c; do init_root "$root"; done
|
|
69
|
+
mkdir -p snapshots/3-split/live-mv
|
|
70
|
+
moves="" retags=""
|
|
71
|
+
for root in team-a team-b team-c; do
|
|
72
|
+
for address in $(sed -n "/to: ${root}\$/,/^ - /s/^ - //p" migrations/split.yml); do
|
|
73
|
+
doc="snapshots/3-split/live-mv/${root}--${address}.json"
|
|
74
|
+
(cd "$root" && "$CHOUDOUFU" live-mv -json -dry-run -from-estate=terralith "$address" "$address" >"../${doc%.json}.dry-run.json" 2>/dev/null) \
|
|
75
|
+
|| die "live-mv -dry-run refused ${address} (${doc%.json}.dry-run.json)"
|
|
76
|
+
(cd "$root" && "$CHOUDOUFU" live-mv -json -from-estate=terralith "$address" "$address" >"../$doc" 2>/dev/null) \
|
|
77
|
+
|| die "live-mv refused ${address} (${doc})"
|
|
78
|
+
say "retag ${address}: terralith → ${root}"
|
|
79
|
+
moves="${moves:+$moves,}
|
|
80
|
+
{\"address\": \"${address}\", \"from\": \"terralith\", \"to\": \"${root}\"}"
|
|
81
|
+
retags="${retags:+$retags,}
|
|
82
|
+
{\"address\": \"${address}\", \"from\": \"terralith\", \"to\": \"${root}\", \"from_estate\": \"terralith\", \"to_estate\": \"${root}\", \"document\": \"${doc}\"}"
|
|
83
|
+
done
|
|
84
|
+
done
|
|
85
|
+
# split.json: the plan behold reads (from, estates, moves), and where each
|
|
86
|
+
# retag's own live-mv document is.
|
|
87
|
+
printf '{\n "from": "terralith",\n "estates": ["team-a", "team-b", "team-c"],\n "migration": "migrations/split.yml",\n "moves": [%s\n ],\n "retags": [%s\n ]\n}\n' "$moves" "$retags" >split.json
|
|
88
|
+
say "snapshot: phase 3"
|
|
89
|
+
for root in terralith team-a team-b team-c; do snap snapshots/3-split "$root"; done
|
|
90
|
+
finish snapshots/3-split split 3 terralith team-a team-b team-c
|
|
91
|
+
say "split. Four estates, one tag write per resource."
|
|
92
|
+
;;
|
|
93
|
+
plan)
|
|
94
|
+
[ -f snapshots/3-split/phase.json ] || die "split has not run yet. Run scripts/terralith-step.sh split first."
|
|
95
|
+
[ -f snapshots/4-plan/phase.json ] && { say "plan already ran (snapshots/4-plan)."; exit 0; }
|
|
96
|
+
command -v git >/dev/null 2>&1 || die "git is not on PATH; the cone is a diff against each root's last commit."
|
|
97
|
+
out="$PWD/snapshots/4-plan"
|
|
98
|
+
mkdir -p "$out"
|
|
99
|
+
# Each estate root keeps its own history, as a split estate's repository
|
|
100
|
+
# would: the base is the root as the split left it. (A root in a
|
|
101
|
+
# subdirectory of one shared repository gets no cone from choudoufu 0.28.0:
|
|
102
|
+
# live-cone lists the base with `git ls-tree` from inside the root, which
|
|
103
|
+
# git filters to that directory, so the base reads empty.)
|
|
104
|
+
for root in terralith team-a team-b team-c; do
|
|
105
|
+
if [ ! -d "$root/.git" ]; then
|
|
106
|
+
(cd "$root" && git init -q && printf '%s\n' .terraform/ .terraform.lock.hcl .tofu-records/ >.gitignore \
|
|
107
|
+
&& git add -A && git -c user.name=terralith-demo -c user.email=terralith-demo@localhost commit -q -m "the root as the split left it")
|
|
108
|
+
fi
|
|
109
|
+
done
|
|
110
|
+
say "the code change: the terralith outputs log_retention_days, and each team's first log group reads it"
|
|
111
|
+
for root in terralith team-a team-b team-c; do cp "phases/plan/$root/main.tf" "$root/main.tf"; done
|
|
112
|
+
say "live-cone: what each change reaches, against the root's last commit"
|
|
113
|
+
for root in terralith team-a team-b team-c; do
|
|
114
|
+
mkdir -p "$out/$root"
|
|
115
|
+
(cd "$root" && "$CHOUDOUFU" live-cone -json HEAD >"$out/$root/cone.json" 2>"$out/$root/cone.err") || true
|
|
116
|
+
done
|
|
117
|
+
say "plan the terralith first: its planned output is what the teams read"
|
|
118
|
+
(cd terralith && "$CHOUDOUFU" plan -input=false -no-color "-out=$PWD/../$WORK/terralith.tfplan" >"$out/terralith/plan.log" 2>&1) \
|
|
119
|
+
|| die "the terralith's plan failed (snapshots/4-plan/terralith/plan.log)"
|
|
120
|
+
(cd terralith && "$CHOUDOUFU" show -json "$PWD/../$WORK/terralith.tfplan" >"$out/terralith/plan.json")
|
|
121
|
+
say "live-plan-set: the three team roots, each its cone, reading the terralith's planned output"
|
|
122
|
+
TF_CLI_ARGS_plan="-cone=HEAD -estate-outputs-from=terralith=$out/terralith/plan.json" \
|
|
123
|
+
"$CHOUDOUFU" live-plan-set -json "-out-dir=$WORK/plan-set" team-a team-b team-c >"$out/set.json" 2>"$out/set.err" || true
|
|
124
|
+
for root in team-a team-b team-c; do cp "$WORK/plan-set/$root.log" "$out/$root/plan.log" 2>/dev/null || true; done
|
|
125
|
+
say "live-summary: the identical changes, folded"
|
|
126
|
+
"$CHOUDOUFU" live-summary -json "$out/set.json" >"$out/summary.json"
|
|
127
|
+
"$CHOUDOUFU" live-summary "$out/set.json" | head -8
|
|
128
|
+
say "snapshot: phase 4"
|
|
129
|
+
snap snapshots/4-plan terralith
|
|
130
|
+
for root in team-a team-b team-c; do
|
|
131
|
+
SNAP_PLAN_ARGS="-estate-outputs-from=terralith=$out/terralith/plan.json" snap snapshots/4-plan "$root"
|
|
132
|
+
done
|
|
133
|
+
finish snapshots/4-plan plan 4 terralith team-a team-b team-c
|
|
134
|
+
say "planned. Nothing was applied: the plans are in .terralith/plan-set."
|
|
135
|
+
;;
|
|
136
|
+
*)
|
|
137
|
+
die "which phase? bash scripts/terralith-step.sh adopt | split | plan"
|
|
138
|
+
;;
|
|
139
|
+
esac
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Phase 1 of `behold demo terralith`: a stock terralith.
|
|
3
|
+
#
|
|
4
|
+
# A scratch floci (the AWS emulator) on 127.0.0.1:4652, a state bucket in it,
|
|
5
|
+
# and one Terraform root applied the stock way: 23 resources (a network and
|
|
6
|
+
# three teams' IAM and log groups) in one state file on S3. No markers yet.
|
|
7
|
+
#
|
|
8
|
+
# Scratch discipline: the container is named behold-terralith-floci (or
|
|
9
|
+
# TERRALITH_CONTAINER), this script refuses to adopt one that already exists,
|
|
10
|
+
# and only terralith-down.sh stops it. The port is not the shared emulator's
|
|
11
|
+
# (:4566), so nothing here reaches a floci another tool runs.
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
cd "$(dirname "$0")/.."
|
|
14
|
+
. scripts/lib.sh
|
|
15
|
+
|
|
16
|
+
docker info >/dev/null 2>&1 || die "Docker is not running. Start Docker and re-run."
|
|
17
|
+
need_choudoufu
|
|
18
|
+
|
|
19
|
+
if [ -f snapshots/1-stock/phase.json ]; then
|
|
20
|
+
say "phase 1 is already up (snapshots/1-stock). terralith-down.sh stops the emulator; a fresh copy starts over."
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
if docker ps -a --format '{{.Names}}' | grep -qx "$CONTAINER"; then
|
|
24
|
+
die "container ${CONTAINER} already exists from an earlier run. Run scripts/terralith-down.sh, or set TERRALITH_CONTAINER to a new name."
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
say "floci on 127.0.0.1:${PORT} (${CONTAINER})"
|
|
28
|
+
docker run -d --name "$CONTAINER" -p "127.0.0.1:${PORT}:4566" "$IMAGE" >/dev/null
|
|
29
|
+
for _ in $(seq 1 40); do
|
|
30
|
+
curl -fs -o /dev/null "http://127.0.0.1:${PORT}/" && break
|
|
31
|
+
sleep 1
|
|
32
|
+
done
|
|
33
|
+
|
|
34
|
+
say "state bucket s3://${BUCKET}, versioned"
|
|
35
|
+
curl -fs -o /dev/null -X PUT "http://127.0.0.1:${PORT}/${BUCKET}"
|
|
36
|
+
curl -fs -o /dev/null -X PUT "http://127.0.0.1:${PORT}/${BUCKET}?versioning" -H 'content-type: application/xml' \
|
|
37
|
+
-d '<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Status>Enabled</Status></VersioningConfiguration>'
|
|
38
|
+
|
|
39
|
+
say "choudoufu init in terralith (an OpenTofu fork; with no live block it runs stock)"
|
|
40
|
+
init_root terralith -backend-config=use_path_style=true
|
|
41
|
+
|
|
42
|
+
say "apply: the terralith, 23 resources in one state file"
|
|
43
|
+
(cd terralith && "$CHOUDOUFU" apply -auto-approve -input=false -no-color | tail -1)
|
|
44
|
+
|
|
45
|
+
say "snapshot: phase 1"
|
|
46
|
+
mkdir -p snapshots/1-stock
|
|
47
|
+
snap snapshots/1-stock terralith
|
|
48
|
+
finish snapshots/1-stock stock 1 terralith
|
|
49
|
+
|
|
50
|
+
say "phase 1 is up. Next: bash scripts/terralith-step.sh adopt"
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
backend "s3" {
|
|
9
|
+
bucket = "terralith-state"
|
|
10
|
+
key = "terralith/terraform.tfstate"
|
|
11
|
+
region = "us-east-1"
|
|
12
|
+
use_lockfile = true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
provider "aws" {
|
|
17
|
+
region = "us-east-1"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# ---- network ----
|
|
21
|
+
resource "aws_vpc" "main" {
|
|
22
|
+
cidr_block = "10.42.0.0/16"
|
|
23
|
+
tags = { Name = "terralith-main" }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
resource "aws_subnet" "app" {
|
|
27
|
+
vpc_id = aws_vpc.main.id
|
|
28
|
+
cidr_block = "10.42.1.0/24"
|
|
29
|
+
tags = { Name = "terralith-app" }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# ---- team-a ----
|
|
33
|
+
resource "aws_iam_role" "team_a" {
|
|
34
|
+
name = "terralith-team-a-role"
|
|
35
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resource "aws_iam_role_policy" "team_a_inline" {
|
|
39
|
+
name = "terralith-team-a-inline"
|
|
40
|
+
role = aws_iam_role.team_a.id
|
|
41
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_iam_policy" "team_a" {
|
|
45
|
+
name = "terralith-team-a-policy"
|
|
46
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_iam_role_policy_attachment" "team_a" {
|
|
50
|
+
role = aws_iam_role.team_a.name
|
|
51
|
+
policy_arn = aws_iam_policy.team_a.arn
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
resource "aws_cloudwatch_log_group" "team_a_0" {
|
|
55
|
+
name = "/terralith/team-a/svc-0"
|
|
56
|
+
retention_in_days = 7
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
resource "aws_cloudwatch_log_group" "team_a_1" {
|
|
60
|
+
name = "/terralith/team-a/svc-1"
|
|
61
|
+
retention_in_days = 7
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
resource "aws_cloudwatch_log_group" "team_a_2" {
|
|
65
|
+
name = "/terralith/team-a/svc-2"
|
|
66
|
+
retention_in_days = 7
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# ---- team-b ----
|
|
70
|
+
resource "aws_iam_role" "team_b" {
|
|
71
|
+
name = "terralith-team-b-role"
|
|
72
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
resource "aws_iam_role_policy" "team_b_inline" {
|
|
76
|
+
name = "terralith-team-b-inline"
|
|
77
|
+
role = aws_iam_role.team_b.id
|
|
78
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
resource "aws_iam_policy" "team_b" {
|
|
82
|
+
name = "terralith-team-b-policy"
|
|
83
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
resource "aws_iam_role_policy_attachment" "team_b" {
|
|
87
|
+
role = aws_iam_role.team_b.name
|
|
88
|
+
policy_arn = aws_iam_policy.team_b.arn
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
resource "aws_cloudwatch_log_group" "team_b_0" {
|
|
92
|
+
name = "/terralith/team-b/svc-0"
|
|
93
|
+
retention_in_days = 7
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
resource "aws_cloudwatch_log_group" "team_b_1" {
|
|
97
|
+
name = "/terralith/team-b/svc-1"
|
|
98
|
+
retention_in_days = 7
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
resource "aws_cloudwatch_log_group" "team_b_2" {
|
|
102
|
+
name = "/terralith/team-b/svc-2"
|
|
103
|
+
retention_in_days = 7
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# ---- team-c ----
|
|
107
|
+
resource "aws_iam_role" "team_c" {
|
|
108
|
+
name = "terralith-team-c-role"
|
|
109
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resource "aws_iam_role_policy" "team_c_inline" {
|
|
113
|
+
name = "terralith-team-c-inline"
|
|
114
|
+
role = aws_iam_role.team_c.id
|
|
115
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
resource "aws_iam_policy" "team_c" {
|
|
119
|
+
name = "terralith-team-c-policy"
|
|
120
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
resource "aws_iam_role_policy_attachment" "team_c" {
|
|
124
|
+
role = aws_iam_role.team_c.name
|
|
125
|
+
policy_arn = aws_iam_policy.team_c.arn
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
resource "aws_cloudwatch_log_group" "team_c_0" {
|
|
129
|
+
name = "/terralith/team-c/svc-0"
|
|
130
|
+
retention_in_days = 7
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
resource "aws_cloudwatch_log_group" "team_c_1" {
|
|
134
|
+
name = "/terralith/team-c/svc-1"
|
|
135
|
+
retention_in_days = 7
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
resource "aws_cloudwatch_log_group" "team_c_2" {
|
|
139
|
+
name = "/terralith/team-c/svc-2"
|
|
140
|
+
retention_in_days = 7
|
|
141
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.27",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"example-carve",
|
|
19
19
|
"example-terraform-estate",
|
|
20
20
|
"example-choudoufu-estate",
|
|
21
|
+
"example-terralith",
|
|
21
22
|
"demos.json",
|
|
22
23
|
"AGENTS.md",
|
|
23
24
|
"LICENSE",
|
package/web/app.js
CHANGED
|
@@ -33,7 +33,7 @@ import { seconds, whyQuery, whyView } from "./why.js";
|
|
|
33
33
|
import { edgeKey, edgeLabel, edgeLegend, edgeTitle, isCiKind, viaIndex } from "./edge-kind.js";
|
|
34
34
|
import { readCostLine } from "./read-cost.js";
|
|
35
35
|
import { mountHistoryPicker } from "./history-picker.js";
|
|
36
|
-
import { applyMemberFrame, pendingLine, stillPending } from "./pending.js";
|
|
36
|
+
import { applyMemberFrame, createMemberFrames, pendingLine, stillPending } from "./pending.js";
|
|
37
37
|
import { initTheme, setTheme, mountThemePicker, readableOn, inkOn, colorForCategory, onThemeChange, getTokens, getTheme, pinTokensFor } from "./theme.js";
|
|
38
38
|
// #399 M2 / #401 M4 of #397: the colour-by modes' arithmetic and the
|
|
39
39
|
// provenance badge's wording — every decision the behaviour overlay makes,
|
|
@@ -109,6 +109,8 @@ import { hasOperator, renderOperator, APPROVED_SEMANTICS } from "./operator.js";
|
|
|
109
109
|
import { releaseRows } from "./release.js";
|
|
110
110
|
import { danglingFor, danglingRows, danglingHeading, DANGLING_EXPLAINED } from "./dangling.js";
|
|
111
111
|
import { comparisonRow, comparisonSummary } from "./cross-env.js";
|
|
112
|
+
// The marker-vs-derived mark on a choudoufu card: how its identity was found.
|
|
113
|
+
import { identityMark, tagGlyphSvg } from "./identity-mark.js";
|
|
112
114
|
initTheme();
|
|
113
115
|
// #476: framed in a host pane. The flag is a class on <html>, so the CSS that
|
|
114
116
|
// folds the chrome away needs no JS, and the theme is the host's for this
|
|
@@ -1699,6 +1701,8 @@ let runtimeCapable = false;
|
|
|
1699
1701
|
* overlay's `meta.pending`. Empty on every non-progressive load, which is every
|
|
1700
1702
|
* single-project serve and every static snapshot. */
|
|
1701
1703
|
let pendingMembers = [];
|
|
1704
|
+
// The frames of the progressive load in flight, replayed once it is drawn.
|
|
1705
|
+
const memberFrames = createMemberFrames();
|
|
1702
1706
|
let pendingTotal = 0;
|
|
1703
1707
|
/** #426: whether the apply-order stop is worth offering — /api/project's
|
|
1704
1708
|
* `stacksCapable`, which is false for an estate and for a single-lexicon
|
|
@@ -2010,14 +2014,14 @@ function copyToClipboard(text, el) {
|
|
|
2010
2014
|
* The choudoufu move plan (#371), as the scope panel shows it: one row per
|
|
2011
2015
|
* move (`address: from → to`), the line a person runs in the destination
|
|
2012
2016
|
* estate's directory with a copy button, and a link to the morph page. The
|
|
2013
|
-
* plan is read from `/api/choudoufu/
|
|
2017
|
+
* plan is read from `/api/choudoufu/split`, which previews with choudoufu's
|
|
2014
2018
|
* own `-dry-run` when asked and never runs the write — `apply.note` carries
|
|
2015
2019
|
* that sentence here verbatim. A no-op when no served member carries a
|
|
2016
|
-
* `carve.json
|
|
2020
|
+
* `split.json` (or the workbench's `carve.json`).
|
|
2017
2021
|
*/
|
|
2018
2022
|
function renderChoudoufuMoves(host, info) {
|
|
2019
2023
|
if (!info || !info.plans || !info.plans.length || staticMode || publicMode) return;
|
|
2020
|
-
host.appendChild(panelHeading("
|
|
2024
|
+
host.appendChild(panelHeading("split (choudoufu)"));
|
|
2021
2025
|
for (const plan of info.plans) {
|
|
2022
2026
|
const head = document.createElement("div");
|
|
2023
2027
|
head.className = "count-row";
|
|
@@ -2026,15 +2030,15 @@ function renderChoudoufuMoves(host, info) {
|
|
|
2026
2030
|
label.textContent = plan;
|
|
2027
2031
|
const morph = document.createElement("a");
|
|
2028
2032
|
morph.className = "tag";
|
|
2029
|
-
morph.textContent = "
|
|
2030
|
-
morph.href = "/choudoufu/
|
|
2033
|
+
morph.textContent = "split ↗";
|
|
2034
|
+
morph.href = "/choudoufu/split?plan=" + encodeURIComponent(plan);
|
|
2031
2035
|
morph.target = "_blank";
|
|
2032
|
-
morph.title = "Every
|
|
2036
|
+
morph.title = "Every estate a box, the moved cards gliding to their destination";
|
|
2033
2037
|
head.append(label, morph);
|
|
2034
2038
|
host.appendChild(head);
|
|
2035
2039
|
const rows = document.createElement("div");
|
|
2036
2040
|
host.appendChild(rows);
|
|
2037
|
-
apiFetch("/api/choudoufu/
|
|
2041
|
+
apiFetch("/api/choudoufu/split?plan=" + encodeURIComponent(plan))
|
|
2038
2042
|
.then((r) => r.json())
|
|
2039
2043
|
.then((body) => {
|
|
2040
2044
|
if (!body || !Array.isArray(body.moves)) {
|
|
@@ -3347,6 +3351,46 @@ function markPendingCards(ir) {
|
|
|
3347
3351
|
}
|
|
3348
3352
|
}
|
|
3349
3353
|
|
|
3354
|
+
/**
|
|
3355
|
+
* The marker-vs-derived mark on each choudoufu card the live overlay bound
|
|
3356
|
+
* (`attrs._identity`, src/choudoufu-live.ts): a small tag badge on the card's
|
|
3357
|
+
* top-right edge, filled when the object wears the estate's marker and
|
|
3358
|
+
* outlined when it does not. A card has no free corner for words, so they are
|
|
3359
|
+
* the badge's tooltip, and the inspect pane's `bound` and `marker` rows. Same
|
|
3360
|
+
* after-the-render stamp as markCarvedCards(), for the same reason.
|
|
3361
|
+
*/
|
|
3362
|
+
function markIdentityCards(ir) {
|
|
3363
|
+
const svg = document.querySelector("#graph svg");
|
|
3364
|
+
if (!svg) return;
|
|
3365
|
+
// A member frame merges identities into lastGraphIr (web/pending.js), and a
|
|
3366
|
+
// re-render (a theme change, a fit) may paint from another IR object, so
|
|
3367
|
+
// both are read.
|
|
3368
|
+
const known = new Map();
|
|
3369
|
+
for (const src of [lastGraphIr, ir]) for (const n of (src && src.nodes) || []) if (n.attrs && n.attrs._identity) known.set(n.id, n.attrs._identity);
|
|
3370
|
+
for (const [id, identity] of known) {
|
|
3371
|
+
const n = { id };
|
|
3372
|
+
const mark = identityMark(identity);
|
|
3373
|
+
if (!mark || mark.glyph === "none") continue;
|
|
3374
|
+
const g = svg.querySelector('[data-node-id="' + CSS.escape(n.id) + '"]');
|
|
3375
|
+
if (!g || g.querySelector('[data-identity="1"]')) continue;
|
|
3376
|
+
const rect = g.querySelector("rect");
|
|
3377
|
+
const box = rect && rect.getBBox ? rect.getBBox() : null;
|
|
3378
|
+
const size = 14;
|
|
3379
|
+
const x = (box ? box.x + box.width : 150) - size - 6;
|
|
3380
|
+
const y = (box ? box.y : 0) - size / 2;
|
|
3381
|
+
const wrap = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
3382
|
+
wrap.setAttribute("data-identity", "1");
|
|
3383
|
+
wrap.setAttribute("class", "identity-mark");
|
|
3384
|
+
wrap.innerHTML =
|
|
3385
|
+
`<rect x="${x - 3}" y="${y - 2}" width="${size + 6}" height="${size + 4}" rx="5" fill="var(--bg)" stroke="var(--managed)" stroke-width="1"/>` +
|
|
3386
|
+
tagGlyphSvg(mark.glyph, x, y, size, "var(--managed)");
|
|
3387
|
+
const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
|
|
3388
|
+
title.textContent = `${mark.label}: ${mark.tip}`;
|
|
3389
|
+
wrap.prepend(title);
|
|
3390
|
+
g.appendChild(wrap);
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3350
3394
|
function markDriftedCards(ir) {
|
|
3351
3395
|
const svg = document.querySelector("#graph svg");
|
|
3352
3396
|
if (!svg) return;
|
|
@@ -6102,6 +6146,7 @@ function render(ir, svg, m) {
|
|
|
6102
6146
|
markCarvedCards(); // #254: the SVG is replaced per render — re-stamp the marker
|
|
6103
6147
|
markPlayhead(ir); // #284 item 2: same, for the step the run is sitting on
|
|
6104
6148
|
markOperatorCards(ir); // #234 free rider: same, for the operating loop's home
|
|
6149
|
+
markIdentityCards(ir); // the identity mark: a tag badge on the card's top-right edge
|
|
6105
6150
|
markDriftedCards(ir); // #404: same, for a bound card the plan would change — after the carve/operator stamps, so it can see and yield to them
|
|
6106
6151
|
markPendingCards(ir); // #422: and the cards whose member has not answered yet
|
|
6107
6152
|
markTerragucciCards(); // #490: and what terragucci's reports found, dated
|
|
@@ -7167,6 +7212,10 @@ function renderPreconditionError(body) {
|
|
|
7167
7212
|
const load = createRefreshQueue(loadOnce);
|
|
7168
7213
|
async function loadOnce(opts = {}, isCurrent = () => true) {
|
|
7169
7214
|
const meta = document.getElementById("meta");
|
|
7215
|
+
// #422: set when this load asks for the progressive overlay; `frameLoad` is
|
|
7216
|
+
// its turn in memberFrames, so an older load's end never releases a newer one.
|
|
7217
|
+
let progressive = false;
|
|
7218
|
+
let frameLoad = 0;
|
|
7170
7219
|
// A background settle re-pull (post-apply) shouldn't flash the meta/overlay.
|
|
7171
7220
|
if (!opts.quiet) {
|
|
7172
7221
|
meta.textContent = view.env ? `loading overlay for ${view.env}…` : "loading…";
|
|
@@ -7229,7 +7278,10 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
|
|
|
7229
7278
|
// its own live read lands, instead of a blank canvas until the slowest
|
|
7230
7279
|
// one finishes. The server only honours it for a composed estate, and
|
|
7231
7280
|
// never in a static snapshot, where there is no stream to follow.
|
|
7232
|
-
if (!staticMode)
|
|
7281
|
+
if (!staticMode) {
|
|
7282
|
+
q.set("progressive", "1");
|
|
7283
|
+
progressive = true;
|
|
7284
|
+
}
|
|
7233
7285
|
// The runtime tier (#86) descends below the declaration boundary. It is
|
|
7234
7286
|
// live-only by nature — owner-referenced children exist in the cluster,
|
|
7235
7287
|
// never in your source — so it rides the overlay and means nothing
|
|
@@ -7259,6 +7311,7 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
|
|
|
7259
7311
|
ciByComponent = new Map();
|
|
7260
7312
|
resourcesByComponent = {};
|
|
7261
7313
|
}
|
|
7314
|
+
if (progressive) frameLoad = memberFrames.begin();
|
|
7262
7315
|
const res = await apiFetch(`${endpoint}?${q}`);
|
|
7263
7316
|
const body = await res.json();
|
|
7264
7317
|
if (!isCurrent()) return; // a newer view/event is pending; do not paint the old result
|
|
@@ -7294,6 +7347,7 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
|
|
|
7294
7347
|
if (view.components) takeTerragucciFacets(body.meta);
|
|
7295
7348
|
render(body.ir, body.svg, body.meta);
|
|
7296
7349
|
afterPaint(body.ir);
|
|
7350
|
+
if (progressive) replayMemberFrames(frameLoad);
|
|
7297
7351
|
} catch (err) {
|
|
7298
7352
|
// A background settle poll must not blow away a good graph on a transient error.
|
|
7299
7353
|
if (!opts.quiet && isCurrent()) {
|
|
@@ -7310,9 +7364,25 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
|
|
|
7310
7364
|
}
|
|
7311
7365
|
} finally {
|
|
7312
7366
|
if (!opts.quiet) hideLoading();
|
|
7367
|
+
// Drawn, refused or superseded: either way nothing waits on this load's
|
|
7368
|
+
// answer any more, so a later frame applies as it lands.
|
|
7369
|
+
if (progressive) memberFrames.cancel(frameLoad);
|
|
7313
7370
|
}
|
|
7314
7371
|
}
|
|
7315
7372
|
|
|
7373
|
+
/** The frames that landed before this load's answer was drawn, folded into it now. */
|
|
7374
|
+
function replayMemberFrames(load) {
|
|
7375
|
+
if (!lastGraphIr) return;
|
|
7376
|
+
const r = memberFrames.replay(lastGraphIr, pendingMembers, load);
|
|
7377
|
+
if (!r) return;
|
|
7378
|
+
pendingMembers = r.pending;
|
|
7379
|
+
if (r.failed) nowline(`the estate read failed — ${r.failed}`);
|
|
7380
|
+
if (r.moved.length) recolorNodesByCategory(lastGraphIr);
|
|
7381
|
+
markPendingCards(lastGraphIr);
|
|
7382
|
+
markIdentityCards(lastGraphIr);
|
|
7383
|
+
renderStatusbar();
|
|
7384
|
+
}
|
|
7385
|
+
|
|
7316
7386
|
/**
|
|
7317
7387
|
* #404: re-read the overlay AND ask for the attribute-drift plan.
|
|
7318
7388
|
*
|
|
@@ -7454,6 +7524,9 @@ events.addEventListener("member", (e) => {
|
|
|
7454
7524
|
}
|
|
7455
7525
|
// The live pass itself failed. Say so on the now-line and stop claiming the
|
|
7456
7526
|
// remaining members are still arriving, because nothing more is coming.
|
|
7527
|
+
// A frame that lands while its load's answer is still on the way waits
|
|
7528
|
+
// for the draw, which replays it (web/pending.js createMemberFrames).
|
|
7529
|
+
if (!memberFrames.note(frame)) return;
|
|
7457
7530
|
if (frame.error) {
|
|
7458
7531
|
pendingMembers = [];
|
|
7459
7532
|
nowline(`the estate read failed — ${frame.error}`);
|
|
@@ -7465,6 +7538,7 @@ events.addEventListener("member", (e) => {
|
|
|
7465
7538
|
pendingMembers = stillPending(pendingMembers, frame);
|
|
7466
7539
|
if (moved.length) recolorNodesByCategory(lastGraphIr);
|
|
7467
7540
|
markPendingCards(lastGraphIr);
|
|
7541
|
+
markIdentityCards(lastGraphIr);
|
|
7468
7542
|
renderStatusbar();
|
|
7469
7543
|
});
|
|
7470
7544
|
|