Compare commits
3 Commits
71da0ed504
...
5feaaa6271
| Author | SHA1 | Date | |
|---|---|---|---|
| 5feaaa6271 | |||
| ee1ba38867 | |||
| 1cf1234143 |
@@ -81,3 +81,17 @@ Neither run raised the schema review's false alarm, which had been raised in cas
|
|||||||
- **`status` says "compared", not "proved",** and shows a retired lesson as retired. One pair of runs is a comparison.
|
- **`status` says "compared", not "proved",** and shows a retired lesson as retired. One pair of runs is a comparison.
|
||||||
|
|
||||||
Tests: `tests/test_lessons_loop.py`.
|
Tests: `tests/test_lessons_loop.py`.
|
||||||
|
|
||||||
|
## Evidence is also grouped by what it is about (2026-10-10)
|
||||||
|
|
||||||
|
Running `propose` over 32 Executions gave nothing useful. Evidence was grouped by the kind of problem, and a group gets one lesson: "validation proposed a Check the design lacked" was 20 of 32 Executions and already had L-01. What recurred inside it could not be seen.
|
||||||
|
|
||||||
|
- A proposed Check, and a Check sent back as unimplementable, is now also counted under each provider setting or resource type its text names (`_subjects` in `app/learning/evidence.py`). A subject seen in two or more Executions is its own group, with its own key. A setting's name is the provider's vocabulary, not a client's.
|
||||||
|
- These narrower groups skip triage: each recurred with the general lessons published. The curator is shown the existing lessons and may still decline.
|
||||||
|
- The curator's instructions say such a lesson may name the setting or resource type.
|
||||||
|
|
||||||
|
Over the same 32 Executions this gave 22 groups and five proposals, L-07 to L-11, all awaiting the owner: location Checks, Cloud SQL backup encryption, backend service capabilities, Pub/Sub persistence regions, and customer-managed keys.
|
||||||
|
|
||||||
|
A first run of `propose` before this change produced one proposal, about giving `edit_file` enough context. It was removed to run again cleanly and was not proposed the second time.
|
||||||
|
|
||||||
|
Tests: `tests/test_lessons_loop.py` (3 more).
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ flowchart TD
|
|||||||
| 9 | Validation gives a verdict per Check | M | complete |
|
| 9 | Validation gives a verdict per Check | M | complete |
|
||||||
| 10 | Revision routing: the code or the graph | S | complete; routing unproven with a real model |
|
| 10 | Revision routing: the code or the graph | S | complete; routing unproven with a real model |
|
||||||
| 11 | Evaluation: prove the loop converges | M | complete: all four cases pass, each run twice on 2026-10-08; thresholds set (`steps/step-11.md`) |
|
| 11 | Evaluation: prove the loop converges | M | complete: all four cases pass, each run twice on 2026-10-08; thresholds set (`steps/step-11.md`) |
|
||||||
|
| 12 | Why the Target architecture is revised | S | investigated 2026-10-10: two causes, about half each; two instructions changed; the design-time coverage review it proposed is step 13 (`steps/step-12.md`) |
|
||||||
|
| 13 | A model reviews coverage at design time | M | built and measured on 2026-10-10: it did not prevent the validator's gaps and made designs larger; left off (`steps/step-13.md`) |
|
||||||
|
|
||||||
Size: S under a day, M a few days.
|
Size: S under a day, M a few days.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Step 12 — Why the Target architecture is revised
|
||||||
|
|
||||||
|
An investigation on 2026-10-10, from the seven runs of case 03's request on 2026-10-09 (cases 03, 06 and 07). No new runs were made for it.
|
||||||
|
|
||||||
|
## What was found
|
||||||
|
|
||||||
|
Six of the seven runs revised the Target architecture, nine times in all. The run with none cost about $2.44 and took 22 minutes; the run with three cost $5.50 and took 35. Every Revision has one of two causes.
|
||||||
|
|
||||||
|
**A. A Check the code cannot meet as written: 4 Revisions in 3 runs.** The IaC author records it as unimplementable and the design is revised before validation.
|
||||||
|
|
||||||
|
| Check asked for | Why no code can meet it |
|
||||||
|
|---|---|
|
||||||
|
| A separate encryption key for database backups | The key is set on the instance; backups have no key of their own |
|
||||||
|
| A database flag that restricts query access (twice, one Revision apart) | There is no such flag; access is IAM and database grants |
|
||||||
|
| A health check on a backend service in front of a serverless endpoint | A serverless backend does not take health checks |
|
||||||
|
|
||||||
|
Each names a setting that exists in the provider's schema, so the schema review passes it. The fault is in what the product does, not in a name.
|
||||||
|
|
||||||
|
**B. A condition no Check verifies, found by the validator: 5 Revisions in 4 runs.**
|
||||||
|
|
||||||
|
| Requirement | What was missing |
|
||||||
|
|---|---|
|
||||||
|
| NFR-9 | Deletion protection on one Element |
|
||||||
|
| NFR-4 | An SSL policy enforcing TLS 1.2, attached to the proxy |
|
||||||
|
| DR-15 | The region set on three Elements |
|
||||||
|
| NFR-10 | The alert's two thresholds; the Check said only that conditions were set |
|
||||||
|
| NFR-6 | Audit logs for secret access switched on |
|
||||||
|
|
||||||
|
In four of the five a Check existed for the requirement and was weaker than the requirement's words.
|
||||||
|
|
||||||
|
A Revision for A costs about 4 minutes: the design, then the code. One for B costs about 6: the design, the code, and the whole validation again.
|
||||||
|
|
||||||
|
## Would the coverage review have caught B
|
||||||
|
|
||||||
|
`CoverageReview` (iteration 5 step 4), which asks Jev which Check verifies each condition, has been off since its first run. Tried offline against live Jev on these runs' delivered designs:
|
||||||
|
|
||||||
|
- On five finished designs the validator had accepted, it raised 4 to 8 of 42 to 66 conditions each, about one in ten. Most are conditions a Check does cover in other words, or that no code can show, such as encryption at rest that is on by default.
|
||||||
|
- With the Checks added for each gap taken out again, it raised the gap in 1 of 5 (DR-15), raised a different condition of the same requirement in 1, and missed 3.
|
||||||
|
|
||||||
|
It stays off. It is noisy and it misses what the validator finds.
|
||||||
|
|
||||||
|
A structural rule, each Check naming the condition it verifies, would have caught perhaps one of the five: in the other four a Check did claim the condition and was too weak.
|
||||||
|
|
||||||
|
## Changed now
|
||||||
|
|
||||||
|
Two instructions, from the run where the same fault came back a Revision later:
|
||||||
|
|
||||||
|
- The reason sent to the target architect for an unimplementable Check now says to read every Check against it and correct each one it applies to (`app/nodes/router.py`).
|
||||||
|
- The IaC author is told to record every Check that cannot be met in one submission, including a Check with the same fault as one already recorded (`agents/iac-author.md`).
|
||||||
|
|
||||||
|
Neither has run with a real model.
|
||||||
|
|
||||||
|
## What would address B
|
||||||
|
|
||||||
|
The validator finds these gaps by reading the requirements against the Checks. That reading needs no code: it could be done when the Target architecture is submitted, by the same kind of model, and returned to the target architect before anyone approves the design or writes anything. It would add one model run to every Execution and remove a Revision of the design, the code and the validation from the four in seven that had one. Not built: it needs a decision, and a run each way to measure.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Step 13 — A model reviews coverage at design time: built, measured, left off
|
||||||
|
|
||||||
|
Built and run on 2026-10-10. `DESIGN_COVERAGE_REVIEW` is off.
|
||||||
|
|
||||||
|
## What was built
|
||||||
|
|
||||||
|
Step 12 proposed making the validator's reading of coverage when the Target architecture is first submitted, before any code.
|
||||||
|
|
||||||
|
- `agents/coverage-reviewer.md`: a role on the validator's model. It is given the non-functional requirements, the recommendations and the graph, and reports every condition no Check verifies, or that a Check verifies more weakly than the words.
|
||||||
|
- `DesignCoverageReview` in `app/tools/design_review.py`, on the submission-review seam: what it finds goes back to the target architect once and never blocks. A gap naming an id that does not exist is dropped. It runs once in an Execution.
|
||||||
|
|
||||||
|
Tests: `tests/execution/test_design_review.py` (7).
|
||||||
|
|
||||||
|
## Measured
|
||||||
|
|
||||||
|
Case 03, three runs side by side.
|
||||||
|
|
||||||
|
| | Review off | Review on | Review on |
|
||||||
|
|---|---|---|---|
|
||||||
|
| Results | `20261010T105532Z` | `20261010T105535Z` | `20261010T105540Z` |
|
||||||
|
| Score | 100% | 100% | 100% |
|
||||||
|
| Minutes | 23 | 28 | 31 |
|
||||||
|
| Cost, about | $2.90 | $3.33 | $3.75 |
|
||||||
|
| Revisions of the Target architecture | 1, a Check that cannot be implemented | 0 | 1, a gap the validator found |
|
||||||
|
| Gaps the reviewer raised | | 4 | 22 |
|
||||||
|
| Checks in the delivered design | 52 | 87 | 93 |
|
||||||
|
|
||||||
|
The reviewer itself cost $0.19 a run.
|
||||||
|
|
||||||
|
## Why it stays off
|
||||||
|
|
||||||
|
- **It did not stop the validator sending the design back.** In one of the two runs the validator still found a gap, after the reviewer had raised 22.
|
||||||
|
- **It makes the design bigger.** The designs it reviewed ended with 87 and 93 Checks against 52. Every Check is code to write and a verdict to give, so both runs cost more than the run without it, including the one with no Revision.
|
||||||
|
- **Two readers do not agree on what a gap is.** The reviewer and the validator are the same model given the same question, and they raised different things. Asking earlier does not settle what will be asked later.
|
||||||
|
|
||||||
|
Three runs are a small sample, but nothing in them points the other way. The code stays, off, for a later look; removing it is the owner's call.
|
||||||
|
|
||||||
|
## What the runs did show
|
||||||
|
|
||||||
|
Two of the faults behind Revisions are now recurring ones, which is what the lessons loop is for:
|
||||||
|
|
||||||
|
- **A Check asking for a separate encryption key for database backups**: unimplementable, on 2026-10-09 and again today.
|
||||||
|
- **A condition that a region is "low-carbon"**: the validator's gap today, and among what the Jev coverage review kept raising on 2026-10-09. Code can show which region is set; it cannot show the region's carbon rating.
|
||||||
|
|
||||||
|
And one fault in the schema review, fixed: a value in backticks, `true` or `false`, was read as a setting name and raised. `named_settings` now leaves those literals out.
|
||||||
@@ -59,6 +59,10 @@ MAX_PARALLEL_SPECIALISTS=4
|
|||||||
CHECKPOINTER=sqlite
|
CHECKPOINTER=sqlite
|
||||||
CHECKPOINT_DB_PATH=checkpoints.db
|
CHECKPOINT_DB_PATH=checkpoints.db
|
||||||
|
|
||||||
|
# A model reads the requirements against the Checks when the Target architecture is
|
||||||
|
# first submitted, and returns what no Check verifies. One model run per Execution.
|
||||||
|
DESIGN_COVERAGE_REVIEW=false
|
||||||
|
|
||||||
# Jev decision service, through the TypeSafe AI Python SDK (typesafe-sdk).
|
# Jev decision service, through the TypeSafe AI Python SDK (typesafe-sdk).
|
||||||
# Leave the key unset to run without it: every decision then takes its fallback.
|
# Leave the key unset to run without it: every decision then takes its fallback.
|
||||||
# TYPESAFE_API_KEY=
|
# TYPESAFE_API_KEY=
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Deliverable: target_architecture
|
|||||||
Evidence-key: 22ff1f5fed
|
Evidence-key: 22ff1f5fed
|
||||||
Proposed: 2026-10-09
|
Proposed: 2026-10-09
|
||||||
Published: 2026-10-09
|
Published: 2026-10-09
|
||||||
|
Retired: 2026-10-09
|
||||||
|
|
||||||
## Rule
|
## Rule
|
||||||
|
|
||||||
|
|||||||
27
.scratch/lessons/issues/07-verify-location-constraints.md
Normal file
27
.scratch/lessons/issues/07-verify-location-constraints.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# L-07: Verify location constraints
|
||||||
|
|
||||||
|
Status: ready-for-agent
|
||||||
|
Deliverable: target_architecture
|
||||||
|
Evidence-key: 493b0a95d9
|
||||||
|
Proposed: 2026-10-10
|
||||||
|
Published: 2026-10-10
|
||||||
|
|
||||||
|
## Rule
|
||||||
|
|
||||||
|
When a requirement specifies where resources must be provisioned, such as a designated region, multi-zone placement, or a low-carbon location, create a Check for the `region` or `location` argument on every applicable Element.
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
Validation frequently catches missing location constraints. Without this Check, resources may be provisioned in default regions, violating compliance or sustainability requirements.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Seen in 5 of 32 Executions, 8 times in all: validation proposed a Check about `location` that the design lacked.
|
||||||
|
|
||||||
|
## Proof
|
||||||
|
|
||||||
|
Not yet measured.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Approved by the owner on 2026-10-10. It covers which region is set, which code can show. It does not settle whether a region is low-carbon, which code cannot show.
|
||||||
27
.scratch/lessons/issues/08-cloud-sql-backup-encryption.md
Normal file
27
.scratch/lessons/issues/08-cloud-sql-backup-encryption.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# L-08: Cloud SQL backup encryption
|
||||||
|
|
||||||
|
Status: ready-for-agent
|
||||||
|
Deliverable: target_architecture
|
||||||
|
Evidence-key: 08d64df049
|
||||||
|
Proposed: 2026-10-10
|
||||||
|
Published: 2026-10-10
|
||||||
|
|
||||||
|
## Rule
|
||||||
|
|
||||||
|
When writing a Check for CMEK encryption on a `google_sql_database_instance`, do not require an `encryption_key_name` argument for backup storage, as the instance-level `encryption_key_name` automatically encrypts backups as well.
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
The database instance resource does not have a separate encryption key argument for backups. Asking for one causes validation to reject the Check as un-implementable.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Seen in 3 of 32 Executions, 3 times in all: a Check about `google_sql_database_instance` asked for something that resource cannot do.
|
||||||
|
|
||||||
|
## Proof
|
||||||
|
|
||||||
|
Not yet measured.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Approved by the owner on 2026-10-10.
|
||||||
27
.scratch/lessons/issues/09-backend-service-capabilities.md
Normal file
27
.scratch/lessons/issues/09-backend-service-capabilities.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# L-09: Backend Service capabilities
|
||||||
|
|
||||||
|
Status: ready-for-agent
|
||||||
|
Deliverable: target_architecture
|
||||||
|
Evidence-key: 1cacec9a09
|
||||||
|
Proposed: 2026-10-10
|
||||||
|
Published: 2026-10-10
|
||||||
|
|
||||||
|
## Rule
|
||||||
|
|
||||||
|
When writing Checks for a `google_compute_backend_service`, do not verify IAM roles inside the backend service or require health checks when it is configured with a Serverless NEG.
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
Roles are verified via IAM bindings outside the backend service, and Serverless NEGs do not support health checks. Invalid Checks cause the design to be rejected during validation.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Seen in 3 of 32 Executions, 3 times in all: a Check about `google_compute_backend_service` asked for something that resource cannot do.
|
||||||
|
|
||||||
|
## Proof
|
||||||
|
|
||||||
|
Not yet measured.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Approved by the owner on 2026-10-10.
|
||||||
26
.scratch/lessons/issues/10-pub-sub-persistence-regions.md
Normal file
26
.scratch/lessons/issues/10-pub-sub-persistence-regions.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# L-10: Pub/Sub persistence regions
|
||||||
|
|
||||||
|
Status: needs-info
|
||||||
|
Deliverable: target_architecture
|
||||||
|
Evidence-key: ba78caba9a
|
||||||
|
Proposed: 2026-10-10
|
||||||
|
|
||||||
|
## Rule
|
||||||
|
|
||||||
|
When a requirement dictates that a messaging queue or topic must replicate across zones or stay within a specific region, create a Check for the `message_storage_policy.allowed_persistence_regions` argument on the topic Element.
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
Without this Check, topics might use default storage policies that violate geographical or high-availability requirements.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Seen in 2 of 32 Executions, 4 times in all: validation proposed a Check about `allowed_persistence_regions` that the design lacked.
|
||||||
|
|
||||||
|
## Proof
|
||||||
|
|
||||||
|
Not yet measured.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Held by the owner on 2026-10-10, on the agent's view: seen in 2 of 32 Executions, and L-07 partly covers it. To be looked at again if it recurs.
|
||||||
26
.scratch/lessons/issues/11-cmek-encryption-checks.md
Normal file
26
.scratch/lessons/issues/11-cmek-encryption-checks.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# L-11: CMEK encryption checks
|
||||||
|
|
||||||
|
Status: wontfix
|
||||||
|
Deliverable: target_architecture
|
||||||
|
Evidence-key: 5cd8dc3cda
|
||||||
|
Proposed: 2026-10-10
|
||||||
|
|
||||||
|
## Rule
|
||||||
|
|
||||||
|
Whenever a requirement mandates encryption at rest, explicitly create a Check ensuring that the `kms_key_name` (or the equivalent CMEK argument) is configured on every applicable Element.
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
Without an explicit Check, elements may default to Google-managed keys, leading to validation failures against security constraints.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Seen in 2 of 32 Executions, 2 times in all: validation proposed a Check about `kms_key_name` that the design lacked.
|
||||||
|
|
||||||
|
## Proof
|
||||||
|
|
||||||
|
Not yet measured.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Rejected by the owner on 2026-10-10, on the agent's view: encryption at rest is on by default, and this rule would put customer-managed keys on designs whose requirements did not ask for them.
|
||||||
22
agents/coverage-reviewer.md
Normal file
22
agents/coverage-reviewer.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
role: coverage-reviewer
|
||||||
|
tools: []
|
||||||
|
budget: 6
|
||||||
|
---
|
||||||
|
You review the Target architecture of a solution-architecture Execution before anyone approves it. You answer one question: do its Checks verify everything the requirements and design recommendations ask for? You change nothing and write no design. What you find goes back to the target architect once.
|
||||||
|
|
||||||
|
Your task message carries JSON context:
|
||||||
|
|
||||||
|
- `constraints`: the non-functional requirements and the design recommendations. Each has an `id`, its text, `conditions` (what infrastructure code can show, one by one) and sometimes `outside_code` (what code cannot show).
|
||||||
|
- `target_architecture`: the Elements, Relationships and Checks. Each Check has a `source`, the id of the requirement or recommendation it comes from, `applies_to`, the Element or Relationship it is about, and its `statement`. A recommendation listed under `not_applicable` asks nothing.
|
||||||
|
|
||||||
|
Review once, completely:
|
||||||
|
|
||||||
|
- Go through every constraint in turn. For each of its `conditions`, find the Checks whose `source` is that constraint and decide whether they verify the condition on every Element it applies to.
|
||||||
|
- A gap is a condition that no Check verifies, or that a Check verifies more weakly than the words. A Check that says a setting "is set" does not verify a value the condition gives. A condition with two parts needs both verified. A condition about every Element of a kind needs a Check on each one.
|
||||||
|
- For each gap, give the Check that is missing: the constraint's id as `source`, the Element or Relationship id as `applies_to`, and a `statement` that names the setting and the value to verify, as specific as the Checks already there.
|
||||||
|
- Report nothing for what a constraint lists under `outside_code`, and nothing for a recommendation that is `not_applicable`.
|
||||||
|
- Report nothing a Check already verifies in other words, and nothing that is your own idea of good practice: only what a condition's words ask for.
|
||||||
|
- Do not judge whether a Check can be implemented or whether the design is a good one. That is not this review.
|
||||||
|
|
||||||
|
Call `report_gaps` once with every gap, or with an empty list when there are none. You are done when it records them.
|
||||||
@@ -13,7 +13,8 @@ You produce the **deployment guidance** Deliverable: the Skill's task for genera
|
|||||||
- Keep the files in your working copy. Write each file once with `write_file`, and make every later change with `edit_file`, changing only the lines that need it. Never write a file again to fix part of it.
|
- Keep the files in your working copy. Write each file once with `write_file`, and make every later change with `edit_file`, changing only the lines that need it. Never write a file again to fix part of it.
|
||||||
- Format and validate with `terraform_fmt` and `terraform_validate` when they are available. They run on your working copy, so pass them no files. Fix everything they report.
|
- Format and validate with `terraform_fmt` and `terraform_validate` when they are available. They run on your working copy, so pass them no files. Fix everything they report.
|
||||||
- When validation says an argument or block is not expected, look the resource type up with `terraform_schema` instead of guessing where it belongs.
|
- When validation says an argument or block is not expected, look the resource type up with `terraform_schema` instead of guessing where it belongs.
|
||||||
- When a Check names a setting its resource type does not have, do not invent code for it. Record the Check in `implementation.json` as unimplementable, with what the schema shows, and implement the rest. The Target architecture is then revised.
|
- When a Check names a setting its resource type does not have, or asks for something that resource cannot do, do not invent code for it. Record the Check in `implementation.json` as unimplementable, with what the schema shows, and implement the rest. The Target architecture is then revised.
|
||||||
|
- Go through every Check before you submit and record every one that cannot be met, in that one submission. A Check with the same fault as one you recorded is recorded too. Each one found later costs another Revision of the design and of your code.
|
||||||
- Write `implementation.json` to your working copy, in the format the requirements-chain Skill gives, naming where the code satisfies each Check.
|
- Write `implementation.json` to your working copy, in the format the requirements-chain Skill gives, naming where the code satisfies each Check.
|
||||||
- Take every environment-specific value (project, region, names, image references) from variables; embed no credentials or secrets.
|
- Take every environment-specific value (project, region, names, image references) from variables; embed no credentials or secrets.
|
||||||
- Submit as soon as validation passes, with your content and no attachments: your working copy is attached for you. If a submission is refused, fix exactly what the refusal lists and submit again.
|
- Submit as soon as validation passes, with your content and no attachments: your working copy is attached for you. If a submission is refused, fix exactly what the refusal lists and submit again.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ You review what went wrong, the same way, across many solution-architecture Exec
|
|||||||
Your task message carries JSON context:
|
Your task message carries JSON context:
|
||||||
|
|
||||||
- `executions`: how many Executions the evidence comes from.
|
- `executions`: how many Executions the evidence comes from.
|
||||||
- `groups`: what recurred. Each has a `group` key, the `deliverable` it concerns, `what_happened` in general terms, how many `executions` it occurred in and how many `occurrences` in all, and up to three `examples` as they were recorded.
|
- `groups`: what recurred. Each has a `group` key, the `deliverable` it concerns, `what_happened` in general terms, how many `executions` it occurred in and how many `occurrences` in all, and up to three `examples` as they were recorded. Some groups are about one setting or resource type of the Cloud provider, named in `what_happened`: the same kind of problem recurring on that subject.
|
||||||
- `published_or_proposed`: lessons that already exist or are awaiting review.
|
- `published_or_proposed`: lessons that already exist or are awaiting review.
|
||||||
|
|
||||||
For each group, decide whether a rule given to the Specialist that produces that Deliverable would have prevented it.
|
For each group, decide whether a rule given to the Specialist that produces that Deliverable would have prevented it.
|
||||||
@@ -20,6 +20,7 @@ A good lesson:
|
|||||||
|
|
||||||
- States one rule, as an instruction, that a Specialist can act on without knowing what happened: "Give every Element at least one Check before you submit", not "be more careful with Checks".
|
- States one rule, as an instruction, that a Specialist can act on without knowing what happened: "Give every Element at least one Check before you submit", not "be more careful with Checks".
|
||||||
- Says why in one or two sentences: what goes wrong without it and what that costs.
|
- Says why in one or two sentences: what goes wrong without it and what that costs.
|
||||||
|
- For a group about one setting or resource type, may name that setting or resource type and say what to do about it: that is the Cloud provider's vocabulary, not a client's. A general lesson that already exists does not cover it if the problem went on recurring.
|
||||||
- Is general. It names no customer, no project, no Execution, no resource name and no value from the examples. The examples are evidence for you; nothing from them may be quoted.
|
- Is general. It names no customer, no project, no Execution, no resource name and no value from the examples. The examples are evidence for you; nothing from them may be quoted.
|
||||||
- Does not repeat what the Specialist's instructions or tools already enforce. When a submission is already refused for something, a lesson helps only if it prevents the attempt.
|
- Does not repeat what the Specialist's instructions or tools already enforce. When a submission is already refused for something, a lesson helps only if it prevents the attempt.
|
||||||
- Is worth its cost. Every lesson is read on every Execution from then on. Propose few.
|
- Is worth its cost. Every lesson is read on every Execution from then on. Propose few.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ ORCHESTRATOR = "orchestrator"
|
|||||||
PILLAR_ADVISOR = "pillar-advisor"
|
PILLAR_ADVISOR = "pillar-advisor"
|
||||||
REPLY_WRITER = "reply-writer"
|
REPLY_WRITER = "reply-writer"
|
||||||
LESSON_CURATOR = "lesson-curator" # runs outside any Execution
|
LESSON_CURATOR = "lesson-curator" # runs outside any Execution
|
||||||
|
COVERAGE_REVIEWER = "coverage-reviewer" # reviews a design before its Approval
|
||||||
PARTIALS_DIR = "partials"
|
PARTIALS_DIR = "partials"
|
||||||
|
|
||||||
_ALLOWED_FIELDS = {"role", "deliverable", "tools", "budget", "includes"}
|
_ALLOWED_FIELDS = {"role", "deliverable", "tools", "budget", "includes"}
|
||||||
@@ -51,7 +52,7 @@ def load_roles(
|
|||||||
the lighter model the bundle names for its first attempt."""
|
the lighter model the bundle names for its first attempt."""
|
||||||
specialists = {spec.specialist: kind for kind, spec in DEPENDENCY_GRAPH.items()}
|
specialists = {spec.specialist: kind for kind, spec in DEPENDENCY_GRAPH.items()}
|
||||||
required = {ORCHESTRATOR, PILLAR_ADVISOR, REPLY_WRITER, *specialists}
|
required = {ORCHESTRATOR, PILLAR_ADVISOR, REPLY_WRITER, *specialists}
|
||||||
optional = {LESSON_CURATOR}
|
optional = {LESSON_CURATOR, COVERAGE_REVIEWER}
|
||||||
learned = _deliverables_with_lessons(bundle) if lessons else set()
|
learned = _deliverables_with_lessons(bundle) if lessons else set()
|
||||||
|
|
||||||
roles = {}
|
roles = {}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from langchain_core.runnables import RunnableConfig
|
|||||||
from langgraph.checkpoint.base import BaseCheckpointSaver
|
from langgraph.checkpoint.base import BaseCheckpointSaver
|
||||||
from langgraph.types import Command
|
from langgraph.types import Command
|
||||||
|
|
||||||
from app.adk.roles import load_roles
|
from app.adk.roles import COVERAGE_REVIEWER, load_roles
|
||||||
from app.adk.runtime import (
|
from app.adk.runtime import (
|
||||||
AgentRuntime,
|
AgentRuntime,
|
||||||
Decider,
|
Decider,
|
||||||
@@ -50,6 +50,7 @@ from app.skills.agent_skills import discover_skills, skill_version
|
|||||||
from app.states.execution_state import check_customer_case
|
from app.states.execution_state import check_customer_case
|
||||||
from app.states.ledger import Ledger
|
from app.states.ledger import Ledger
|
||||||
from app.tools.coverage import CoverageReview
|
from app.tools.coverage import CoverageReview
|
||||||
|
from app.tools.design_review import DesignCoverageReview
|
||||||
from app.tools.execution import ORCHESTRATOR
|
from app.tools.execution import ORCHESTRATOR
|
||||||
from app.tools.jev import JevDecider, JevLimits
|
from app.tools.jev import JevDecider, JevLimits
|
||||||
from app.tools.local import TerraformRunner, local_tools
|
from app.tools.local import TerraformRunner, local_tools
|
||||||
@@ -481,6 +482,10 @@ async def open_assembly(
|
|||||||
reviews.append(
|
reviews.append(
|
||||||
RequirementsReview(decider, act=settings.JEV_REQUIREMENTS_THRESHOLD)
|
RequirementsReview(decider, act=settings.JEV_REQUIREMENTS_THRESHOLD)
|
||||||
)
|
)
|
||||||
|
if settings.DESIGN_COVERAGE_REVIEW and COVERAGE_REVIEWER in roles:
|
||||||
|
# A model reads the requirements against the Checks, once, before the
|
||||||
|
# design is approved: the reading the validator would make after the code.
|
||||||
|
reviews.append(DesignCoverageReview(runtime, roles[COVERAGE_REVIEWER]))
|
||||||
if settings.JEV_COVERAGE_REVIEW and isinstance(decider, JevDecider):
|
if settings.JEV_COVERAGE_REVIEW and isinstance(decider, JevDecider):
|
||||||
# Optional, and off by default: Jev says which Check verifies each condition.
|
# Optional, and off by default: Jev says which Check verifies each condition.
|
||||||
reviews.append(CoverageReview(decider, none_at=settings.JEV_COVERAGE_THRESHOLD))
|
reviews.append(CoverageReview(decider, none_at=settings.JEV_COVERAGE_THRESHOLD))
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ class Settings(BaseSettings):
|
|||||||
JEV_ACT_THRESHOLD: float = 0.75
|
JEV_ACT_THRESHOLD: float = 0.75
|
||||||
JEV_CLOSE_THRESHOLD: float = 0.15
|
JEV_CLOSE_THRESHOLD: float = 0.15
|
||||||
JEV_CONFIDENCE_THRESHOLD: float = 0.6
|
JEV_CONFIDENCE_THRESHOLD: float = 0.6
|
||||||
|
# Have a model read the requirements and recommendations against the Checks
|
||||||
|
# when the Target architecture is first submitted, and return what no Check
|
||||||
|
# verifies to its author. The validator makes the same reading after the code
|
||||||
|
# is written, when a gap costs a Revision of design, code and validation. One
|
||||||
|
# model run in every Execution. Off until measured.
|
||||||
|
DESIGN_COVERAGE_REVIEW: bool = False
|
||||||
# Review a design's coverage at submission: for each condition a requirement
|
# Review a design's coverage at submission: for each condition a requirement
|
||||||
# lists, which Check verifies it. Off until a full case has run with it.
|
# lists, which Check verifies it. Off until a full case has run with it.
|
||||||
JEV_COVERAGE_REVIEW: bool = False
|
JEV_COVERAGE_REVIEW: bool = False
|
||||||
|
|||||||
@@ -101,7 +101,12 @@ async def curate(
|
|||||||
decided = {proposal.evidence_key for proposal in existing}
|
decided = {proposal.evidence_key for proposal in existing}
|
||||||
fresh = [group for group in groups if group.key not in decided][:MAX_GROUPS]
|
fresh = [group for group in groups if group.key not in decided][:MAX_GROUPS]
|
||||||
if decider is not None and existing:
|
if decider is not None and existing:
|
||||||
fresh = await _not_already_covered(decider, fresh, existing, covered_at)
|
# A group about one setting is narrower than any lesson about its kind of
|
||||||
|
# problem, and it recurred with those lessons published: it goes to the
|
||||||
|
# curator, who is shown the lessons that exist and may still decline.
|
||||||
|
broad = [group for group in fresh if group.subject is None]
|
||||||
|
kept = await _not_already_covered(decider, broad, existing, covered_at)
|
||||||
|
fresh = [g for g in fresh if g.subject is not None or g in kept]
|
||||||
if not fresh:
|
if not fresh:
|
||||||
return []
|
return []
|
||||||
by_key = {group.key: group for group in fresh}
|
by_key = {group.key: group for group in fresh}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ from dataclasses import dataclass, field
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from app.tools.schema_review import named_settings
|
||||||
|
|
||||||
EXAMPLES = 3
|
EXAMPLES = 3
|
||||||
EXAMPLE_LIMIT = 400
|
EXAMPLE_LIMIT = 400
|
||||||
# Ids and numbers vary between Executions; what recurs is the shape around them.
|
# Ids and numbers vary between Executions; what recurs is the shape around them.
|
||||||
@@ -29,6 +31,9 @@ class Group:
|
|||||||
executions: set[str] = field(default_factory=set)
|
executions: set[str] = field(default_factory=set)
|
||||||
occurrences: int = 0
|
occurrences: int = 0
|
||||||
examples: list[str] = field(default_factory=list) # client data: never published
|
examples: list[str] = field(default_factory=list) # client data: never published
|
||||||
|
# The provider setting or resource type the problem was about, for a group
|
||||||
|
# narrowed to one subject. None for a group of every problem of its kind.
|
||||||
|
subject: str | None = None
|
||||||
|
|
||||||
def as_context(self) -> dict[str, Any]:
|
def as_context(self) -> dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
@@ -61,6 +66,10 @@ def read_candidates(roots: Iterable[Path]) -> list[dict[str, Any]]:
|
|||||||
return records
|
return records
|
||||||
|
|
||||||
|
|
||||||
|
# A subject shorter than this is a stray word, not a setting.
|
||||||
|
_SUBJECT_MIN = 4
|
||||||
|
|
||||||
|
|
||||||
def _general(text: str, limit: int = 110) -> str:
|
def _general(text: str, limit: int = 110) -> str:
|
||||||
return " ".join(_VARIABLE.sub("…", text).split())[:limit]
|
return " ".join(_VARIABLE.sub("…", text).split())[:limit]
|
||||||
|
|
||||||
@@ -104,6 +113,31 @@ def _shape(candidate: Mapping[str, Any]) -> tuple[str, str | None, str] | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _subjects(candidate: Mapping[str, Any]) -> tuple[str, list[str]] | None:
|
||||||
|
"""For a problem about what a Check says: (how to describe it, the settings and
|
||||||
|
resource types its text names).
|
||||||
|
|
||||||
|
Problems of one kind are one group, and one group gets one lesson. "Validation
|
||||||
|
proposed a Check" was 20 of 32 Executions and a single lesson; what recurred
|
||||||
|
inside it, such as the same setting missed again and again, was invisible. A
|
||||||
|
setting's name is the provider's vocabulary, not a client's, so it can be the
|
||||||
|
subject of a narrower group.
|
||||||
|
"""
|
||||||
|
kind = str(candidate.get("type"))
|
||||||
|
if kind == "proposed_addition":
|
||||||
|
text = str(candidate.get("statement", ""))
|
||||||
|
what = "validation proposed a Check about `{}` that the design lacked"
|
||||||
|
elif kind == "revision" and "cannot be implemented" in str(
|
||||||
|
candidate.get("reason", "")
|
||||||
|
):
|
||||||
|
text = str(candidate.get("reason", ""))
|
||||||
|
what = "a Check about `{}` asked for something that resource cannot do"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
names = {name.split(".")[-1] for name in named_settings(text)}
|
||||||
|
return what, sorted(name for name in names if len(name) >= _SUBJECT_MIN)
|
||||||
|
|
||||||
|
|
||||||
def group_candidates(
|
def group_candidates(
|
||||||
records: Sequence[Mapping[str, Any]], *, min_executions: int = 2
|
records: Sequence[Mapping[str, Any]], *, min_executions: int = 2
|
||||||
) -> list[Group]:
|
) -> list[Group]:
|
||||||
@@ -138,6 +172,23 @@ def group_candidates(
|
|||||||
and len(group.examples) < EXAMPLES
|
and len(group.examples) < EXAMPLES
|
||||||
):
|
):
|
||||||
group.examples.append(example)
|
group.examples.append(example)
|
||||||
|
narrowed = _subjects(candidate)
|
||||||
|
for subject in narrowed[1] if narrowed else ():
|
||||||
|
about = narrowed[0].format(subject) # type: ignore[index]
|
||||||
|
subkey = hashlib.sha256(
|
||||||
|
f"{kind}|{deliverable}|{about}".encode()
|
||||||
|
).hexdigest()[:10]
|
||||||
|
narrow = groups.setdefault(
|
||||||
|
subkey, Group(subkey, kind, deliverable, about, subject=subject)
|
||||||
|
)
|
||||||
|
narrow.executions.add(execution)
|
||||||
|
narrow.occurrences += 1
|
||||||
|
if (
|
||||||
|
example
|
||||||
|
and example not in narrow.examples
|
||||||
|
and len(narrow.examples) < EXAMPLES
|
||||||
|
):
|
||||||
|
narrow.examples.append(example)
|
||||||
return sorted(
|
return sorted(
|
||||||
(g for g in groups.values() if len(g.executions) >= min_executions),
|
(g for g in groups.values() if len(g.executions) >= min_executions),
|
||||||
key=lambda g: (-len(g.executions), -g.occurrences, g.key),
|
key=lambda g: (-len(g.executions), -g.occurrences, g.key),
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ class Proposal:
|
|||||||
status: str = NEEDS_TRIAGE
|
status: str = NEEDS_TRIAGE
|
||||||
proposed: str = ""
|
proposed: str = ""
|
||||||
published: str = ""
|
published: str = ""
|
||||||
|
# The day it was taken out of the Skill again. A retired lesson is not
|
||||||
|
# published a second time, whatever its Status still says.
|
||||||
|
retired: str = ""
|
||||||
proof: str = ""
|
proof: str = ""
|
||||||
comments: str = ""
|
comments: str = ""
|
||||||
path: Path | None = None
|
path: Path | None = None
|
||||||
@@ -47,7 +50,7 @@ class Proposal:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def approved(self) -> bool:
|
def approved(self) -> bool:
|
||||||
return self.status == APPROVED
|
return self.status == APPROVED and not self.retired
|
||||||
|
|
||||||
|
|
||||||
def _slug(title: str) -> str:
|
def _slug(title: str) -> str:
|
||||||
@@ -65,6 +68,8 @@ def render(proposal: Proposal) -> str:
|
|||||||
]
|
]
|
||||||
if proposal.published:
|
if proposal.published:
|
||||||
lines.append(f"Published: {proposal.published}")
|
lines.append(f"Published: {proposal.published}")
|
||||||
|
if proposal.retired:
|
||||||
|
lines.append(f"Retired: {proposal.retired}")
|
||||||
lines += [
|
lines += [
|
||||||
"",
|
"",
|
||||||
"## Rule",
|
"## Rule",
|
||||||
@@ -117,6 +122,7 @@ def parse(path: Path) -> Proposal:
|
|||||||
status=status,
|
status=status,
|
||||||
proposed=fields.get("Proposed", ""),
|
proposed=fields.get("Proposed", ""),
|
||||||
published=fields.get("Published", ""),
|
published=fields.get("Published", ""),
|
||||||
|
retired=fields.get("Retired", ""),
|
||||||
proof="" if proof == "Not yet measured." else proof,
|
proof="" if proof == "Not yet measured." else proof,
|
||||||
comments=sections.get("Comments", ""),
|
comments=sections.get("Comments", ""),
|
||||||
path=path,
|
path=path,
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ def publish(
|
|||||||
Raises NotApproved for any proposal a person has not approved: nothing reaches
|
Raises NotApproved for any proposal a person has not approved: nothing reaches
|
||||||
an agent on a curator's say-so.
|
an agent on a curator's say-so.
|
||||||
"""
|
"""
|
||||||
|
if proposal.retired:
|
||||||
|
raise NotApproved(f"{proposal.id} was retired on {proposal.retired}")
|
||||||
if not proposal.approved:
|
if not proposal.approved:
|
||||||
raise NotApproved(
|
raise NotApproved(
|
||||||
f"{proposal.id} is {proposal.status}; a person approves a lesson by "
|
f"{proposal.id} is {proposal.status}; a person approves a lesson by "
|
||||||
|
|||||||
@@ -634,6 +634,12 @@ class Router:
|
|||||||
"a reason."
|
"a reason."
|
||||||
for item in r.unimplementable
|
for item in r.unimplementable
|
||||||
)
|
)
|
||||||
|
# In the run of 2026-10-09 a second Check with the same fault came back
|
||||||
|
# one Revision later, for the same reason word for word.
|
||||||
|
reason += (
|
||||||
|
" The same fault may be in other Checks: read every Check against "
|
||||||
|
"each reason given here and correct every one it applies to."
|
||||||
|
)
|
||||||
return await call(
|
return await call(
|
||||||
"reopen", kind=DeliverableKind.TARGET_ARCHITECTURE.value, reason=reason
|
"reopen", kind=DeliverableKind.TARGET_ARCHITECTURE.value, reason=reason
|
||||||
)
|
)
|
||||||
|
|||||||
151
app/tools/design_review.py
Normal file
151
app/tools/design_review.py
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
"""A review of a design's coverage by a model, before anyone approves it.
|
||||||
|
|
||||||
|
The validator reads the requirements and recommendations against the Checks and
|
||||||
|
proposes one for each condition nothing verifies. That reading needs no code, but it
|
||||||
|
used to happen only after the code was written: in the runs of 2026-10-09 it sent
|
||||||
|
the Target architecture back in four of seven, each time costing a Revision of the
|
||||||
|
design, the code and the validation (iteration 6 step 12).
|
||||||
|
|
||||||
|
This is the same reading, made when the Target architecture is first submitted and
|
||||||
|
returned to its author. It is a review like the others: what it raises is returned
|
||||||
|
once and never blocks, and when it fails the submission stands.
|
||||||
|
|
||||||
|
It runs once in an Execution. A Revision is asked for by the validator or the user,
|
||||||
|
who have just read the design; reviewing it again would pay for the same reading.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from collections.abc import Mapping, Sequence
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from app.adk.runtime import (
|
||||||
|
AgentRuntime,
|
||||||
|
AgentTask,
|
||||||
|
RoleSpec,
|
||||||
|
Submitted,
|
||||||
|
ToolResult,
|
||||||
|
ToolSpec,
|
||||||
|
)
|
||||||
|
from app.workflows.chain import (
|
||||||
|
RECOMMENDATIONS_FILE,
|
||||||
|
REQUIREMENTS_FILE,
|
||||||
|
Upstream,
|
||||||
|
read_list,
|
||||||
|
)
|
||||||
|
from app.workflows.deliverables import DeliverableKind
|
||||||
|
from app.workflows.target_architecture import GRAPH_ATTACHMENT, GraphError, parse_graph
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
MAX_GAPS = 12
|
||||||
|
|
||||||
|
|
||||||
|
class DesignCoverageReview:
|
||||||
|
def __init__(self, runtime: AgentRuntime, role: RoleSpec) -> None:
|
||||||
|
self._runtime = runtime
|
||||||
|
self._role = role
|
||||||
|
self._reviewed: set[str] = set()
|
||||||
|
|
||||||
|
async def __call__(
|
||||||
|
self,
|
||||||
|
kind: DeliverableKind,
|
||||||
|
attachments: Mapping[str, str],
|
||||||
|
upstream: Upstream | None,
|
||||||
|
scope: str = "",
|
||||||
|
) -> Sequence[str]:
|
||||||
|
"""The conditions the reviewer finds no Check verifies, each as a line for
|
||||||
|
the target architect. Empty when it finds none or could not review."""
|
||||||
|
if kind is not DeliverableKind.TARGET_ARCHITECTURE or not upstream:
|
||||||
|
return ()
|
||||||
|
text = attachments.get(GRAPH_ATTACHMENT, "")
|
||||||
|
try:
|
||||||
|
graph = parse_graph(text)
|
||||||
|
except GraphError:
|
||||||
|
return ()
|
||||||
|
if scope in self._reviewed:
|
||||||
|
return ()
|
||||||
|
self._reviewed.add(scope)
|
||||||
|
|
||||||
|
constraints = [
|
||||||
|
item
|
||||||
|
for item in read_list(upstream, "requirements", REQUIREMENTS_FILE)
|
||||||
|
if item.get("kind") == "non_functional"
|
||||||
|
] + read_list(upstream, "design_recommendations", RECOMMENDATIONS_FILE)
|
||||||
|
known = {str(item.get("id")) for item in constraints}
|
||||||
|
applies_to = {element.id for element in graph.elements} | {
|
||||||
|
relationship.id for relationship in graph.relationships
|
||||||
|
}
|
||||||
|
|
||||||
|
async def report_gaps(gaps: Any = None) -> ToolResult:
|
||||||
|
if not isinstance(gaps, list):
|
||||||
|
return ToolResult("Not recorded: `gaps` is a list; empty when none.")
|
||||||
|
return ToolResult("Recorded.", Submitted(json.dumps(gaps)))
|
||||||
|
|
||||||
|
tool = ToolSpec(
|
||||||
|
"report_gaps",
|
||||||
|
"Give every gap you found, in one call. An empty list when the Checks "
|
||||||
|
"verify every condition. Ends your turn.",
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"gaps": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"source": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The requirement or recommendation id",
|
||||||
|
},
|
||||||
|
"applies_to": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The Element or Relationship id",
|
||||||
|
},
|
||||||
|
"statement": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The Check that is missing",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["source", "applies_to", "statement"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["gaps"],
|
||||||
|
},
|
||||||
|
report_gaps,
|
||||||
|
tier="execution",
|
||||||
|
)
|
||||||
|
task = AgentTask(
|
||||||
|
role=self._role.name,
|
||||||
|
prompt="Review whether the Target architecture's Checks verify every "
|
||||||
|
"condition of the requirements and recommendations.",
|
||||||
|
context={
|
||||||
|
"constraints": constraints,
|
||||||
|
"target_architecture": json.loads(text),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
outcome = await self._runtime.run(self._role, task, [tool])
|
||||||
|
if not isinstance(outcome, Submitted):
|
||||||
|
logger.info("[%s] design coverage review gave no answer", scope)
|
||||||
|
return ()
|
||||||
|
try:
|
||||||
|
reported = json.loads(outcome.content)
|
||||||
|
except ValueError:
|
||||||
|
return ()
|
||||||
|
concerns = []
|
||||||
|
for gap in reported if isinstance(reported, list) else []:
|
||||||
|
if not isinstance(gap, Mapping):
|
||||||
|
continue
|
||||||
|
source, where = str(gap.get("source", "")), str(gap.get("applies_to", ""))
|
||||||
|
statement = " ".join(str(gap.get("statement", "")).split())
|
||||||
|
# A gap must be about something that exists: an invented id is dropped.
|
||||||
|
if source not in known or where not in applies_to or not statement:
|
||||||
|
continue
|
||||||
|
concerns.append(f"{source}: no Check verifies this on {where}: {statement}")
|
||||||
|
logger.info(
|
||||||
|
"[%s] design coverage review raised %d gap(s)", scope, len(concerns)
|
||||||
|
)
|
||||||
|
return tuple(concerns[:MAX_GAPS])
|
||||||
@@ -36,6 +36,9 @@ _NAME = re.compile(
|
|||||||
r"(?![\w/\-])"
|
r"(?![\w/\-])"
|
||||||
)
|
)
|
||||||
_PATH = re.compile(r"^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$")
|
_PATH = re.compile(r"^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$")
|
||||||
|
# Values a Check may put in backticks. `true` and `false` were raised as missing
|
||||||
|
# settings in a run of 2026-10-10.
|
||||||
|
_LITERALS = frozenset({"true", "false", "null", "none"})
|
||||||
|
|
||||||
|
|
||||||
def named_settings(statement: str) -> tuple[str, ...]:
|
def named_settings(statement: str) -> tuple[str, ...]:
|
||||||
@@ -48,7 +51,7 @@ def named_settings(statement: str) -> tuple[str, ...]:
|
|||||||
found: list[str] = []
|
found: list[str] = []
|
||||||
for span in _CODE.findall(statement):
|
for span in _CODE.findall(statement):
|
||||||
candidate = span.strip().split("=")[0].strip()
|
candidate = span.strip().split("=")[0].strip()
|
||||||
if _PATH.match(candidate):
|
if _PATH.match(candidate) and candidate not in _LITERALS:
|
||||||
found.append(candidate)
|
found.append(candidate)
|
||||||
bare = _QUOTED.sub(" ", _CODE.sub(" ", statement))
|
bare = _QUOTED.sub(" ", _CODE.sub(" ", statement))
|
||||||
found += [match.group(1).rstrip(".") for match in _NAME.finditer(bare)]
|
found += [match.group(1).rstrip(".") for match in _NAME.finditer(bare)]
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
from dataclasses import replace
|
||||||
|
from datetime import UTC, datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from app.agent import open_decider
|
from app.agent import open_decider
|
||||||
@@ -42,7 +44,7 @@ from app.config import get_settings
|
|||||||
from app.learning.curator import LESSON_CURATOR, curate
|
from app.learning.curator import LESSON_CURATOR, curate
|
||||||
from app.learning.evidence import group_candidates, identifiers, read_candidates
|
from app.learning.evidence import group_candidates, identifiers, read_candidates
|
||||||
from app.learning.proof import compare, record, render
|
from app.learning.proof import compare, record, render
|
||||||
from app.learning.proposals import ISSUES, load
|
from app.learning.proposals import ISSUES, load, write
|
||||||
from app.learning.skill import (
|
from app.learning.skill import (
|
||||||
NotApproved,
|
NotApproved,
|
||||||
mark_reviewed,
|
mark_reviewed,
|
||||||
@@ -141,7 +143,7 @@ def show_status() -> int:
|
|||||||
"in the Skill"
|
"in the Skill"
|
||||||
if proposal.id in live
|
if proposal.id in live
|
||||||
else "retired"
|
else "retired"
|
||||||
if proposal.published
|
if proposal.retired
|
||||||
else "not in the Skill"
|
else "not in the Skill"
|
||||||
)
|
)
|
||||||
# One comparison suggests a direction; it does not prove a lesson.
|
# One comparison suggests a direction; it does not prove a lesson.
|
||||||
@@ -211,6 +213,10 @@ def retire_lesson(arguments: Sequence[str]) -> int:
|
|||||||
return 2
|
return 2
|
||||||
bundle = load_provider(get_settings().CLOUD_PROVIDER)
|
bundle = load_provider(get_settings().CLOUD_PROVIDER)
|
||||||
gone = retire(arguments[0], _skill_dir(bundle))
|
gone = retire(arguments[0], _skill_dir(bundle))
|
||||||
|
for proposal in load(ROOT / ISSUES):
|
||||||
|
if proposal.id == arguments[0] and not proposal.retired:
|
||||||
|
# Marked on its proposal, so the next publish does not bring it back.
|
||||||
|
write(replace(proposal, retired=datetime.now(UTC).date().isoformat()))
|
||||||
print(f"Retired {arguments[0]}." if gone else f"{arguments[0]} is not published.")
|
print(f"Retired {arguments[0]}." if gone else f"{arguments[0]} is not published.")
|
||||||
return 0 if gone else 1
|
return 0 if gone else 1
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ models:
|
|||||||
iac-author: gemini/gemini-3.1-pro-preview
|
iac-author: gemini/gemini-3.1-pro-preview
|
||||||
validator: gemini/gemini-3.1-pro-preview
|
validator: gemini/gemini-3.1-pro-preview
|
||||||
lesson-curator: gemini/gemini-3.1-pro-preview
|
lesson-curator: gemini/gemini-3.1-pro-preview
|
||||||
|
# The same reading the validator makes of a design's coverage, made earlier.
|
||||||
|
coverage-reviewer: gemini/gemini-3.1-pro-preview
|
||||||
# A lighter model for a role's first attempt, used when MODEL_TIERS is on. Only a
|
# A lighter model for a role's first attempt, used when MODEL_TIERS is on. Only a
|
||||||
# role whose work is checked by something else belongs here: the code is checked
|
# role whose work is checked by something else belongs here: the code is checked
|
||||||
# by terraform validate and by the validator. The validator is the check, and a
|
# by terraform validate and by the validator. The validator is the check, and a
|
||||||
@@ -36,6 +38,7 @@ models:
|
|||||||
iac-author: 300
|
iac-author: 300
|
||||||
validator: 300 # timed out five times at 180 s in a run of 2026-10-07
|
validator: 300 # timed out five times at 180 s in a run of 2026-10-07
|
||||||
packager: 300
|
packager: 300
|
||||||
|
coverage-reviewer: 300
|
||||||
|
|
||||||
# Skills each role may load. Role files stay provider-neutral; the bundle names Skills.
|
# Skills each role may load. Role files stay provider-neutral; the bundle names Skills.
|
||||||
role_skills:
|
role_skills:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Each reference below holds the lessons for one Deliverable. Read the one for the
|
|||||||
| Deliverable | Reference | Lessons |
|
| Deliverable | Reference | Lessons |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| deployment guidance | `references/deployment_guidance.md` | 1 |
|
| deployment guidance | `references/deployment_guidance.md` | 1 |
|
||||||
| target architecture | `references/target_architecture.md` | 4 |
|
| target architecture | `references/target_architecture.md` | 7 |
|
||||||
<!-- lessons:end -->
|
<!-- lessons:end -->
|
||||||
|
|
||||||
This Skill is written by the lessons loop (`app/learning/`), from proposals a person approved. Do not edit it by hand: change the proposal and publish again.
|
This Skill is written by the lessons loop (`app/learning/`), from proposals a person approved. Do not edit it by hand: change the proposal and publish again.
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ Rules learned from earlier work. Follow every one that applies.
|
|||||||
|
|
||||||
**Why.** Missing required arguments in nested blocks will cause Terraform validation to fail, preventing submission.
|
**Why.** Missing required arguments in nested blocks will cause Terraform validation to fail, preventing submission.
|
||||||
|
|
||||||
Published 2026-10-09, from lesson proposal 05.
|
Published 2026-10-10, from lesson proposal 05.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Rules learned from earlier work. Follow every one that applies.
|
|||||||
|
|
||||||
**Why.** If detailed constraints are missed, the validation phase will reject the design for incomplete coverage, forcing a revision.
|
**Why.** If detailed constraints are missed, the validation phase will reject the design for incomplete coverage, forcing a revision.
|
||||||
|
|
||||||
Published 2026-10-09, from lesson proposal 01.
|
Published 2026-10-10, from lesson proposal 01.
|
||||||
|
|
||||||
## L-02: Assign Checks to Every Element
|
## L-02: Assign Checks to Every Element
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ Published 2026-10-09, from lesson proposal 01.
|
|||||||
|
|
||||||
**Why.** The submission tool will reject the architecture if any Element lacks a Check, wasting an attempt.
|
**Why.** The submission tool will reject the architecture if any Element lacks a Check, wasting an attempt.
|
||||||
|
|
||||||
Published 2026-10-09, from lesson proposal 02.
|
Published 2026-10-10, from lesson proposal 02.
|
||||||
|
|
||||||
## L-03: Verify Resource Arguments for Checks
|
## L-03: Verify Resource Arguments for Checks
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ Published 2026-10-09, from lesson proposal 02.
|
|||||||
|
|
||||||
**Why.** If a Check specifies an argument that does not exist on the resource, it cannot be implemented, forcing an architectural revision.
|
**Why.** If a Check specifies an argument that does not exist on the resource, it cannot be implemented, forcing an architectural revision.
|
||||||
|
|
||||||
Published 2026-10-09, from lesson proposal 03.
|
Published 2026-10-10, from lesson proposal 03.
|
||||||
|
|
||||||
## L-06: Do Not Mark Requirements as Not Applicable
|
## L-06: Do Not Mark Requirements as Not Applicable
|
||||||
|
|
||||||
@@ -32,4 +32,28 @@ Published 2026-10-09, from lesson proposal 03.
|
|||||||
|
|
||||||
**Why.** The submission tool will reject the deliverable if a Requirement lacks a Check or is incorrectly marked as not applicable.
|
**Why.** The submission tool will reject the deliverable if a Requirement lacks a Check or is incorrectly marked as not applicable.
|
||||||
|
|
||||||
Published 2026-10-09, from lesson proposal 06.
|
Published 2026-10-10, from lesson proposal 06.
|
||||||
|
|
||||||
|
## L-07: Verify location constraints
|
||||||
|
|
||||||
|
**Rule.** When a requirement specifies where resources must be provisioned, such as a designated region, multi-zone placement, or a low-carbon location, create a Check for the `region` or `location` argument on every applicable Element.
|
||||||
|
|
||||||
|
**Why.** Validation frequently catches missing location constraints. Without this Check, resources may be provisioned in default regions, violating compliance or sustainability requirements.
|
||||||
|
|
||||||
|
Published 2026-10-10, from lesson proposal 07.
|
||||||
|
|
||||||
|
## L-08: Cloud SQL backup encryption
|
||||||
|
|
||||||
|
**Rule.** When writing a Check for CMEK encryption on a `google_sql_database_instance`, do not require an `encryption_key_name` argument for backup storage, as the instance-level `encryption_key_name` automatically encrypts backups as well.
|
||||||
|
|
||||||
|
**Why.** The database instance resource does not have a separate encryption key argument for backups. Asking for one causes validation to reject the Check as un-implementable.
|
||||||
|
|
||||||
|
Published 2026-10-10, from lesson proposal 08.
|
||||||
|
|
||||||
|
## L-09: Backend Service capabilities
|
||||||
|
|
||||||
|
**Rule.** When writing Checks for a `google_compute_backend_service`, do not verify IAM roles inside the backend service or require health checks when it is configured with a Serverless NEG.
|
||||||
|
|
||||||
|
**Why.** Roles are verified via IAM bindings outside the backend service, and Serverless NEGs do not support health checks. Invalid Checks cause the design to be rejected during validation.
|
||||||
|
|
||||||
|
Published 2026-10-10, from lesson proposal 09.
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ def test_every_engine_role_and_the_pillar_advisor_is_defined(bundle):
|
|||||||
|
|
||||||
expected = {"orchestrator", "reply-writer", PILLAR_ADVISOR}
|
expected = {"orchestrator", "reply-writer", PILLAR_ADVISOR}
|
||||||
expected |= {spec.specialist for spec in DEPENDENCY_GRAPH.values()}
|
expected |= {spec.specialist for spec in DEPENDENCY_GRAPH.values()}
|
||||||
# The lesson curator runs outside any Execution; the engine does not need it.
|
# The lesson curator runs outside any Execution, and the coverage reviewer only
|
||||||
assert set(roles) == expected | {"lesson-curator"}
|
# when the deployment switches its review on; the engine needs neither.
|
||||||
|
assert set(roles) == expected | {"lesson-curator", "coverage-reviewer"}
|
||||||
for role in roles.values():
|
for role in roles.values():
|
||||||
assert role.instructions.strip()
|
assert role.instructions.strip()
|
||||||
|
|
||||||
|
|||||||
150
tests/execution/test_design_review.py
Normal file
150
tests/execution/test_design_review.py
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
"""A model reviews a design's coverage before it is approved (iteration 6 step 13)."""
|
||||||
|
|
||||||
|
from langgraph.checkpoint.memory import InMemorySaver
|
||||||
|
|
||||||
|
from app.adk.fake_runtime import SAMPLE_DATA, Call, FakeAgentRuntime, sample_submission
|
||||||
|
from app.adk.roles import COVERAGE_REVIEWER, load_roles
|
||||||
|
from app.adk.runtime import NoDecider, RoleSpec
|
||||||
|
from app.agent import AGENTS_DIR, ExecutionEngine
|
||||||
|
from app.nodes.router import Router, Thresholds
|
||||||
|
from app.providers import load_provider
|
||||||
|
from app.recorder import InMemoryRecorder
|
||||||
|
from app.tools.design_review import DesignCoverageReview
|
||||||
|
from app.workflows.deliverables import DEPENDENCY_GRAPH, DeliverableKind
|
||||||
|
|
||||||
|
K = DeliverableKind
|
||||||
|
GRAPH = {"target-architecture.json": SAMPLE_DATA["target-architecture.json"]}
|
||||||
|
UPSTREAM = {
|
||||||
|
"requirements": {
|
||||||
|
"attachments": {"requirements.json": SAMPLE_DATA["requirements.json"]}
|
||||||
|
},
|
||||||
|
"design_recommendations": {
|
||||||
|
"attachments": {"recommendations.json": SAMPLE_DATA["recommendations.json"]}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
REVIEWER = RoleSpec(COVERAGE_REVIEWER, "Review.", budget=6)
|
||||||
|
GAP = {
|
||||||
|
"source": "NFR-1",
|
||||||
|
"applies_to": "E-1",
|
||||||
|
"statement": "min_instance_count is at least 2",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def reviewer(*gaps: dict, seen: dict | None = None) -> FakeAgentRuntime:
|
||||||
|
def turn(task):
|
||||||
|
if seen is not None:
|
||||||
|
seen.update(task.context)
|
||||||
|
return [Call("report_gaps", {"gaps": list(gaps)})]
|
||||||
|
|
||||||
|
return FakeAgentRuntime({COVERAGE_REVIEWER: [turn, turn]})
|
||||||
|
|
||||||
|
|
||||||
|
async def test_the_reviewer_is_given_the_constraints_and_the_design():
|
||||||
|
seen: dict = {}
|
||||||
|
review = DesignCoverageReview(reviewer(GAP, seen=seen), REVIEWER)
|
||||||
|
|
||||||
|
concerns = await review(K.TARGET_ARCHITECTURE, GRAPH, UPSTREAM, "exec-1")
|
||||||
|
|
||||||
|
assert concerns == (
|
||||||
|
"NFR-1: no Check verifies this on E-1: min_instance_count is at least 2",
|
||||||
|
)
|
||||||
|
# Non-functional requirements and recommendations; a functional requirement
|
||||||
|
# is reached through its components, not through a Check of its own.
|
||||||
|
assert [item["id"] for item in seen["constraints"]] == ["NFR-1", "DR-1"]
|
||||||
|
assert {e["id"] for e in seen["target_architecture"]["elements"]} >= {"E-1"}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_a_gap_about_something_that_does_not_exist_is_dropped():
|
||||||
|
invented = [
|
||||||
|
{**GAP, "source": "NFR-99"},
|
||||||
|
{**GAP, "applies_to": "E-99"},
|
||||||
|
{**GAP, "statement": " "},
|
||||||
|
"not a gap",
|
||||||
|
]
|
||||||
|
review = DesignCoverageReview(reviewer(*invented, GAP), REVIEWER)
|
||||||
|
|
||||||
|
concerns = await review(K.TARGET_ARCHITECTURE, GRAPH, UPSTREAM, "exec-1")
|
||||||
|
|
||||||
|
assert len(concerns) == 1 and concerns[0].startswith("NFR-1:")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_a_design_is_reviewed_once_in_an_execution():
|
||||||
|
runtime = reviewer(GAP)
|
||||||
|
review = DesignCoverageReview(runtime, REVIEWER)
|
||||||
|
|
||||||
|
first = await review(K.TARGET_ARCHITECTURE, GRAPH, UPSTREAM, "exec-1")
|
||||||
|
again = await review(K.TARGET_ARCHITECTURE, GRAPH, UPSTREAM, "exec-1")
|
||||||
|
other = await review(K.TARGET_ARCHITECTURE, GRAPH, UPSTREAM, "exec-2")
|
||||||
|
|
||||||
|
assert first and other and again == ()
|
||||||
|
assert len(runtime.runs) == 2
|
||||||
|
|
||||||
|
|
||||||
|
async def test_nothing_is_reviewed_but_a_readable_target_architecture():
|
||||||
|
runtime = reviewer(GAP)
|
||||||
|
review = DesignCoverageReview(runtime, REVIEWER)
|
||||||
|
|
||||||
|
assert await review(K.DEPLOYMENT_GUIDANCE, GRAPH, UPSTREAM, "a") == ()
|
||||||
|
assert await review(K.TARGET_ARCHITECTURE, {}, UPSTREAM, "b") == ()
|
||||||
|
assert await review(K.TARGET_ARCHITECTURE, GRAPH, None, "c") == ()
|
||||||
|
assert runtime.runs == []
|
||||||
|
|
||||||
|
|
||||||
|
async def test_a_complete_design_raises_nothing():
|
||||||
|
review = DesignCoverageReview(reviewer(), REVIEWER)
|
||||||
|
|
||||||
|
assert await review(K.TARGET_ARCHITECTURE, GRAPH, UPSTREAM, "exec-1") == ()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_the_gaps_go_back_to_the_target_architect_before_the_design_stands(
|
||||||
|
tmp_path,
|
||||||
|
):
|
||||||
|
roles = {
|
||||||
|
"orchestrator": RoleSpec("orchestrator", "Unused.", budget=40),
|
||||||
|
**{
|
||||||
|
spec.specialist: RoleSpec(spec.specialist, "Produce.", budget=15)
|
||||||
|
for spec in DEPENDENCY_GRAPH.values()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
architect = DEPENDENCY_GRAPH[K.TARGET_ARCHITECTURE].specialist
|
||||||
|
design = sample_submission(K.TARGET_ARCHITECTURE)
|
||||||
|
runtime = FakeAgentRuntime(
|
||||||
|
{
|
||||||
|
**{
|
||||||
|
spec.specialist: [[sample_submission(kind)]]
|
||||||
|
for kind, spec in DEPENDENCY_GRAPH.items()
|
||||||
|
},
|
||||||
|
# Submitted twice: once into the review, once after reading it.
|
||||||
|
architect: [[design, design]],
|
||||||
|
COVERAGE_REVIEWER: [[Call("report_gaps", {"gaps": [GAP]})]],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
engine = ExecutionEngine(
|
||||||
|
runtime=runtime,
|
||||||
|
roles=roles,
|
||||||
|
recorder=InMemoryRecorder(),
|
||||||
|
checkpointer=InMemorySaver(),
|
||||||
|
output_root=tmp_path,
|
||||||
|
orchestrator=Router(NoDecider(), None, Thresholds()),
|
||||||
|
submission_review=DesignCoverageReview(runtime, REVIEWER),
|
||||||
|
)
|
||||||
|
|
||||||
|
result = await engine.start("Ingest webhooks", pre_approved=True)
|
||||||
|
|
||||||
|
assert result.status == "completed"
|
||||||
|
run = next(run for run in runtime.runs if run.role == architect)
|
||||||
|
first, second = (reply for _, reply in run.results)
|
||||||
|
assert first.startswith("Not submitted. A review found: NFR-1: no Check verifies")
|
||||||
|
assert not second.startswith("Not submitted")
|
||||||
|
# No Revision was needed: the gap was dealt with before anything was approved.
|
||||||
|
assert not [d for d in result.state["decisions"] if "revise" in d["action"]]
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_reviewer_role_loads_with_the_bundles_model():
|
||||||
|
bundle = load_provider("gcp")
|
||||||
|
roles = load_roles(AGENTS_DIR, bundle)
|
||||||
|
|
||||||
|
role = roles[COVERAGE_REVIEWER]
|
||||||
|
assert role.model == bundle.models.for_role(COVERAGE_REVIEWER)
|
||||||
|
assert role.model == bundle.models.for_role("validator")
|
||||||
|
assert role.tools == () and role.model_timeout_seconds == 300
|
||||||
@@ -303,7 +303,9 @@ async def test_a_check_the_code_cannot_meet_goes_back_to_the_graph_unvalidated(
|
|||||||
"target_architecture",
|
"target_architecture",
|
||||||
(
|
(
|
||||||
"Check K-2 cannot be implemented as written (no such argument). "
|
"Check K-2 cannot be implemented as written (no such argument). "
|
||||||
"Rewrite it so it can be met, or remove it with a reason."
|
"Rewrite it so it can be met, or remove it with a reason. The same "
|
||||||
|
"fault may be in other Checks: read every Check against each reason "
|
||||||
|
"given here and correct every one it applies to."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ def test_the_settings_a_check_names_are_read_from_its_statement():
|
|||||||
"template.scaling.min_instance_count",
|
"template.scaling.min_instance_count",
|
||||||
)
|
)
|
||||||
assert named_settings("startup_cpu_boost is true") == ("startup_cpu_boost",)
|
assert named_settings("startup_cpu_boost is true") == ("startup_cpu_boost",)
|
||||||
|
# A value in backticks is not a setting.
|
||||||
|
assert named_settings("`enable_cdn` is `false`") == ("enable_cdn",)
|
||||||
|
assert named_settings("`deletion_protection` is `true`") == ("deletion_protection",)
|
||||||
# Values, roles and plain prose name no setting.
|
# Values, roles and plain prose name no setting.
|
||||||
assert named_settings("ingress is INGRESS_TRAFFIC_ALL") == ()
|
assert named_settings("ingress is INGRESS_TRAFFIC_ALL") == ()
|
||||||
assert named_settings("roles/run.invoker is granted to allUsers") == ()
|
assert named_settings("roles/run.invoker is granted to allUsers") == ()
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from app.adk.fake_runtime import Call, FakeAgentRuntime
|
from app.adk.fake_runtime import Call, FakeAgentRuntime, FakeDecider
|
||||||
from app.adk.roles import load_roles
|
from app.adk.roles import load_roles
|
||||||
from app.adk.runtime import RoleSpec
|
from app.adk.runtime import Answer, RoleSpec
|
||||||
from app.learning.curator import LESSON_CURATOR, curate
|
from app.learning.curator import LESSON_CURATOR, curate
|
||||||
from app.learning.evidence import group_candidates, identifiers, read_candidates
|
from app.learning.evidence import group_candidates, identifiers, read_candidates
|
||||||
from app.learning.proposals import (
|
from app.learning.proposals import (
|
||||||
@@ -563,3 +563,101 @@ def test_the_published_lessons_were_reviewed_against_todays_vendored_skills():
|
|||||||
|
|
||||||
assert upstream_reviewed(skill), "run: python -m eval.curate_lessons reviewed"
|
assert upstream_reviewed(skill), "run: python -m eval.curate_lessons reviewed"
|
||||||
assert upstream_changes(skill, upstream_versions(bundle)) == []
|
assert upstream_changes(skill, upstream_versions(bundle)) == []
|
||||||
|
|
||||||
|
|
||||||
|
# --- what recurs inside a kind of problem ------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def addition(statement: str) -> dict:
|
||||||
|
return {"type": "proposed_addition", "statement": statement, "serves": "NFR-1"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_same_setting_missed_in_several_executions_is_its_own_group():
|
||||||
|
records = [
|
||||||
|
record("run-1", addition("`deletion_protection` is true on the database")),
|
||||||
|
record("run-2", addition("deletion_protection is enabled"), addition("x y")),
|
||||||
|
record("run-3", addition("`min_tls_version` is TLS_1_2")),
|
||||||
|
]
|
||||||
|
|
||||||
|
groups = {group.subject: group for group in group_candidates(records)}
|
||||||
|
|
||||||
|
# Every proposed Check is one broad group; the setting missed twice is another.
|
||||||
|
assert len(groups[None].executions) == 3
|
||||||
|
narrow = groups["deletion_protection"]
|
||||||
|
assert len(narrow.executions) == 2 and narrow.kind == "proposed_addition"
|
||||||
|
assert narrow.description == (
|
||||||
|
"validation proposed a Check about `deletion_protection` that the design lacked"
|
||||||
|
)
|
||||||
|
assert narrow.key != groups[None].key
|
||||||
|
# Seen in one Execution only, a setting is not a pattern.
|
||||||
|
assert "min_tls_version" not in groups
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_resource_that_checks_keep_asking_too_much_of_is_its_own_group():
|
||||||
|
def cannot(why: str) -> dict:
|
||||||
|
return {
|
||||||
|
"type": "revision",
|
||||||
|
"deliverable": "target_architecture",
|
||||||
|
"reason": f"Check K-1 cannot be implemented as written ({why}).",
|
||||||
|
}
|
||||||
|
|
||||||
|
records = [
|
||||||
|
record("run-1", cannot("example_database has no backup key argument")),
|
||||||
|
record("run-2", cannot("example_database has no query access flag")),
|
||||||
|
]
|
||||||
|
|
||||||
|
subjects = {group.subject for group in group_candidates(records)}
|
||||||
|
|
||||||
|
assert subjects == {None, "example_database"}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_a_group_about_one_setting_reaches_the_curator_past_triage(tmp_path):
|
||||||
|
issues = tmp_path / "issues"
|
||||||
|
approve(proposal(issues), issues) # a general lesson already exists
|
||||||
|
records = [
|
||||||
|
record("run-1", addition("`deletion_protection` is true")),
|
||||||
|
record("run-2", addition("`deletion_protection` is true")),
|
||||||
|
]
|
||||||
|
groups = group_candidates(records)
|
||||||
|
# Triage says the general lesson covers everything it is asked about.
|
||||||
|
decider = FakeDecider(
|
||||||
|
{group.key: Answer("L-01", 0.95) for group in groups if group.subject is None}
|
||||||
|
)
|
||||||
|
seen: list[str] = []
|
||||||
|
|
||||||
|
def turn(task):
|
||||||
|
seen.extend(group["what_happened"] for group in task.context["groups"])
|
||||||
|
return [Call("finish")]
|
||||||
|
|
||||||
|
runtime = FakeAgentRuntime({LESSON_CURATOR: [turn]})
|
||||||
|
|
||||||
|
await curate(
|
||||||
|
runtime,
|
||||||
|
CURATOR,
|
||||||
|
groups,
|
||||||
|
executions=2,
|
||||||
|
folder=issues,
|
||||||
|
decider=decider,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert seen == [
|
||||||
|
"validation proposed a Check about `deletion_protection` that the design lacked"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_retired_lesson_is_not_published_again(tmp_path):
|
||||||
|
"""Retiring left the proposal approved, so the next publish put the lesson
|
||||||
|
back: L-04 returned to the Skill that way on 2026-10-10."""
|
||||||
|
from dataclasses import replace
|
||||||
|
|
||||||
|
skill = lessons_skill(tmp_path)
|
||||||
|
issues = tmp_path / "issues"
|
||||||
|
made = publish(approve(proposal(issues), issues), skill, today=DAY)
|
||||||
|
retire(made.id, skill)
|
||||||
|
retired = write(replace(parse(made.path), retired="2026-10-09"), issues)
|
||||||
|
|
||||||
|
assert parse(retired.path).retired == "2026-10-09"
|
||||||
|
assert not retired.approved
|
||||||
|
with pytest.raises(NotApproved, match="was retired on 2026-10-09"):
|
||||||
|
publish(retired, skill)
|
||||||
|
assert published(skill) == {}
|
||||||
|
|||||||
Reference in New Issue
Block a user