chore: remove agent projection authority

This commit is contained in:
2026-08-26 00:52:55 +03:00
parent a8b2c4eed9
commit 6719160c13
24 changed files with 8 additions and 2566 deletions
-80
View File
@@ -1,80 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
workspace=${WEALTH_LEDGER_WORKSPACE:-$(cd "$script_dir/../.." && pwd -P)}
source_root="$workspace/specs/agent-projection/opencode"
projection_root="$workspace/.opencode"
for tree in commands skills; do
if [[ ! -d "$source_root/$tree" ]]; then
printf 'Missing canonical projection tree: %s\n' "${source_root#$workspace/}/$tree" >&2
exit 1
fi
done
mkdir -p "$projection_root"
stage=$(mktemp -d "$projection_root/.projection-stage.XXXXXX")
backup=$(mktemp -d "$projection_root/.projection-backup.XXXXXX")
commands_existed=0
skills_existed=0
cutover_started=0
cleanup_temporary() {
rm -rf "$stage" "$backup"
}
rollback() {
if [[ $cutover_started -eq 1 ]]; then
rm -rf "$projection_root/commands" "$projection_root/skills"
if [[ $commands_existed -eq 1 && -d "$backup/commands" ]]; then
mv "$backup/commands" "$projection_root/commands"
fi
if [[ $skills_existed -eq 1 && -d "$backup/skills" ]]; then
mv "$backup/skills" "$projection_root/skills"
fi
fi
cleanup_temporary
}
trap rollback EXIT
cp -R "$source_root/commands" "$stage/commands"
cp -R "$source_root/skills" "$stage/skills"
if [[ -d "$projection_root/commands" ]]; then
commands_existed=1
cp -R "$projection_root/commands" "$backup/commands"
fi
if [[ "${WEALTH_LEDGER_SYNC_FAIL_DURING_BACKUP:-0}" == '1' ]]; then
printf 'Injected projection backup failure; local projection was not modified.\n' >&2
exit 1
fi
if [[ -d "$projection_root/skills" ]]; then
skills_existed=1
cp -R "$projection_root/skills" "$backup/skills"
fi
cutover_started=1
rm -rf "$projection_root/commands" "$projection_root/skills"
if ! mv "$stage/commands" "$projection_root/commands"; then
printf 'Projection sync failed while installing commands; previous state will be restored.\n' >&2
exit 1
fi
if [[ "${WEALTH_LEDGER_SYNC_FAIL_AFTER_COMMANDS:-0}" == '1' ]]; then
printf 'Injected projection sync failure after commands; previous state will be restored.\n' >&2
exit 1
fi
if ! mv "$stage/skills" "$projection_root/skills"; then
printf 'Projection sync failed while installing skills; previous state will be restored.\n' >&2
exit 1
fi
if ! WEALTH_LEDGER_WORKSPACE="$workspace" bash "$script_dir/verify-agent-projection.sh"; then
printf 'Projection verification failed after cutover; previous state will be restored.\n' >&2
exit 1
fi
cutover_started=0
trap - EXIT
cleanup_temporary
printf 'Agent projection synchronized from specs authority.\n'
-72
View File
@@ -1,72 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
workspace=${WEALTH_LEDGER_WORKSPACE:-$(cd "$script_dir/../.." && pwd -P)}
source_root="$workspace/specs/agent-projection/opencode"
projection_root="$workspace/.opencode"
version_file="$workspace/specs/openspec/.cli-version"
failures=0
fail() {
printf 'FAIL: %s\n' "$1" >&2
failures=$((failures + 1))
}
if [[ ! -f "$version_file" ]]; then
fail 'missing OpenSpec version contract: specs/openspec/.cli-version'
expected_version=''
else
expected_version=$(tr -d '[:space:]' < "$version_file")
[[ -n "$expected_version" ]] || fail 'OpenSpec version contract is empty'
fi
for tree in commands skills; do
source_tree="$source_root/$tree"
projection_tree="$projection_root/$tree"
if [[ ! -d "$source_tree" ]]; then
fail "missing canonical projection tree: specs/agent-projection/opencode/$tree"
continue
fi
if [[ ! -d "$projection_tree" ]]; then
fail "missing projection directory: .opencode/$tree"
continue
fi
while IFS= read -r source_file; do
relative_path=${source_file#"$source_root/"}
projection_file="$projection_root/$relative_path"
if [[ ! -f "$projection_file" ]]; then
fail "missing projection file: $relative_path"
elif ! cmp -s "$source_file" "$projection_file"; then
fail "projection content drift: $relative_path"
fi
if [[ "$relative_path" == skills/*/SKILL.md ]]; then
marker_count=$(awk -v expected="generatedBy: \"$expected_version\"" '
{
line = $0
sub(/^[[:space:]]*/, "", line)
if (line == expected) count++
}
END { print count + 0 }
' "$source_file")
if [[ "$marker_count" -ne 1 ]]; then
fail "generated version marker mismatch in $relative_path: expected $expected_version"
fi
fi
done < <(find "$source_tree" -type f | sort)
while IFS= read -r projection_file; do
relative_path=${projection_file#"$projection_root/"}
if [[ ! -f "$source_root/$relative_path" ]]; then
fail "unexpected projection file: $relative_path"
fi
done < <(find "$projection_tree" -type f | sort)
done
if [[ $failures -gt 0 ]]; then
exit 1
fi
printf 'Agent projection verified against versioned authority: OpenSpec %s\n' "$expected_version"
-88
View File
@@ -1,88 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
verifier="$script_dir/verify-agent-projection.sh"
syncer="$script_dir/sync-agent-projection.sh"
contract_version=$(tr -d '[:space:]' < "$script_dir/../openspec/.cli-version")
if [[ ! -x "$verifier" ]]; then
printf 'expected executable projection verifier at %s\n' "$verifier" >&2
exit 1
fi
if [[ ! -x "$syncer" ]]; then
printf 'expected executable projection sync at %s\n' "$syncer" >&2
exit 1
fi
fixture=$(mktemp -d)
trap 'rm -rf "$fixture"' EXIT
mkdir -p "$fixture/specs/openspec" \
"$fixture/specs/agent-projection/opencode/commands" \
"$fixture/specs/agent-projection/opencode/skills/example" \
"$fixture/.opencode"
printf '%s\n' "$contract_version" > "$fixture/specs/openspec/.cli-version"
printf 'command authority\n' > "$fixture/specs/agent-projection/opencode/commands/example.md"
printf '%s\n' '---' 'name: example' 'metadata:' " generatedBy: \"$contract_version\"" '---' > "$fixture/specs/agent-projection/opencode/skills/example/SKILL.md"
printf '{"private":true}\n' > "$fixture/.opencode/package.json"
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$syncer"
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier"
[[ -f "$fixture/.opencode/package.json" ]]
printf 'manual drift\n' >> "$fixture/.opencode/commands/example.md"
if output=$(WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier" 2>&1); then
printf 'expected content drift to fail projection verification\n' >&2
exit 1
fi
[[ "$output" == *'projection content drift: commands/example.md'* ]]
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$syncer"
rm "$fixture/.opencode/skills/example/SKILL.md"
if output=$(WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier" 2>&1); then
printf 'expected missing projection file to fail verification\n' >&2
exit 1
fi
[[ "$output" == *'missing projection file: skills/example/SKILL.md'* ]]
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$syncer"
printf 'unexpected\n' > "$fixture/.opencode/commands/unexpected.md"
if output=$(WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier" 2>&1); then
printf 'expected extra projection file to fail verification\n' >&2
exit 1
fi
[[ "$output" == *'unexpected projection file: commands/unexpected.md'* ]]
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$syncer"
perl -0pi -e 's/generatedBy: "1\.10\.0"/generatedBy: "9.9.9"/' "$fixture/specs/agent-projection/opencode/skills/example/SKILL.md"
if output=$(WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier" 2>&1); then
printf 'expected incompatible canonical marker to fail verification\n' >&2
exit 1
fi
[[ "$output" == *"generated version marker mismatch in skills/example/SKILL.md: expected $contract_version"* ]]
perl -0pi -e "s/generatedBy: \"9\\.9\\.9\"/generatedBy: \"$contract_version\"/" "$fixture/specs/agent-projection/opencode/skills/example/SKILL.md"
printf 'old command\n' > "$fixture/.opencode/commands/example.md"
printf '%s\n' '---' 'name: old' 'metadata:' " generatedBy: \"$contract_version\"" '---' > "$fixture/.opencode/skills/example/SKILL.md"
cp -R "$fixture/.opencode/commands" "$fixture/expected-commands"
cp -R "$fixture/.opencode/skills" "$fixture/expected-skills"
if WEALTH_LEDGER_WORKSPACE="$fixture" WEALTH_LEDGER_SYNC_FAIL_DURING_BACKUP=1 bash "$syncer"; then
printf 'expected injected backup failure\n' >&2
exit 1
fi
diff -r "$fixture/expected-commands" "$fixture/.opencode/commands"
diff -r "$fixture/expected-skills" "$fixture/.opencode/skills"
if WEALTH_LEDGER_WORKSPACE="$fixture" WEALTH_LEDGER_SYNC_FAIL_AFTER_COMMANDS=1 bash "$syncer"; then
printf 'expected injected sync failure\n' >&2
exit 1
fi
diff -r "$fixture/expected-commands" "$fixture/.opencode/commands"
diff -r "$fixture/expected-skills" "$fixture/.opencode/skills"
rm -rf "$fixture/.opencode/commands" "$fixture/.opencode/skills"
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$syncer"
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier"
printf 'verify-agent-projection tests passed\n'
-4
View File
@@ -64,10 +64,6 @@ require_schema_edge "$schema_file" 'design' 'specs'
require_schema_edge "$schema_file" 'tasks' 'design'
require_file_contains "$schema_file" 'requires: [ tasks ]'
if ! projection_validation=$(WEALTH_LEDGER_WORKSPACE="$workspace" bash "$script_dir/verify-agent-projection.sh" 2>&1); then
fail "agent projection verification failed: $projection_validation"
fi
if [[ -d "$workspace/specs" ]]; then
if ! schema_validation=$(cd "$workspace/specs" && openspec schema validate wealth-ledger-sdd 2>&1); then
fail "wealth-ledger-sdd schema validation failed: $schema_validation"
+2 -21
View File
@@ -89,37 +89,18 @@ openspec status --store wealth-ledger-specs
Require explicit Change Owner approval and invalidate dependent approvals after upstream edits.'
apply_gate="$apply_gate"$'\n'"$planning_line"
mkdir -p "$fixture/specs/agent-projection/opencode"
cp -R "$fixture/.opencode/commands" "$fixture/specs/agent-projection/opencode/commands"
cp -R "$fixture/.opencode/skills" "$fixture/specs/agent-projection/opencode/skills"
run_verifier() {
WEALTH_LEDGER_WORKSPACE="$fixture" bash "$verifier"
}
run_verifier
rm "$fixture/specs/agent-projection/opencode/commands/opsx-apply.md"
if run_verifier; then
echo "expected missing canonical projection source to fail" >&2
exit 1
fi
cp "$fixture/.opencode/commands/opsx-apply.md" "$fixture/specs/agent-projection/opencode/commands/opsx-apply.md"
for path in \
.opencode/commands/opsx-propose.md \
specs/agent-projection/opencode/commands/opsx-propose.md; do
perl -0pi -e 's/^bash specs\/scripts\/verify-openspec-planning\.sh .*\n//m' "$fixture/$path"
done
perl -0pi -e 's/^bash specs\/scripts\/verify-openspec-planning\.sh .*\n//m' "$fixture/.opencode/commands/opsx-propose.md"
if run_verifier; then
echo "expected missing planning gate in an artifact entrypoint to fail" >&2
exit 1
fi
for path in \
.opencode/commands/opsx-propose.md \
specs/agent-projection/opencode/commands/opsx-propose.md; do
printf '%s\n' "$planning_line" >> "$fixture/$path"
done
printf '%s\n' "$planning_line" >> "$fixture/.opencode/commands/opsx-propose.md"
write_file "specs/openspec/.cli-version" '9.9.9'
if run_verifier; then
+5 -2
View File
@@ -4,8 +4,11 @@ set -euo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
workspace=$(cd "$script_dir/../.." && pwd -P)
verifier="$script_dir/verify-openspec-planning.sh"
source_change="$workspace/specs/openspec/changes/harden-openspec-sdd-quality"
changes_root="$workspace/specs/openspec/changes"
source_change="$changes_root/harden-openspec-sdd-quality"
if [[ ! -d "$source_change" ]]; then
source_change="$changes_root/archive/2026-08-26-harden-openspec-sdd-quality"
fi
prefix="planning-fixture-$$"
created_changes=('')
@@ -86,7 +89,7 @@ design_output=$(run_verifier "$design_change")
make_change required-rollback
required_rollback=$fixture_change
rm -f "$changes_root/$required_rollback/tasks.md"
perl -0pi -e 's/\| Status \| `N\/A` \|/| Status | `required` |/; s/(\| Verification \|)/| Trigger | Deployment fails the projection gate. |\n| Actions | Restore the previous projection. |\n| Data safety | No application data changes. |\n$1/' "$changes_root/$required_rollback/design.md"
perl -0pi -e 's/\| Status \| `N\/A` \|/| Status | `required` |/; s/(\| Verification \|)/| Trigger | Deployment fails the local gate. |\n| Actions | Restore the previous local state. |\n| Data safety | No application data changes. |\n$1/' "$changes_root/$required_rollback/design.md"
required_output=$(run_verifier "$required_rollback")
[[ "$required_output" == *'Planning stage verified: design'* ]]