feat: implement repoctl L1 core (models, schemas, validate, discover, context, init, adopt)

Adds the repository-stewardship Python package (src/stewardship) with:
- JSON Schemas (Draft 2020-12) for RepositoryContract, KnowledgeBase, CatalogIndex,
  ContextBundle, BootstrapPlan, AdoptionAssessment/Plan/Report, user config and the
  repoctl-result envelope.
- Safe YAML I/O, path confinement, deterministic clock and canonical-JSON hashing.
- validate: schema, ID uniqueness, path safety, KDB references, freshness, secret-shaped
  fields, shell-string detection, and Markdown frontmatter/fence/link checks.
- discover/CatalogIndex with deterministic sorting and duplicate-name detection.
- describe (contract-only) and context (intent-scoped ContextBundle with budgeted
  materialization and --strict truncation).
- init: plan-then-apply bootstrap with SHA-256 plan-hash approval, no fake domain
  artifacts, bundled Claude skills.
- adopt: assess/plan/apply/verify overlay workflow per docs/adoption-runbook.md,
  preserving legacy content roots and KDB, with baseline-hash re-check and rollback.
- argparse-based `repoctl` CLI with human/yaml/json output and spec exit codes.
- pytest suite (39 tests) covering positive/negative fixtures, discovery, context,
  bootstrap and adoption (including LXD- and Antivirus-shaped legacy layouts).

Managed with uv (.venv), ruff clean, mypy --strict clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Alexander Baranov
2026-08-24 14:57:34 +03:00
co-authored by Claude Sonnet 5
parent 9a39b8a941
commit 96d4d08230
75 changed files with 4259 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# example-project agent instructions
Read `ops/contract.yaml`, then use `repoctl context`.
+3
View File
@@ -0,0 +1,3 @@
# CLAUDE.md
@AGENTS.md
@@ -0,0 +1,3 @@
# ADR 0001
Placeholder decision record.
@@ -0,0 +1,3 @@
# Deliverable one
Placeholder deliverable content for a fixture repository.
+9
View File
@@ -0,0 +1,9 @@
apiVersion: stewardship.corsus.ru/v1alpha1
kind: KnowledgeBase
metadata:
name: example-project-kdb
spec:
repository: repo:example-project
defaultLanguage: en
topics: []
documents: []
@@ -0,0 +1,30 @@
apiVersion: stewardship.corsus.ru/v1alpha1
kind: RepositoryContract
metadata:
name: example-project
title: Example project
owners:
- example-team
spec:
summary: Example non-code project
repository:
type: project
lifecycle: active
agent:
primary: CLAUDE.md
portable: AGENTS.md
knowledge:
entrypoint: kdb/kdb.yaml
contentRoots:
- id: deliverables
role: deliverables
path: deliverables
kind: directory
authority: source
writePolicy: managed
- id: decisions
role: decisions
path: decisions
kind: directory
authority: source
writePolicy: managed