feat: establish the Target architecture as a graph before code
Design is now approved before any infrastructure code is written (ADR-0005). A new target-architect Specialist produces one graph of Elements, Relationships and Checks; the diagram is rendered from it, deployment guidance must account for every Check, and validation gives a verdict per Check. Requirements, components, products and recommendations carry ids in data files, and a submission with a gap in the Requirements chain is refused. Also in this commit: - Customer cases group Executions, with an intent history per case - lesson candidates are captured when an Execution ends - evaluation gains chain, verdict, judged and interactive checks, and per-case thresholds - Terraform providers are cached between checks - the requirements analyst proposes defaults instead of asking - the legacy-baseline case and the checks that only read it are removed - ADR-0006 (Change requests) accepted; ADR-0004 and ADR-0007 proposed - plans for iterations 4 to 7 under .agents/plans/ Unproven with a real model: no evaluation run has completed on this design. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Local tools: Mermaid check and Terraform fmt/validate/plan in a scratch directory."""
|
||||
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -157,3 +158,88 @@ def test_local_tools_are_built_by_name_with_their_tier():
|
||||
}
|
||||
with pytest.raises(KeyError, match="terraform_apply"):
|
||||
local_tools(["terraform_apply"], TerraformRunner())
|
||||
|
||||
|
||||
# --- the provider cache ----------------------------------------------------------------
|
||||
|
||||
|
||||
def fake_terraform(tmp_path: Path) -> tuple[Path, Path]:
|
||||
"""A stand-in terraform that records the cache settings it was run with."""
|
||||
log = tmp_path / "calls.log"
|
||||
binary = tmp_path / "terraform"
|
||||
binary.write_text(
|
||||
"#!/bin/sh\n"
|
||||
f'echo "$1 cache=$TF_PLUGIN_CACHE_DIR '
|
||||
f'reuse=$TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE" >> {log}\n'
|
||||
'echo "Success! The configuration is valid."\n'
|
||||
)
|
||||
binary.chmod(0o755)
|
||||
return binary, log
|
||||
|
||||
|
||||
async def test_providers_are_cached_in_a_directory_the_runner_creates(tmp_path):
|
||||
binary, log = fake_terraform(tmp_path)
|
||||
cache = tmp_path / "not" / "yet" / "there"
|
||||
runner = TerraformRunner(binary=str(binary), plugin_cache_dir=str(cache))
|
||||
|
||||
result = await runner.validate(VALID_TF)
|
||||
|
||||
assert result.message.startswith("terraform validate passed")
|
||||
assert cache.is_dir()
|
||||
# Scratch directories have no lock file, so reuse must be allowed explicitly.
|
||||
assert log.read_text().splitlines() == [
|
||||
f"init cache={cache} reuse=true",
|
||||
f"validate cache={cache} reuse=true",
|
||||
]
|
||||
|
||||
|
||||
async def test_without_a_cache_directory_terraform_is_left_to_its_defaults(tmp_path):
|
||||
binary, log = fake_terraform(tmp_path)
|
||||
|
||||
await TerraformRunner(binary=str(binary)).validate(VALID_TF)
|
||||
|
||||
assert log.read_text().splitlines() == [
|
||||
"init cache= reuse=",
|
||||
"validate cache= reuse=",
|
||||
]
|
||||
|
||||
|
||||
async def test_concurrent_checks_install_into_the_cache_one_at_a_time(tmp_path):
|
||||
import asyncio
|
||||
|
||||
marker = tmp_path / "installing"
|
||||
overlaps = tmp_path / "overlaps"
|
||||
binary = tmp_path / "terraform"
|
||||
binary.write_text(
|
||||
"#!/bin/sh\n"
|
||||
'if [ "$1" = init ]; then\n'
|
||||
f" [ -e {marker} ] && echo overlap >> {overlaps}\n"
|
||||
f" touch {marker}; sleep 0.2; rm -f {marker}\n"
|
||||
"fi\n"
|
||||
"echo ok\n"
|
||||
)
|
||||
binary.chmod(0o755)
|
||||
runner = TerraformRunner(binary=str(binary), plugin_cache_dir=str(tmp_path / "c"))
|
||||
|
||||
await asyncio.gather(*(runner.validate(VALID_TF) for _ in range(3)))
|
||||
|
||||
assert not overlaps.exists()
|
||||
|
||||
|
||||
def test_the_cache_setting_resolves_under_the_repository_and_can_be_disabled():
|
||||
from app.config import Settings
|
||||
|
||||
default = Settings(_env_file=None)
|
||||
assert default.terraform_plugin_cache() == str(
|
||||
default.BASE_DIR / ".cache" / "terraform-plugins"
|
||||
)
|
||||
assert (
|
||||
Settings(_env_file=None, TF_PLUGIN_CACHE_DIR="").terraform_plugin_cache()
|
||||
is None
|
||||
)
|
||||
assert (
|
||||
Settings(
|
||||
_env_file=None, TF_PLUGIN_CACHE_DIR="/var/cache/tf"
|
||||
).terraform_plugin_cache()
|
||||
== "/var/cache/tf"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user