feat(adopt): let the owner answer the type question assess asks

assess sets confirmationRequired and asks "Confirm repository type" whenever
confidence is below high, but there was no way to answer it: --answers read only
name, title, owners and lifecycle, and build_plan took the type solely from the
classifier's guess. The confirmation boundary in runbook section 9 could not be
closed through the tool, and nothing in the resulting contract distinguished a
deliberate decision from an unreviewed low-confidence default.

- accept the type via --type or a repositoryType answer, validated against the
  known set rather than written through unchecked
- record classification, confidence and evidence in metadata.annotations, which
  the schema already allows as a free-form object
- omit any timestamp so re-planning stays deterministic and planHash stable

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Alexander Baranov
2026-08-24 18:33:42 +03:00
co-authored by Claude Opus 5
parent 90bf25c49d
commit 523ef61fe3
2 changed files with 31 additions and 4 deletions
+18 -3
View File
@@ -387,12 +387,26 @@ def build_plan(
confirmed_title: str | None = None,
confirmed_owners: list[str] | None = None,
confirmed_lifecycle: str = "active",
confirmed_type: str | None = None,
strategy: str = "overlay",
) -> dict[str, Any]:
if strategy != "overlay":
raise ValueError("Only the overlay strategy is implemented; normalize requires an explicit recipe run")
baseline = assessment["repository"]["baselineRevision"]
classification = assessment["classification"]
repository_type = confirmed_type or classification["proposedType"]
# assess asks the owner to confirm the type whenever confidence is below
# high, so record which of the two answers the contract is built on. Without
# this a low-confidence guess and a deliberate decision look identical later.
annotations: dict[str, str] = {
"stewardship.corsus.ru/classification": "confirmed" if confirmed_type else "inferred",
"stewardship.corsus.ru/classification-confidence": classification["confidence"],
}
if classification.get("evidence"):
annotations["stewardship.corsus.ru/classification-evidence"] = ", ".join(
classification["evidence"]
)
changes: list[dict[str, Any]] = []
forbidden: list[str] = []
@@ -421,7 +435,7 @@ def build_plan(
if not (root / "AGENTS.md").exists():
answers = BootstrapAnswers(
name=confirmed_name, title=confirmed_title or confirmed_name, owners=confirmed_owners or [],
repository_type=assessment["classification"]["proposedType"], lifecycle=confirmed_lifecycle,
repository_type=repository_type, lifecycle=confirmed_lifecycle,
)
changes.append({"action": "create", "path": "AGENTS.md", "ownership": "shared", "content": render_agents_md(answers)})
else:
@@ -464,15 +478,16 @@ def build_plan(
"name": confirmed_name,
"title": confirmed_title or confirmed_name,
"owners": confirmed_owners or [],
"annotations": annotations,
},
"spec": {
"summary": f"Adopted repository {confirmed_name}",
"repository": {
"type": assessment["classification"]["proposedType"],
"type": repository_type,
"lifecycle": confirmed_lifecycle,
},
"template": {
"id": "repository." + assessment["classification"]["proposedType"].split("-")[0],
"id": "repository." + repository_type.split("-")[0],
"version": "0.1.0",
"source": "repo:repository-stewardship",
"mode": "adopted-overlay",