diff --git a/build.py b/build.py index ca16885..b785cc6 100644 --- a/build.py +++ b/build.py @@ -490,6 +490,39 @@ def build_release_templates(folder: Path, dry_run: bool = False) -> None: f"({len(manifest['components'])} components)") +# ── Repository inventory bundle ─────────────────────────────────────────────── + + +def build_repos(folder: Path, dry_run: bool = False) -> None: + """Publish ``folder/src/repos.json`` as ``/mcp/repos.json``. + + The repository inventory (name, type, version source, Drone shape) is a + single hand-authored JSON file, surfaced to agents through the + ``registry://repos`` resource and the ``list_repos`` tool. See standards + "15_repository_inventory". + + Args: + folder (Path): The hub folder owning ``src/repos.json``. + dry_run (bool): Print the plan without executing. + """ + name = folder.name + src = folder / "src" / "repos.json" + if not src.is_file(): + return + out = folder / "mcp" / "repos.json" + if dry_run: + print(f"[REP] {name} {src.relative_to(ROOT)} -> {out.relative_to(ROOT)}") + return + + data = json.loads(src.read_text(encoding="utf-8")) + out.parent.mkdir(parents=True, exist_ok=True) + out.write_text( + json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8" + ) + print(f"[REP] {name} repo inventory written to {out.relative_to(ROOT)} " + f"({len(data.get('repos', []))} repos)") + + # ── CLI ────────────────────────────────────────────────────────────────────── @@ -511,6 +544,7 @@ def main() -> None: build_templates(folder, dry_run=args.dry_run) build_drone_templates(folder, dry_run=args.dry_run) build_release_templates(folder, dry_run=args.dry_run) + build_repos(folder, dry_run=args.dry_run) build_html(folder, dry_run=args.dry_run) diff --git a/registry.py b/registry.py index 6d6dae9..788dd40 100644 --- a/registry.py +++ b/registry.py @@ -12,6 +12,7 @@ Resources: registry://components (the template component index) registry://drone (the CI template index) registry://release (the release template index) + registry://repos (the repository inventory) Tools: ping (from the base server) @@ -23,12 +24,15 @@ Tools: get_drone_template (kind -> exact .drone.yml template) list_release_templates (the changelog + version-file artefacts) get_release_template (kind -> exact release template file) + list_repos (the covered repositories: type, path, version source) Prompts: intake (the questions to gather before building) build (the two axes -> deterministic build prompt) start_app (combined entry: intake, then build) trial (self-contained trial build into a scratch dir) + compliance (remediate repos against the CI + versioning standard) + release (agent-assisted tagging after the release MR is merged) """ from __future__ import annotations @@ -94,6 +98,45 @@ def _build_text(app_name: str, resources: str, pipelines: str, auth: str) -> str ) +_COMPLIANCE_TEXT = ( + "# Compliance — align repositories with the CI + versioning standard\n\n" + "Read `docs://modules/drone_pipelines` and `docs://modules/versioning_and_changelog`,\n" + "then enumerate the working set with `registry://repos` (or `list_repos()`).\n\n" + "For each repository, bring it to the standard for its `type`:\n\n" + "- **package** — `version` in `pyproject.toml`; root `CHANGELOG.md`; Drone file\n" + " from `get_drone_template(\"drone-pypi\")` (`python-lib.yaml`, tag-triggered).\n" + "- **service / site** — root `VERSION`; root `CHANGELOG.md`; Drone file from\n" + " `get_drone_template(\"drone-service\")` (`service-docker.yaml`; tag-triggered\n" + " service variant, push-triggered site variant).\n\n" + "Steps:\n" + "1. Inspect each repo (`git -C tag`, version file, `CHANGELOG.md`,\n" + " `.drone.yml`) and list the gaps — never assume.\n" + "2. Add missing files from `get_release_template(\"changelog\"/\"version-file\")`.\n" + "3. Replace `.drone.yml` with the guarded template for the repo's type.\n" + "4. Align the version file with the intended tag.\n" + "5. Commit per repo (one focused commit); **do not push or tag** without the\n" + " user's explicit go-ahead.\n" +) + +_RELEASE_TEXT = ( + "# Release — tag the merged commit\n\n" + "The version bump and changelog promotion live **in the release merge\n" + "request**; the tag is created on the commit that results from merging it.\n" + "See `docs://modules/versioning_and_changelog`.\n\n" + "Do this only after the user confirms the MR is merged/squashed and tells you\n" + "to proceed — never tag before the merge.\n\n" + "1. Wait for that explicit go-ahead.\n" + "2. Find the commit that introduced the version bump `x.y.z`:\n" + " - package: `git log -S 'version = \"x.y.z\"' -n 1 --format='%H %s' -- pyproject.toml`\n" + " - service / site: `git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION`\n" + "3. Verify that commit's version file equals `x.y.z` (the Drone guard enforces\n" + " `tag == version`).\n" + "4. Tag **only** that commit, lightweight and bare: `git tag x.y.z `.\n" + "5. **Do not push.** Ask the user to run `git push origin x.y.z`, then Drone\n" + " builds the release.\n" +) + + class StandardsMCPServer(MCPServer): """MCP server for the `standards` bundle with discovery/scaffolding tools. @@ -146,6 +189,13 @@ class StandardsMCPServer(MCPServer): return {"error": "not_found", "path": str(path), "components": []} return json.loads(path.read_bytes()) + def _repos(self) -> dict[str, Any]: + """Load the repository inventory.""" + path = Path(self.mcp_root) / "repos.json" + if not path.exists(): + return {"error": "not_found", "path": str(path), "repos": []} + return json.loads(path.read_bytes()) + def _find_release_component(self, kind: str) -> dict[str, Any] | None: for entry in self._release().get("components", []): if entry.get("kind") == kind: @@ -258,9 +308,19 @@ class StandardsMCPServer(MCPServer): return self._drone() @self.app.resource("registry://release") - def release() -> dict[str, Any]: + def release_templates() -> dict[str, Any]: return self._release() + @self.app.resource("registry://repos") + def repos() -> dict[str, Any]: + """Return the repository inventory. + + Use this to enumerate the repositories covered by the CI and + versioning standards, each with its type, path, version source, and + Drone shape. Paths are relative to the aetos/ workspace root. + """ + return self._repos() + @self.app.resource("docs://spec") def spec() -> dict[str, Any]: """Return the pinned auth-server OpenAPI contract. @@ -452,6 +512,27 @@ class StandardsMCPServer(MCPServer): } return self._read_release_component(entry) + @self.app.tool() + def list_repos(type: str | None = None) -> list[dict[str, Any]]: + """List the repositories covered by the CI and versioning standards. + + Each entry has: ``name``, ``type`` ("package" | "service" | "site"), + ``path`` (relative to the aetos/ workspace root), ``version_source`` + ("pyproject.toml" | "VERSION"), ``drone`` (the template file), + ``trigger`` ("tag" | "push"), ``docs`` kinds, and ``mcp``. + + Args: + type (str | None): Optional filter, e.g. "package" or "site". + + Returns: + list[dict[str, Any]]: Matching repository entries. + """ + repos = self._repos().get("repos", []) + if type: + needle = type.strip().lower() + return [r for r in repos if str(r.get("type", "")).lower() == needle] + return repos + @self.app.prompt() def intake() -> str: """Return the questions to gather before building an app. @@ -544,3 +625,28 @@ class StandardsMCPServer(MCPServer): "back so the standard can be amended.\n\n" f"Delete `{target}` once you are satisfied.\n" ) + + @self.app.prompt() + def compliance() -> str: + """Return the procedure to align repositories with the standard. + + Use this to audit and remediate the repos listed in + `registry://repos` against the Drone and versioning standards. + + Returns: + str: The compliance/remediation prompt. + """ + return _COMPLIANCE_TEXT + + @self.app.prompt() + def release() -> str: + """Return the agent-assisted tagging procedure. + + Use after the user confirms the release MR is merged/squashed: find + the commit that bumped the version file, tag only that commit, and + ask the user to push the tag. + + Returns: + str: The release/tagging prompt. + """ + return _RELEASE_TEXT diff --git a/standards/lib/01_build_recipe/index.html b/standards/lib/01_build_recipe/index.html index e21a5f7..bb29d66 100644 --- a/standards/lib/01_build_recipe/index.html +++ b/standards/lib/01_build_recipe/index.html @@ -593,6 +593,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/02_layering_rules/index.html b/standards/lib/02_layering_rules/index.html index 61938ed..1df16f2 100644 --- a/standards/lib/02_layering_rules/index.html +++ b/standards/lib/02_layering_rules/index.html @@ -584,6 +584,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/03_composition_root/index.html b/standards/lib/03_composition_root/index.html index ebc159c..b25ce57 100644 --- a/standards/lib/03_composition_root/index.html +++ b/standards/lib/03_composition_root/index.html @@ -575,6 +575,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/04_spec_first_routing/index.html b/standards/lib/04_spec_first_routing/index.html index 6744c1d..00374ba 100644 --- a/standards/lib/04_spec_first_routing/index.html +++ b/standards/lib/04_spec_first_routing/index.html @@ -602,6 +602,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/05_crud_template/index.html b/standards/lib/05_crud_template/index.html index 213afef..8e87ef5 100644 --- a/standards/lib/05_crud_template/index.html +++ b/standards/lib/05_crud_template/index.html @@ -611,6 +611,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/06_pipeline_scaffold/index.html b/standards/lib/06_pipeline_scaffold/index.html index dcac487..db823a5 100644 --- a/standards/lib/06_pipeline_scaffold/index.html +++ b/standards/lib/06_pipeline_scaffold/index.html @@ -602,6 +602,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/07_worker_and_progress/index.html b/standards/lib/07_worker_and_progress/index.html index f0550e3..2951f61 100644 --- a/standards/lib/07_worker_and_progress/index.html +++ b/standards/lib/07_worker_and_progress/index.html @@ -575,6 +575,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/08_human_in_loop/index.html b/standards/lib/08_human_in_loop/index.html index e7e3a31..9257e1c 100644 --- a/standards/lib/08_human_in_loop/index.html +++ b/standards/lib/08_human_in_loop/index.html @@ -584,6 +584,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/09_infra_adaptors/index.html b/standards/lib/09_infra_adaptors/index.html index 9c40318..4c49900 100644 --- a/standards/lib/09_infra_adaptors/index.html +++ b/standards/lib/09_infra_adaptors/index.html @@ -602,6 +602,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/10_drone_pipelines/index.html b/standards/lib/10_drone_pipelines/index.html index 3abe994..20e7b42 100644 --- a/standards/lib/10_drone_pipelines/index.html +++ b/standards/lib/10_drone_pipelines/index.html @@ -575,6 +575,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/11_versioning_and_changelog/index.html b/standards/lib/11_versioning_and_changelog/index.html index 1d8ee1b..8d0ab8b 100644 --- a/standards/lib/11_versioning_and_changelog/index.html +++ b/standards/lib/11_versioning_and_changelog/index.html @@ -14,7 +14,7 @@ - + @@ -556,6 +556,30 @@ +
  • + +
  • + + + Tagging strategy (MR-based) + + + + +
  • @@ -599,6 +623,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • @@ -725,6 +771,30 @@ +
  • + +
  • + + + Tagging strategy (MR-based) + + + + +
  • @@ -809,8 +879,9 @@ and tag contract is exactly what those two CI shapes consume.

  • Tag = version. The git tag is bare SemVer (0.0.6), no v prefix, and it MUST match the version file byte-for-byte. The Drone guard fails the build otherwise — this is what stops a tag from silently publishing nothing.
  • -
  • A release is a tag. Bump the version file, promote the changelog, commit, - tag, push. Everything else is automated by Drone.
  • +
  • A release is a tag, created after the change is merged. The version bump + and the changelog promotion travel inside the merge request (MR); the tag is + added on the merged commit and pushed. See Tagging strategy.
  • Never reuse a tag. If a release is wrong, cut a new patch version.
  • Pre-1.0 (0.y.z)

    @@ -867,17 +938,50 @@ one open [Unreleased] section with the change categories that apply version heading and clear it.
    +

    Tagging strategy (MR-based)

    +

    The release version is known while the change is still a merge request, so the +bump travels with the change and only the tag is added afterwards:

    +
      +
    1. In the MR — set the intended release version: version in + pyproject.toml (or the VERSION file) to x.y.z, and promote the + changelog (below). Changelog entries and link references name the + version/tag, never a commit id.
    2. +
    3. Merge or squash the MR into main.
    4. +
    5. Create the tag x.y.z on the resulting commit (the merge/squash commit).
    6. +
    7. Push the tag (git push origin x.y.z) — Drone builds the release.
    8. +
    +

    Because the version bump is inside the tagged commit, the guard's +tag == version check can only fail if the wrong commit was tagged.

    +

    Agent-assisted tagging

    +

    The agent neither authors nor merges the MR, and never tags before the merge. +After the user confirms the MR is merged/squashed and says to proceed:

    +
      +
    1. Wait for that explicit go-ahead.
    2. +
    3. Find the commit that introduced the version bump:
    4. +
    5. packages: + git log -S 'version = "x.y.z"' -n 1 --format='%H %s' -- pyproject.toml
    6. +
    7. services: + git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION
    8. +
    9. Confirm that commit's version file equals x.y.z, then tag only that + commit, lightweight and bare: git tag x.y.z <sha>.
    10. +
    11. Do not push. Ask the user to push the tag: git push origin x.y.z.
    12. +
    +

    Release checklist

      -
    1. Confirm the quality gate is green on main.
    2. -
    3. Move every [Unreleased] entry under the new version heading with today's - date (## [x.y.z] - YYYY-MM-DD); restore an empty [Unreleased] on top.
    4. -
    5. Add the two compare-link references at the bottom of the changelog.
    6. -
    7. Set the version file: pyproject.toml (version = "x.y.z") or VERSION.
    8. -
    9. Commit: chore(release): x.y.z.
    10. -
    11. Tag: git tag x.y.z and push the tag (git push origin x.y.z).
    12. -
    13. Watch Drone: Type A publishes the wheel/sdist, Type B builds and deploys the - image. Both first assert tag == version.
    14. +
    15. Confirm the quality gate is green and main is up to date.
    16. +
    17. In the MR: move every [Unreleased] entry under the new version heading with + the target date (## [x.y.z] - YYYY-MM-DD); restore an empty [Unreleased] + on top.
    18. +
    19. In the MR: add the two compare-link references at the bottom of the + changelog, naming the version/tag (never a commit id).
    20. +
    21. In the MR: set the version file — pyproject.toml (version = "x.y.z") or + VERSION — to the intended release version.
    22. +
    23. Merge or squash the MR into main.
    24. +
    25. Create the tag on the resulting commit: lightweight git tag x.y.z.
    26. +
    27. Push the tag (git push origin x.y.z). Watch Drone: Type A publishes the + wheel/sdist, Type B builds and deploys the image; both first assert + tag == version.
    28. Do not reuse the tag if the run fails — fix and cut x.y.(z+1).

    @@ -891,7 +995,7 @@ Drone guard turns that silent no-op into a hard failure.


    diff --git a/standards/lib/12_genericity_matrix/index.html b/standards/lib/12_genericity_matrix/index.html index 4a9d13e..7d907bc 100644 --- a/standards/lib/12_genericity_matrix/index.html +++ b/standards/lib/12_genericity_matrix/index.html @@ -11,7 +11,7 @@ - + @@ -486,6 +486,28 @@ + + +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + diff --git a/standards/lib/13_library_registry/index.html b/standards/lib/13_library_registry/index.html index c8f7367..5594011 100644 --- a/standards/lib/13_library_registry/index.html +++ b/standards/lib/13_library_registry/index.html @@ -486,6 +486,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/14_auth_integration/index.html b/standards/lib/14_auth_integration/index.html index a83051a..ab38830 100644 --- a/standards/lib/14_auth_integration/index.html +++ b/standards/lib/14_auth_integration/index.html @@ -488,6 +488,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/15_repository_inventory/index.html b/standards/lib/15_repository_inventory/index.html new file mode 100644 index 0000000..92b8ef7 --- /dev/null +++ b/standards/lib/15_repository_inventory/index.html @@ -0,0 +1,983 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Repository Inventory - Aetos Standards — Reference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + +
    + + +
    + +
    + + + + + + +
    +
    + + + +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + +

    Repository Inventory

    +

    Summary

    +

    The canonical list of Aetos repositories covered by the CI and versioning +standards, with the artifact each one produces, its version source, and its +Drone shape. Every entry maps to the contract in +11 – Versioning & Changelog and the two CI +files in 10 – Drone Pipelines.

    +

    The same data is published machine-readably as the registry://repos MCP +resource (and the list_repos tool), sourced from standards/src/repos.json. +Paths are relative to the aetos/ workspace root.

    +
    +

    Packages (Type A)

    +

    A wheel + sdist published to the private index. Version source is +pyproject.toml; Drone file is python-lib.yaml (tag-triggered).

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    RepoPathDocsMCP server
    dagpipedagpipelib, wikidagpipe:8006
    doc-forgedoc-forgelib, wikidocforge:8001
    hexahexalib, wikihexa:8008
    mail-intakemail-intakelib, wikimail_intake:8002
    mongo-opsmongo-opslib, wikimongo_ops:8007
    omnireadomnireadlib, wikiomniread:8003
    openapi-firstopenapi-firstlib, wikiopenapi_first:8004
    py-jwtpy-jwtlib, wikijwtlib:8005
    +
    +

    Services & sites (Type B)

    +

    A container image pushed to the registry and run on the Docker host. Version +source is the VERSION file; Drone file is service-docker.yaml.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    RepoTypePathTriggerDocs
    auth-serverserviceauth-servertagapi, lib, wiki
    docssitedocspush—
    mcpsitemcppush—
    +

    The service variant is tag-triggered and enforces tag == VERSION. The +site variant is push-triggered, ships :latest, and has no tag guard.

    +
    +

    Required files per repo

    + + + + + + + + + + + + + + + + + + + + + + + +
    TypeVersion sourceChangelogDrone
    packagepyproject.tomlCHANGELOG.mdpython-lib.yaml
    service / siteVERSIONCHANGELOG.mdservice-docker.yaml
    +

    Every covered repository must be able to satisfy tag == version: +the version file (never a commit id) is bumped in the release MR, the MR is +merged, and the tag is created on the merged commit.

    +
    +

    Reading this at runtime

    +
      +
    • Resource: registry://repos
    • +
    • Tool: list_repos()
    • +
    • Humans: this page (mirror of standards/src/repos.json).
    • +
    +
    + + + + + + + + + + + + + + + +
    +
    + + + + + +
    + + + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + \ No newline at end of file diff --git a/standards/lib/404.html b/standards/lib/404.html index 68017d5..14027c2 100644 --- a/standards/lib/404.html +++ b/standards/lib/404.html @@ -479,6 +479,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • diff --git a/standards/lib/index.html b/standards/lib/index.html index 45e82b3..9a2ff77 100644 --- a/standards/lib/index.html +++ b/standards/lib/index.html @@ -496,6 +496,28 @@ +
  • + + + + + + Repository Inventory + + + + + +
  • + + + + + + + + +
  • @@ -608,6 +630,8 @@ patterns, and the internal library catalog that agents consult while coding.

  • Drone Pipelines — the two CI shapes: a PyPI package or a Docker deployment.
  • Versioning & Changelog — SemVer, the tag↔version contract, and the release changelog.
  • +
  • Repository Inventory — every covered repo, its type, version source, and + Drone shape.
  • Genericity Matrix — what is library-backed, template-provided, or authored.
  • Auth Integration — consuming the shared auth-server service (spec-driven, no auth code).
  • diff --git a/standards/lib/search/search_index.json b/standards/lib/search/search_index.json index 211240b..8dc3146 100644 --- a/standards/lib/search/search_index.json +++ b/standards/lib/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Standards Reference","text":"

    The reference half of the Standards description: the enforceable rules, patterns, and the internal library catalog that agents consult while coding.

    • Build Recipe \u2014 the ordered, agentic checklist for a new app.
    • Layering Rules \u2014 the strict request \u2192 domain \u2192 repository layering and the rules that enforce it.
    • Composition Root \u2014 a single composition point wiring the whole app.
    • Spec-First Routing \u2014 the OpenAPI contract as the routing source of truth.
    • CRUD Template \u2014 the standardized generic resource endpoint scaffold.
    • Pipeline Scaffold \u2014 the deterministic pipeline skeleton for multi-stage jobs.
    • Worker & Progress \u2014 queued work, progress reporting, and visibility.
    • Human-in-the-Loop \u2014 guardrails and approvals inside automations.
    • Infra Adapters \u2014 how infrastructure connects without leaking into domain.
    • Drone Pipelines \u2014 the two CI shapes: a PyPI package or a Docker deployment.
    • Versioning & Changelog \u2014 SemVer, the tag\u2194version contract, and the release changelog.
    • Genericity Matrix \u2014 what is library-backed, template-provided, or authored.
    • Auth Integration \u2014 consuming the shared auth-server service (spec-driven, no auth code).
    • Library Registry \u2014 the catalog of internal libraries behind all of it.

    Read the Wiki for the philosophy and rationale; these pages are the reference that mirrors the standards MCP bundle.

    "},{"location":"01_build_recipe/","title":"Build Recipe","text":""},{"location":"01_build_recipe/#summary","title":"Summary","text":"

    The ordered, deterministic checklist for generating a new application of the standard shape. Every step is fixed; only the resource model (step 2), the codegen pass (step 3), and the pipeline family (step 8) need app-specific work.

    This page is served by the standards MCP as docs://modules/build_recipe. The start_app prompt on that server collects the two axes and hands off here; pull exact files with get_app_component.

    "},{"location":"01_build_recipe/#bootstrap","title":"\ud83d\ude80 Bootstrap","text":"

    From the standards docs checkout:

    cp -r <docs>/standards/src/templates/app apps/<your-app>\ncd apps/<your-app>\n

    Install the internal libraries \u2014 editable local checkouts (preferred in development) or the private index (CI / fresh machines). Credentials are environment-only; never commit them.

    # local checkouts\npip install -e ../aetos/openapi-first -e ../aetos/mongo-ops -e ../aetos/hexa \\\n            -e ../aetos/dagpipe -e ../aetos/doc-forge\n# private index\npip install --extra-index-url \\\n  \"https://$PIP_REGISTRY_USERNAME:$PIP_REGISTRY_PASSWORD@pip.aetoskia.com/simple\" .\n
    "},{"location":"01_build_recipe/#agent-prompt-copyable","title":"\ud83d\udccb Agent prompt (copyable)","text":"
    # Build a new application from the Aetos Standards blueprint\n\nYou are coding a complete new backend application conforming to the Aetos\nstandard app blueprint. Execute every step in order. Only steps 2\u20134 use the\napp-specific details provided by the user; everything else is deterministic.\n\n## Before writing any code\n\nConnect to the `standards` MCP server and read:\n- `docs://nav` (the module list)\n- `docs://modules/genericity_matrix` (Tier A library / Tier B template / Tier C authored)\n- `docs://modules/layering_rules` (the dependency rules)\n\nThen:\n- call `find_library` with `db`, `di`, `routing`, `ingestion`, `pipeline`, `docs`\n  and note the Tier A libraries that already exist \u2014 never reimplement one;\n- call `list_app_components()` and pull each file you need with\n  `get_app_component(kind, resource=..., family=...)` instead of writing it from\n  scratch.\n\n## Steps\n\n1. **Scaffold** \u2014 copy `standards/src/templates/app/` into `apps/<your-app>/`\n   (or pull the same tree via `get_app_template`). Keep the tree: `domain/`,\n   `infra/`, `interfaces/`, `pipelines/`, `tests/`, `scripts/`, plus\n   `pyproject.toml`, `openapi.yaml`, `config.py`, `init.py`, `main.py`,\n   `worker.py`, `Dockerfile`, `docker-compose.yaml`, `.env.example`.\n\n2. **Author the spec (app-specific)** \u2014 write `openapi.yaml`: resources,\n   schemas, `operationId`s, security, and extension metadata. This is the\n   contract and drives all routing. Every operation MUST have an `operationId`.\n\n3. **Generate the scaffold (codegen)** \u2014 from the spec, generate the wire\n   models and the exact handler signatures:\n   ```bash\n   openapi-first models openapi.yaml -o _gen/models.py\n   openapi-first routes openapi.yaml -o _gen/routes \\\n     --use-models --models-module _gen.models --inject-request --package --template-style\n   ```\n   `_gen/models.py` is the **wire contract** (Pydantic, one class per\n   `components.schemas` entry). `_gen/routes/<resource>/routes.py` lists every\n   `operationId` with its exact parameter signature. `--template-style` makes\n   those stubs `async def` with a `body` parameter, matching the handlers you\n   keep in `interfaces/` (without it they are sync `def` stubs taking\n   `payload`; both bind the same way). Treat `_gen/` as generated\n   (never hand-edit it) \u2014 the canonical handlers live in `interfaces/`.\n\n4. **Write each CRUD slice (app-specific)** \u2014 per resource create the four-file\n   slice: `models.py` (domain model, **no `id`**), `ports/db.py`\n   (`class XDocument(BaseDocument, X)` \u2014 id comes from `BaseDocument`),\n   `ports/service.py`, and optional `converters.py`. Follow the CRUD template.\n\n5. **Wire the composition root** \u2014 in `init.py`, build leaf repositories, then\n   dependent repositories, then services; add infra adapters (db, cache, stores,\n   progress bus, fetchers). Expose `get_svc` overloads.\n\n6. **Add routes** \u2014 create `interfaces/<resource>/routes.py` thin handlers whose\n   names match the `operationId`s (use the signatures from step 3 as your\n   checklist) and re-export them in `interfaces/openapi.py`. Add the cache\n   decorator to read endpoints.\n\n7. **Bootstrap app and worker** \u2014 confirm `main.py` runs the OpenAPI-first app\n   with its lifespan. If the app has long-running jobs, adapt `worker.py` to poll\n   the job collection, run the pipeline, and publish progress.\n\n8. **Add pipeline families (only if data-driven)** \u2014 copy `pipelines/example/`\n   to `pipelines/<family>/` with `abc.py`, `impl.py`, `pipeline.yaml`,\n   `resources/`, and reuse `pipelines/shared/` (loader + registry). Register the\n   root. Add fixtures and a parity test.\n\n9. **Add infrastructure only where needed** \u2014 Tier A capability: use the\n   library. Tier B capability: copy the template. Never hand-write a Tier A\n   library.\n\n10. **Tests** \u2014 integration tests with fakes at the HTTP edge; unit tests for\n    domain and pipeline logic; a config-consistency test for rule-driven\n    pipelines. Include `tests/integration/test_openapi_app_builds.py` (imports\n    the app, asserts `import main` binds every operation).\n\n11. **Scripts and seeds** \u2014 operator scripts under `scripts/` using\n    `init()` / `get_svc()` / `shutdown()`; run as `python -m scripts.<name>`.\n\n12. **Docs** \u2014 author GSDFC docstrings, generate `.pyi` stubs, mark the package\n    `py.typed`, and build the docs.\n\n**Definition of done:**\n- `python -c \"import main\"` succeeds.\n- `pytest` passes.\n- The app serves every operation in the spec; the worker drains its queue.\n- No domain module imports a web framework.\n- No Tier A library was reimplemented.\n
    "},{"location":"01_build_recipe/#where-the-steps-land","title":"\ud83e\udded Where the steps land","text":"

    The steps map onto the layers as follows:

    Step Package / file Depends on 1 \u00b7 Scaffold whole templates/app/ \u2014 2 \u00b7 Spec openapi.yaml \u2014 3 \u00b7 Codegen _gen/ (generated) spec, openapi-first 4 \u00b7 CRUD slices domain/<resource>/ spec, CRUD template 5 \u00b7 Wiring init.py every slice 6 \u00b7 Routes interfaces/<resource>/ services, openapi route registry 7 \u00b7 Bootstrap main.py, worker.py composition root 8 \u00b7 Pipelines pipelines/<family>/, shared/ library pipeline engine 9 \u00b7 Infra infra/ domain ports 10 \u00b7 Tests tests/ app + fixtures 11 \u00b7 Scripts scripts/ composition root 12 \u00b7 Docs docstrings + docs build code, Doc Forge"},{"location":"01_build_recipe/#the-codegen-fast-path-in-detail","title":"\ud83d\udd27 The codegen fast path, in detail","text":"

    openapi-first is spec \u2192 code only (it never generates a spec). Use it to erase the two mechanical parts of the build:

    Generated artifact Replaces Notes _gen/models.py hand-writing Pydantic wire models one class per components.schemas entry _gen/routes/<resource>/routes.py hand-typing handler signatures names == operationIds; request: Request injected

    Rules of the road:

    • Wire models are not domain models. _gen/models.py is the HTTP contract; domain/<resource>/models.py is your business shape. If the spec's schema has a required id: str, keep it off the domain model and let the document get its id from BaseDocument.
    • Use --template-style. Stubs are then async def ...(request, body: ...) matching interfaces/; without it they are sync def ...(payload: ...). Either binds (the router introspects the signature), but --template-style keeps the scaffold consistent with the code you keep.
    • Resource names are sanitized. /fetch-requests \u2192 fetch_requests.py.
    • Multipart bodies expand to UploadFile = File(...) / Form(...) params.
    • _gen/ is disposable. Regenerate on every spec change; git diff shows exactly what moved.
    "},{"location":"01_build_recipe/#definition-of-done","title":"\u26a0\ufe0f Definition of done","text":"
    • python -c \"import main\" succeeds.
    • pytest passes.
    • The app serves the spec's operations; the worker drains its queue.
    • No domain module imports a web framework.
    • No Tier A library was reimplemented.
    "},{"location":"01_build_recipe/#related","title":"Related","text":"
    • 02 \u2013 Layering Rules \u00b7 05 \u2013 CRUD Template \u00b7 06 \u2013 Pipeline Scaffold \u00b7 12 \u2013 Genericity Matrix
    "},{"location":"02_layering_rules/","title":"Layering Rules","text":""},{"location":"02_layering_rules/#summary","title":"Summary","text":"

    The dependency direction is fixed. Violating it is a design defect.

    "},{"location":"02_layering_rules/#allowed-imports","title":"Allowed imports","text":"
    interfaces/*      ->  domain/*            (services, ports, models)\ninterfaces/*      ->  infra/adapters/*    (only read-only value objects)\ndomain/*          ->  domain/*            (same layer)\ndomain/*          ->  pipelines/*         (call a pipeline via a port)\ndomain/*/ports/*  ->  infra/*             (bind adapters + libraries at the seam)\ninfra/adapters/*  ->  domain/ports/*      (implement the interface)\nmain.py/init.py   ->  everything          (composition root only)\n
    "},{"location":"02_layering_rules/#forbidden-imports","title":"Forbidden imports","text":"
    domain/*          ->  interfaces/*        (never)\ndomain/*          ->  fastapi/starlette   (never)\ninfra/adapters/*  ->  interfaces/*        (never)\ninterfaces/*      ->  infra/db/*          (state lives in resources, not imports)\n
    "},{"location":"02_layering_rules/#why","title":"Why","text":"
    • The business logic is testable without a server or an event loop.
    • Adapters can be swapped (in-memory fake, real database) without touching business logic.
    • The HTTP edge stays thin and replaceable.
    "},{"location":"02_layering_rules/#the-portadapter-contract","title":"The port/adapter contract","text":"

    The ports/ package is the seam where the domain meets infrastructure. Each domain/<resource>/ports/ module declares the resource's models/document shape and exposes factory functions that bind a concrete adapter \u2014 so a port module is allowed to import from infra/ and from the persistence libraries. Everything outside ports/ in domain/ stays framework- and driver-free.

    domain/<resource>/ports/db.py       -> document model + create_<resource>_repo()\ndomain/<resource>/ports/service.py  -> service + get_<resource>_service()\ninfra/db/repos/<vendor>.py          -> repository adapter factory\ninfra/adapters/service.py           -> generic CRUD service base\n

    The composition root calls the port factories; nothing else constructs an adapter.

    "},{"location":"02_layering_rules/#enforcement","title":"Enforcement","text":"
    • domain/ must never import the web framework (fastapi / starlette) or interfaces/. Only the ports/ seam, infra/, and the composition root touch drivers.
    • Reviewers (and CI) reject import fastapi inside domain/ or infra/.
    "},{"location":"03_composition_root/","title":"Composition Root","text":""},{"location":"03_composition_root/#summary","title":"Summary","text":"

    All wiring happens in exactly one module. It builds a flat resource registry and exposes it to the HTTP layer and to scripts.

    "},{"location":"03_composition_root/#the-resource-registry","title":"The resource registry","text":"

    init.py returns a plain dict[str, Any]. Keys follow two conventions:

    • <resource>_repo \u2014 a repository adapter for a resource.
    • <resource>_svc \u2014 a service for a resource.

    Plus named infrastructure adaptors:

    • http_cache_store \u2014 response cache backend.
    • progress_bus \u2014 progress/event bus.
    • <vendor>_<kind> \u2014 fetchers, clients, stores.

    The API stores the dict on app.state.db_resources during lifespan startup. Handlers read from it; nothing imports concrete adapters.

    "},{"location":"03_composition_root/#shape","title":"Shape","text":"
    _resources: dict = {}\n_initialized = False\n\nasync def init(settings=None) -> dict:\n    global _initialized\n    if _initialized:\n        return _resources\n\n    await setup_database(uri=settings.mongo_uri, db_name=settings.mongo_db)\n\n    # 1. leaf repositories\n    user_repo = create_user_repo()\n\n    # 2. dependent repositories (dependencies passed by keyword)\n    wallet_repo = create_wallet_repo(user_repo=user_repo)\n\n    # 3. services (build via the DI library, injecting the repo)\n    _resources[\"user_repo\"]   = user_repo\n    _resources[\"wallet_repo\"] = wallet_repo\n    _resources[\"user_svc\"]    = get_user_service(user_repo)\n    _resources[\"wallet_svc\"]  = get_wallet_service(wallet_repo)\n\n    # 4. infrastructure adaptors (optional)\n    _resources[\"http_cache_store\"] = HttpCacheStore(...)\n    _resources[\"progress_bus\"]     = ProgressEventBus()\n\n    _initialized = True\n    return _resources\n\nasync def shutdown() -> None:\n    global _initialized\n    await close_stores(_resources)\n    await shutdown_database()\n    _resources.clear()\n    _initialized = False\n
    "},{"location":"03_composition_root/#typed-accessors","title":"Typed accessors","text":"

    Expose a get_svc(name) helper with one @overload per key so scripts get typing without importing concrete classes:

    @overload\ndef get_svc(name: Literal[\"user_svc\"]) -> UserService: ...\n@overload\ndef get_svc(name: Literal[\"wallet_svc\"]) -> WalletService: ...\n\ndef get_svc(name: str):\n    return _resources[name]\n

    Also expose get_db() (raw database handle) and pure helpers such as compute_fingerprint(payload) (canonical hash used for deduplication).

    "},{"location":"03_composition_root/#rules","title":"Rules","text":"
    • init() is idempotent.
    • The composition root is the only place that imports concrete adapters.
    • Handlers never call init(); they read request.app.state.db_resources.
    • Scripts call init() / shutdown() around their work.
    "},{"location":"04_spec_first_routing/","title":"Spec-First Routing","text":""},{"location":"04_spec_first_routing/#summary","title":"Summary","text":"

    The OpenAPI document is the single source of truth for the HTTP contract. Handlers are bound to it by name; there is no decorator router.

    "},{"location":"04_spec_first_routing/#the-contract","title":"The contract","text":"
    • openapi.yaml (or .json) declares paths, schemas, parameters, responses, and security.
    • A custom operationId names the handler function.
    • The framework (openapi_first) validates requests/responses against the spec and dispatches to the handler whose name equals operationId.
    "},{"location":"04_spec_first_routing/#app-bootstrap","title":"App bootstrap","text":"
    # main.py\nfrom openapi_first.app import OpenAPIFirstApp\n\napp = OpenAPIFirstApp(\n    openapi_path=\"openapi.yaml\",\n    routes_module=interfaces.openapi,   # module whose namespace holds handlers\n    title=\"<App> API\",\n    version=\"0.1.0\",\n    lifespan=lifespan,\n)\n

    lifespan calls the composition root:

    @asynccontextmanager\nasync def lifespan(app):\n    app.state.db_resources = await init()\n    yield\n    await shutdown()\n
    "},{"location":"04_spec_first_routing/#handler-registry","title":"Handler registry","text":"

    interfaces/openapi.py is a flat re-export of every handler, so the framework can resolve operationId across the whole app:

    from interfaces.item.routes import *\nfrom interfaces.wallet.routes import *\nfrom interfaces.progress.sse import *\n
    "},{"location":"04_spec_first_routing/#handler-shape","title":"Handler shape","text":"

    Handlers are thin and synchronous with respect to business logic:

    async def create_item(request: Request, body: dict):\n    svc = request.app.state.db_resources[\"item_svc\"]\n    return await svc.create(Item.model_validate(body))\n

    Generated stubs. openapi-first routes emits this exact shape (async def handlers taking body) when given --template-style; without that flag the stub is def create_item(payload: ItemInput) \u2014 sync, with a payload parameter. Both shapes bind identically: the router resolves handlers by operationId and introspects the FastAPI signature, and it never inspects the request body. Pass --template-style so the generated signatures match the handlers you keep in interfaces/.

    "},{"location":"04_spec_first_routing/#conventions","title":"Conventions","text":"
    • operationId naming: list_<resource>, create_<resource>, get_<resource>, update_<resource>, delete_<resource>.
    • Read-only endpoints may use a cache decorator keyed on path + query + user.
    • Validation errors -> 400; not found -> 404; delete -> 204.
    • Security is declared once in the spec and enforced by the framework; handlers contain no auth code.
    "},{"location":"04_spec_first_routing/#authless-apps","title":"Authless apps","text":"

    Auth is deferred in the standard: the same spec-first app runs with or without it, because security lives entirely in the spec, never in handlers. For an app that needs no auth yet, do not invent per-handler auth checks \u2014 just omit the security keys:

    • Remove the top-level security: block.
    • Remove components.securitySchemes.
    • Do not add security: [] to operations. An explicit empty array is a per-operation override that means \"public\", and it only matters when a global security block exists. Leaving every operation without a security key is the cleanest authless spec.

    Profile endpoints (/users/me) and profile headers (x-profile) still exist in an authless app. Define a stand-in identity in the composition root \u2014 for example get_current_user returns or lazily creates a fixed \"Demo User\" \u2014 so handlers stay auth-agnostic and only the wiring changes when real auth arrives.

    The handlers, services, and composition root are unchanged. When auth is needed later, add the global security block and an introspecting dependency; only handlers that must opt out get security: [].

    "},{"location":"04_spec_first_routing/#codegen","title":"Codegen","text":"

    openapi_first scaffolds models and route stubs from the spec (see the Build Recipe, step 3):

    openapi-first models openapi.yaml -o _gen/models.py\nopenapi-first routes openapi.yaml -o _gen/routes \\\n  --use-models --models-module _gen.models --inject-request --package --template-style\n

    Prefer codegen over hand-writing boilerplate. The result is the wire contract and a set of operationId-named signatures \u2014 not the canonical handlers.

    "},{"location":"05_crud_template/","title":"CRUD Template","text":""},{"location":"05_crud_template/#summary","title":"Summary","text":"

    Every resource follows the same four-file slice. Repetition is intentional: it makes the codebase predictable and generatable.

    "},{"location":"05_crud_template/#the-slice","title":"The slice","text":"
    domain/<resource>/\n    models.py               # pure Pydantic model (no DB fields)\n    ports/\n        db.py               # document model + repository factory\n        service.py          # service class + factory\n        converters.py       # (optional) transforms\n
    "},{"location":"05_crud_template/#the-id-rule-model-vs-document","title":"The id rule (model vs. document)","text":"

    Two different objects, two different jobs:

    Object Lives in Has id? Purpose Domain model domain/<resource>/models.py No business shape, framework-free Document domain/<resource>/ports/db.py Yes (from BaseDocument) Mongo persistence shape

    BaseDocument (mongo-ops) supplies id: Optional[PyObjectId] (aliased to _id) plus created_at / updated_at. The domain model must not declare id; Mongo owns it.

    Trap \u2014 generated wire models. openapi-first models produces the HTTP contract (see the Build Recipe, step 3). Response schemas frequently declare a required id: str, so a generated class is not a domain model. If you write class ItemDocument(Item, BaseDocument) and Item re-exports a required id: str, that field shadows BaseDocument.id and no Mongo _id can ever be set. Fix it one of three ways:

    1. Preferred: keep the domain model id-free (hand-author it from the CRUD template), and keep the required id only on the wire model.
    2. Order the bases so the document wins: class ItemDocument(BaseDocument, Item).
    3. Keep a separate document type and translate with ports/converters.py.
    "},{"location":"05_crud_template/#modelspy","title":"models.py","text":"

    A framework-free Pydantic model describing the business shape (no id).

    class Item(BaseModel):\n    name: str\n    quantity: int = 0\n
    "},{"location":"05_crud_template/#portsdbpy","title":"ports/db.py","text":"

    The persistence model extends the business model and adds database concerns. The repository factory selects the right repository flavour.

    # Item is id-free; BaseDocument adds id/created_at/updated_at.\nclass ItemDocument(Item, BaseDocument):\n    pass\n\ndef create_item_repo(*, owner_repo=None) -> ItemRepository:\n    return repo_factory(\n        collection=\"items\",\n        document=ItemDocument,\n        populate_rules=[PopulateRule(field_name=\"owner\", collection_name=\"users\")],\n        cache=None,               # or a CachedBaseRepository config\n    )\n
    "},{"location":"05_crud_template/#nested-references","title":"Nested references","text":"

    The wire contract often declares a reference as an expanded object (expense.entity: Entity), while the domain model stays id-free. Pick one convention and apply it consistently:

    • Embed (default for small, stable refs) \u2014 store the object as a dict / list[dict] on the document; the API returns it verbatim. No populate wiring.
    • Populate \u2014 store an id and declare a PopulateRule; mongo-ops expands it on read. The referenced repo must be registered with the PopulationEngine.
    • Id only \u2014 store the id and let the client resolve it.

    For populate-backed repositories change a reference with update, not patch: patch rejects changes to populated FK fields by design.

    "},{"location":"05_crud_template/#portsservicepy","title":"ports/service.py","text":"

    The service is built through the DI library, injecting the repository. The generic CRUD base provides create/read/update/patch/delete/search/....

    class ItemService(CrudsServiceAdaptor[Item, ItemDocument]):\n    model = Item\n    schema = ItemDocument\n\ndef get_item_service(repo) -> ItemService:\n    return build(ItemService, instances={\"repo\": repo})\n
    "},{"location":"05_crud_template/#naming-conventions","title":"Naming conventions","text":"Concept Convention collection plural snake case (items) document <Resource>Document repository factory create_<resource>_repo service <Resource>Service service factory get_<resource>_service resource key <resource>_svc operationId list_items, create_item, ..."},{"location":"05_crud_template/#optional-files","title":"Optional files","text":"
    • converters.py \u2014 pure functions mapping between domain types.
    • ports/enrichment.py \u2014 adapts a pipeline into an async callable the service can invoke (used when a resource is populated by a pipeline).
    "},{"location":"06_pipeline_scaffold/","title":"Pipeline Scaffold","text":""},{"location":"06_pipeline_scaffold/#summary","title":"Summary","text":"

    Data-driven processing is expressed as a composition graph. The graph is built by a DI library; execution is driven by a DAG engine. Stages are pure and individually testable.

    "},{"location":"06_pipeline_scaffold/#when-to-use-a-pipeline","title":"When to use a pipeline","text":"

    Use a pipeline when a resource is produced by a multi-step transformation of an input (a document, a file, a message) rather than by a simple CRUD write.

    "},{"location":"06_pipeline_scaffold/#structure-of-a-family","title":"Structure of a family","text":"

    A family is one input shape (e.g. a file format or a message kind). Each family has the same skeleton:

    pipelines/<family>/\n    abc.py            # port contracts (stage interfaces + root interface)\n    impl.py           # concrete stages + root implementation\n    pipeline.yaml     # graph spec: nodes, edges, roots, schema\n    resources/\n        pipeline.yaml # runtime spec consumed by the loader\n        patterns/*.yaml  # rule fragments (pattern registry)\n    banks/<variant>.py   # optional variants that re-pin a few slots\n
    "},{"location":"06_pipeline_scaffold/#shared-scaffolding","title":"Shared scaffolding","text":"
    pipelines/shared/\n    ports.py     # RegistryPort, FinalizePort, etc.\n    loader.py    # build(root_cls) -> wires the graph + engine\n    registry.py  # resolve_root(...) -> root class for a (kind, variant)\n
    "},{"location":"06_pipeline_scaffold/#the-loader","title":"The loader","text":"
    def build(root_cls, *, instances=None, config=None):\n    # merge resources/patterns/*.yaml into a pattern registry\n    # bind registry/config into each graph node by id\n    # build the schema (state) class and the engine\n    root = root_cls()\n    root._engine = Engine(graph, state_cls, payload_cls)\n    return root\n
    "},{"location":"06_pipeline_scaffold/#the-registry","title":"The registry","text":"

    A single lookup replaces hand-rolled if/else selection:

    _FAMILIES = {\n    \"csv\":  {\"acme\": {\"heuristic\": AcmeCsvPipeline}},\n    \"json\": {\"globex\": {\"heuristic\": GlobexJsonPipeline}},\n}\n\ndef resolve_root(kind, variant, mode=\"heuristic\"):\n    return _FAMILIES[kind][variant][mode]\n

    Adding a new variant means adding one class and one registry entry.

    "},{"location":"06_pipeline_scaffold/#driving-a-pipeline","title":"Driving a pipeline","text":"

    Stages are driven explicitly so intermediate state can be persisted:

    pipeline = build(resolve_root(kind, variant))\ncontent = pipeline.ingest.materialize(raw_bytes)\nrecords = pipeline.reader.read(content)\nitems   = pipeline.normalize.build(records)\n
    "},{"location":"06_pipeline_scaffold/#testing","title":"Testing","text":"

    Because stages are pure, test each stage in isolation and test the assembled root against fixture inputs whose expected outputs are stored as golden files. A parity test replays fixtures headlessly.

    "},{"location":"07_worker_and_progress/","title":"Worker & Progress","text":""},{"location":"07_worker_and_progress/#summary","title":"Summary","text":"

    Long-running work runs in a background worker. Jobs are durable documents that move through an explicit status machine. Progress is streamed to clients.

    "},{"location":"07_worker_and_progress/#the-status-machine","title":"The status machine","text":"
    pending -> processing -> completed\n                     \\-> failed    (retried up to N times)\n                     \\-> paused    (waiting for human input)\n
    • pending \u2014 queued, eligible for pickup.
    • processing \u2014 claimed by a worker.
    • paused \u2014 blocked on a human-in-the-loop question.
    • failed \u2014 error; retry_count increments until a max, then skipped.
    • completed \u2014 terminal success.
    "},{"location":"07_worker_and_progress/#the-poll-loop","title":"The poll loop","text":"
    async def poll(resources):\n    backoff = MIN_POLL\n    while True:\n        jobs = await job_svc.search(filter={\"status\": \"pending\"}, limit=100)\n        backoff = MIN_POLL if jobs else min(backoff * 2, MAX_POLL)\n        for job in jobs:\n            if (job.retry_count or 0) >= MAX_RETRIES:\n                continue\n            await job_svc.update_status(job.id, \"processing\")\n            try:\n                await process(job, resources)\n            except PauseForResolution:\n                await job_svc.update_status(job.id, \"paused\")\n            except Exception as e:\n                await job_svc.update_status(\n                    job.id, \"failed\", error=str(e),\n                    retry_count=(job.retry_count or 0) + 1,\n                )\n        await asyncio.sleep(backoff)\n

    Tunables live in environment variables: WORKER_POLL_MIN, WORKER_POLL_MAX, WORKER_MAX_RETRIES.

    "},{"location":"07_worker_and_progress/#progress-events","title":"Progress events","text":"

    A worker publishes structured progress events to a bus (a port). The HTTP edge exposes a streaming endpoint that replays events for a given job id.

    class ProgressEvent(BaseModel):\n    job_id: str\n    step: str\n    status: str            # started | progress | completed | skipped | paused\n    message: dict | None = None\n

    The bus is an in-memory adapter by default; because it is a port, it can be swapped for a durable broker. Emit from the orchestrator at each stage:

    await self.bus.publish(ProgressEvent(job_id=jid, step=\"normalize\",\n                                     status=\"completed\", message={\"count\": n}))\n
    "},{"location":"07_worker_and_progress/#streaming-endpoint","title":"Streaming endpoint","text":"
    async def stream_job_events(request, id):\n    bus = request.app.state.db_resources.get(\"progress_bus\")\n    if bus is None:\n        return {\"events\": []}\n\n    async def gen():\n        sent = 0\n        while True:\n            events = bus.get_events(id)\n            for e in events[sent:]:\n                yield f\"data: {e.model_dump_json(exclude_none=True)}\\n\\n\"\n                sent += 1\n            await asyncio.sleep(0.5)\n\n    return StreamingResponse(gen(), media_type=\"text/event-stream\")\n

    Known limitation. The default in-memory bus is per-process. If the worker and the API run as separate processes, events published by the worker are not visible to the API. For production, back the bus with a shared broker. The port boundary makes this a one-adapter change.

    "},{"location":"08_human_in_loop/","title":"Human-in-the-Loop","text":""},{"location":"08_human_in_loop/#summary","title":"Summary","text":"

    Some inputs are ambiguous and must be resolved by a human before processing can continue. The blueprint models this as a durable pause: an exception is raised, a question is recorded, the job pauses, and later resumes.

    "},{"location":"08_human_in_loop/#the-mechanism","title":"The mechanism","text":"
    1. During processing, a stage raises a domain exception carrying the context needed to ask the question:
    raise PauseForResolution(\n    job_id=jid,\n    reference=\"<stable key for this decision>\",\n    options=[...],\n    context={...},\n)\n
    1. The orchestrator catches it, records a question document, and re-raises so the worker marks the job paused.
    2. A client lists pending questions and answers one:
    GET  /jobs/{id}/questions            -> list pending questions\nPOST /questions/{qid}/resolve  {choice}  -> record the choice\n
    1. When the last pending question is resolved, the resolve endpoint flips the parent job back to pending.
    2. The worker picks it up again, rebuilds a resolution map from previously answered questions, and seeds it into the pipeline so the same decision is not asked twice.
    "},{"location":"08_human_in_loop/#the-question-document","title":"The question document","text":"
    class Question(BaseDocument):\n    job_id: str\n    reference: str            # stable key: stage|field|value\n    status: str               # pending | resolved\n    options: list[dict]\n    context: dict\n    chosen: dict | None = None\n    resolved_at: str | None = None\n
    "},{"location":"08_human_in_loop/#resume-map","title":"Resume map","text":"

    The worker turns answered questions into a lookup keyed by reference, then injects it into the pipeline so that stage can skip re-raising:

    resolved = {q.reference: q.chosen for q in await svc.search(\n    filter={\"job_id\": jid, \"status\": \"resolved\"})}\n\npipeline = build(root, instances={\"pause\": handler}, config={\"resolved\": resolved})\n
    "},{"location":"08_human_in_loop/#resolve-endpoint","title":"Resolve endpoint","text":"
    async def resolve_question(request, id, body):\n    svc = request.app.state.db_resources[\"question_svc\"]\n    q = await svc.read(id)\n    await svc.update(id, {\"chosen\": body[\"chosen\"], \"status\": \"resolved\",\n                          \"resolved_at\": now()})\n\n    pending = await svc.search(filter={\"job_id\": q.job_id, \"status\": \"pending\"},\n                               limit=1)\n    if not pending:\n        jobs = request.app.state.db_resources[\"job_svc\"]\n        job = await jobs.read(q.job_id)\n        if job and job.status == \"paused\":\n            await jobs.update_status(q.job_id, \"pending\")\n    return q\n
    "},{"location":"08_human_in_loop/#cli-parity","title":"CLI parity","text":"

    The same flow is available through scripts/CLI: list, get, create, questions, resolve, retry.

    "},{"location":"09_infra_adaptors/","title":"Infra Adapters","text":""},{"location":"09_infra_adaptors/#summary","title":"Summary","text":"

    All external systems are reached through adapters in infra/. Prefer an existing internal library over writing a new adapter; where no library exists, copy the Tier B scaffold from templates/app. See the Genericity Matrix for the Tier A / B / C split.

    "},{"location":"09_infra_adaptors/#database-mongodb","title":"Database (MongoDB)","text":"
    • A single connection manager owns the client lifecycle. setup_database(uri, db_name) / shutdown_database().
    • A repository factory selects the repository flavour:
    repo_factory(collection, document, engine=None,\n             populate_rules=None, cache=None)\n
    • base repository \u2014 plain CRUD;
    • populating repository \u2014 resolves referenced documents (foreign keys);
    • cached repository \u2014 an LRU/TTL cache in front of reads.

    • Referenced documents are described declaratively:

    PopulateRule(field_name=\"owner\", collection_name=\"users\",\n             nested_rules=[], max_depth=2, projection=None)\n
    • Transactions use a session context manager provided by the library.

    Tier A \u2014 Library (Mongo Ops). Do not write raw Motor calls in the domain; consult the registry and the library's MCP before touching the driver.

    "},{"location":"09_infra_adaptors/#http-response-cache","title":"HTTP response cache","text":"

    Tier B \u2014 template. Copy from templates/app; not a standalone library.

    A generic GET cache sits behind a decorator.

    @cache_response(ttl=60)\nasync def list_items(request): ...\n
    • Keyed on path + query + user.
    • No-op when no store is wired.
    • invalidate(*resources) bumps a generation counter for write-triggered invalidation.
    "},{"location":"09_infra_adaptors/#event-progress-bus","title":"Event / progress bus","text":"

    Tier B \u2014 template. Copy from templates/app.

    A port with an in-memory default adapter (publish, get_events). Swap for a durable broker in production (see Worker & Progress).

    "},{"location":"09_infra_adaptors/#external-clients-ingestion","title":"External clients (ingestion)","text":"

    External fetchers (files, mail, HTTP) are adapters that wrap ingestion libraries. Construct them in the composition root and inject into orchestrators.

    Tier A \u2014 Libraries: Omniread (formats) and Mail Intake (email).

    "},{"location":"09_infra_adaptors/#llm-clients","title":"LLM clients","text":"

    Tier B \u2014 template. Copy the pool scaffold from templates/app.

    When a pipeline calls a model provider, route through a pool adaptor that handles provider selection, retries, and client lifecycle:

    pool = setup_async_pool(provider=settings.llm_provider)\nresult = await pool.complete(model=\"...\", messages=[...])\n

    Providers are selected by LLM_PROVIDER and configured by environment.

    "},{"location":"09_infra_adaptors/#key-value-store","title":"Key-value store","text":"

    Tier B \u2014 template. Copy from templates/app.

    For report/snapshot storage, provide a pluggable store port with a Redis adapter and an in-memory fallback.

    "},{"location":"09_infra_adaptors/#rule","title":"Rule","text":"
    • Tier A (libraries: DB, DI, ingestion, mail, auth, docs, pipelines) \u2014 use the library; writing a private copy is a defect. Query find_library first.
    • Tier B (cache, progress bus, LLM pool, KV store, composition shape, worker, tests) \u2014 these are template code, not libraries: copy them from templates/app rather than searching the registry.
    • Tier C (models, business logic, pipeline families, rules) \u2014 author them yourself.
    "},{"location":"10_drone_pipelines/","title":"Drone Pipelines","text":""},{"location":"10_drone_pipelines/#summary","title":"Summary","text":"

    Every Aetos repository ships a Drone CI definition at .drone.yml. There is exactly one standard per repository, and there are two types of file, chosen by what the repository produces:

    Type File Produces Repos A \u2014 PyPI package templates/drone/python-lib.yaml A wheel + sdist on the private index dagpipe, doc-forge, hexa, mail-intake, mongo-ops, omniread, openapi-first, py-jwt B \u2014 Docker deployment templates/drone/service-docker.yaml An image pushed to the registry and run as a container auth-server, docs, mcp

    Both templates run on platform: linux / arm64 with the workspace at /drone/src. Copy the matching template to <repo>/.drone.yml; the Type A file needs no edits, the Type B file needs its placeholders filled in (below).

    Conventions: .drone.yml (not .yaml), one file per repo, secrets injected with from_secret \u2014 never commit credentials.

    "},{"location":"10_drone_pipelines/#type-a-pypi-package-python-libyaml","title":"Type A \u2014 PyPI package (python-lib.yaml)","text":"

    For internal libraries. The file contains two pipelines:

    1. build-and-publish-pypi \u2014 triggered on tag:
    2. check-version \u2014 guard: fail unless $DRONE_TAG equals the version in pyproject.toml; then read name / version and query $PIP_REPO_URL/simple/<package>/; if that version already exists, exit 78 and skip the whole build (see 11 \u2013 Versioning & Changelog).
    3. quality-gate \u2014 install the package with its [dev] extras from the private index, then black --check, ruff check, mypy, pydoclint, pytest.
    4. build-package \u2014 python -m build into dist/.
    5. upload-to-private-pypi \u2014 twine upload to $PIP_REPO_URL.
    6. backfill-pypi-from-tags \u2014 triggered on custom:
    7. fetch-tags \u2014 git fetch --tags --force.
    8. build-and-upload-missing \u2014 walk every tag in version order, skip the ones already on the index, git checkout the rest, verify tag == pyproject version at that commit, build, and upload. This is the disaster-recovery / replay path.

    Secrets: PIP_REPO_URL, PIP_USERNAME, PIP_PASSWORD.

    • Ship as-is. Package name and version come from pyproject.toml, so the same file is reused verbatim across every library.
    "},{"location":"10_drone_pipelines/#type-b-docker-deployment-service-dockeryaml","title":"Type B \u2014 Docker deployment (service-docker.yaml)","text":"

    For services and sites that ship a container image. The file contains two pipelines, each mirroring a repo family:

    1. build-and-deploy-service \u2014 triggered on tag (a long-running API/worker service, e.g. auth-server):
    2. fetch-tags \u2014 resolve the latest tag into LATEST_TAG.txt; fail if there are no tags.
    3. check-version \u2014 guard: fail unless $DRONE_TAG equals the repo-root VERSION file (see 11 \u2013 Versioning & Changelog).
    4. check-remote-image \u2014 if aetos/<app>:<tag> already exists locally, exit 78 and skip the build.
    5. quality-gate \u2014 install from requirements.txt and run black / ruff / mypy / pytest.
    6. build-image \u2014 docker build with the private-index build args, tagged aetos/<app>:<tag> and :latest.
    7. push-image \u2014 login, re-tag with $REGISTRY_HOST, push both tags.
    8. stop-old \u2014 docker rm -f <app>.
    9. run-container \u2014 docker run -d --name <app> -p <host>:<container> --restart always with the service's -e environment.
    10. build-and-deploy-site \u2014 triggered on push (a static/HTTP site, e.g. docs, mcp): build-image \u2192 push-image \u2192 stop-old \u2192 run-container, with no tag resolution, no quality gate, and no version guard (it ships :latest only).

    Secrets: PIP_REPO_URL, PIP_USERNAME, PIP_PASSWORD (service build args), REGISTRY_HOST, REGISTRY_USER, REGISTRY_PASS, plus the service runtime env (for example MONGO_*, JWT_SECRET).

    Placeholders to fill in per repo:

    Placeholder Meaning Example <app> service image / container name auth-server aetos/<app> image repository on the registry aetos/auth-server <host-port> / <container-port> published : in-image port 9003:8000 <site> site image / container name docs <ENV_VAR> runtime environment variable MONGO_HOST"},{"location":"10_drone_pipelines/#what-not-to-do","title":"What not to do","text":"
    • Do not hand-roll a third shape. A repo is either Type A or Type B, never both.
    • Do not inline secrets; always use from_secret.
    • Do not drop the check-version / check-remote-image skip \u2014 it guards the index and the running container against duplicate publishes.
    • Do not drop the tag\u2194version guard. A package needs its pyproject.toml version to equal the tag; a service needs a root VERSION file that equals the tag. See 11 \u2013 Versioning & Changelog.
    • Do not rename the pipelines; tooling and runbooks key off build-and-publish-pypi, build-and-deploy-service, and build-and-deploy-site.
    "},{"location":"10_drone_pipelines/#related","title":"Related","text":"
    • 01 \u2013 Build Recipe \u00b7 09 \u2013 Infra Adapters \u00b7 11 \u2013 Versioning & Changelog \u00b7 13 \u2013 Library Registry
    "},{"location":"11_versioning_and_changelog/","title":"Versioning & Changelog","text":""},{"location":"11_versioning_and_changelog/#summary","title":"Summary","text":"

    Every Aetos artifact \u2014 library, service, or site \u2014 is versioned with Semantic Versioning and documents its releases in a Keep a Changelog file. The version file is the source of truth, the git tag must equal it, and a Drone guard enforces that equality before anything is published. Releases are cut manually; a tag is what triggers the pipeline.

    This page pairs with 10 \u2013 Drone Pipelines: the version and tag contract is exactly what those two CI shapes consume.

    "},{"location":"11_versioning_and_changelog/#the-version-contract","title":"The version contract","text":"Artifact Source of truth Notes Library (PyPI package) version in pyproject.toml check-version also reads it to skip duplicates Service / site (Docker) VERSION file at the repo root one line, x.y.z

    Rules:

    1. One version per repository. No per-module versions.
    2. Tag = version. The git tag is bare SemVer (0.0.6), no v prefix, and it MUST match the version file byte-for-byte. The Drone guard fails the build otherwise \u2014 this is what stops a tag from silently publishing nothing.
    3. A release is a tag. Bump the version file, promote the changelog, commit, tag, push. Everything else is automated by Drone.
    4. Never reuse a tag. If a release is wrong, cut a new patch version.
    "},{"location":"11_versioning_and_changelog/#pre-10-0yz","title":"Pre-1.0 (0.y.z)","text":"

    While a package is 0.y.z, 0.y is treated as the major line:

    • breaking change \u2192 0.(y+1).0
    • new feature \u2192 0.y.(z+1)
    • bug fix \u2192 0.y.(z+1)

    Once a package reaches 1.0.0, normal SemVer applies. Do not ship 1.0.0 until the public API is considered stable.

    "},{"location":"11_versioning_and_changelog/#the-changelog","title":"The changelog","text":"

    CHANGELOG.md at the repo root, in Keep a Changelog form. It always has exactly one open [Unreleased] section with the change categories that apply:

    ## [Unreleased]\n\n### Added\n### Changed\n### Deprecated\n### Removed\n### Fixed\n### Security\n

    On release you promote it \u2014 never delete history:

    ## [0.0.6] - 2026-03-07\n\n### Added\n- ...\n

    and add a link reference at the bottom:

    [Unreleased]: https://git.aetoskia.com/aetos/<repo>/compare/0.0.6...HEAD\n[0.0.6]: https://git.aetoskia.com/aetos/<repo>/compare/0.0.5...0.0.6\n

    Conventions:

    • Write entries for humans: one line each, imperative, referencing the user impact, not the commit hash.
    • Categories: Added, Changed, Deprecated, Removed, Fixed, Security. Omit empty categories.
    • Security fixes get their own entry even if the change is otherwise a bug fix.
    • The [Unreleased] heading is never renamed; copy its content into the new version heading and clear it.
    "},{"location":"11_versioning_and_changelog/#release-checklist","title":"Release checklist","text":"
    1. Confirm the quality gate is green on main.
    2. Move every [Unreleased] entry under the new version heading with today's date (## [x.y.z] - YYYY-MM-DD); restore an empty [Unreleased] on top.
    3. Add the two compare-link references at the bottom of the changelog.
    4. Set the version file: pyproject.toml (version = \"x.y.z\") or VERSION.
    5. Commit: chore(release): x.y.z.
    6. Tag: git tag x.y.z and push the tag (git push origin x.y.z).
    7. Watch Drone: Type A publishes the wheel/sdist, Type B builds and deploys the image. Both first assert tag == version.
    8. Do not reuse the tag if the run fails \u2014 fix and cut x.y.(z+1).
    "},{"location":"11_versioning_and_changelog/#why-the-guard-matters","title":"Why the guard matters","text":"

    The version file and the tag are two facts that must agree; nothing in git enforces that by itself. A mismatch is not a theoretical risk \u2014 a package can be tagged 0.0.2 while its pyproject.toml still says 0.0.1, and the publish step (which compares the file against the index) then skips the build entirely, so 0.0.2 never reaches the index while looking like a release. The Drone guard turns that silent no-op into a hard failure.

    "},{"location":"11_versioning_and_changelog/#related","title":"Related","text":"
    • 10 \u2013 Drone Pipelines \u00b7 01 \u2013 Build Recipe \u00b7 13 \u2013 Library Registry
    "},{"location":"12_genericity_matrix/","title":"Genericity Matrix","text":""},{"location":"12_genericity_matrix/#summary","title":"Summary","text":"

    This page states precisely what is library-backed, what is template-provided, and what is app-specific and must be authored. Use it to scope a new build and to know, for any given capability, whether to call a library, copy template code, or write it yourself.

    "},{"location":"12_genericity_matrix/#tier-a-library-backed-use-never-reimplement","title":"Tier A \u2014 Library-backed (use; never reimplement)","text":"

    These capabilities already exist as internal libraries. Reach them through the library registry MCP (find_library(capability)) and read the library's own MCP for its API. Writing a private copy of any of these is a defect.

    Capability Library MCP Persistence: repositories, cache, populate, transactions Mongo Ops (mongo_ops) :8007 Dependency injection / composition Hexa (hexa) :8008 Deterministic multi-step transformation engine DAG Pipe (dagpipe) :8006 Spec-first HTTP edge, client, codegen OpenAPI First (openapi_first) :8004 Format-agnostic fetch + parse (HTML, PDF, CSV, XLSX) Omniread (omniread) :8003 Read-only email ingestion Mail Intake (mail_intake) :8002 JWT auth primitives (register, login, introspect) Py JWT (jwtlib) :8005 Documentation build (MkDocs + MCP) Doc Forge (docforge) :8001"},{"location":"12_genericity_matrix/#tier-b-template-provided-copy-from-templatesapp-then-adapt","title":"Tier B \u2014 Template-provided (copy from templates/app, then adapt)","text":"

    These are reusable internal components shipped inside the template \u2014 they are not independent libraries. Copy them as-is, then rename/populate only what is app-specific. They give every app the same wiring shape as the reference app. Fetch them by kind with get_app_component, or the whole tree with get_app_template.

    Component Template location Action Shipped Layering & dependency rule the package layout + import rules keep \u2705 Composition root shape init.py (get_svc/get_db, idempotency) keep \u2705 Spec-first web edge interfaces/openapi.py, thin handlers bound to operationId keep \u2705 CRUD slice pattern domain/<resource>/{models.py, ports/db.py, ports/service.py, converters.py} rename + fill \u2705 Generic CRUD service infra/adapters/service.py (CrudsServiceAdaptor) keep \u2705 Repository factory infra/db/repos/mongo.py (_repo_factory) keep \u2705 Worker poll + status loop worker.py keep \u2705 Progress bus infra/adapters/sse.py (keyed in-memory bus) + an app SSE endpoint keep \u2705 HTTP response cache infra/http_cache.py (cache_response + generation invalidation) keep \u2705 Key-value store infra/adapters/kv.py (port + in-memory + Redis adaptor) keep \u2705 Pipeline scaffold pipelines/shared/{ports,loader,registry}.py + pipelines/<family>/ rename + fill \u2705 Operator scripts scripts/ (init() / get_svc() / shutdown()) rename \u2705 Testing harness integration fakes + fixture-parity pattern keep \u2705 Project scaffolding pyproject.toml, Dockerfile, docker-compose.yaml, .env.example, openapi.yaml rename + fill \u2705"},{"location":"12_genericity_matrix/#tier-b-patterns-port-from-the-reference-app","title":"Tier B (patterns) \u2014 port from the reference app","text":"

    A few Tier B capabilities are real and reusable, but are shaped by the app or the provider, so the template does not ship them verbatim \u2014 copying them blindly would carry app-specific names. Treat them as patterns: lift the shape from the reference app and rename per app.

    Component Reference location Action Shipped Human-in-the-loop durable pause + question document + resolve endpoint + resume map port + reshape \u2717 LLM client pool provider-select + retry/rotation pool scaffold port + reshape \u2717"},{"location":"12_genericity_matrix/#tier-c-app-specific-must-be-authored","title":"Tier C \u2014 App-specific (must be authored)","text":"Artifact Why Resource models the business shape Repository populate/cache rules the relationships Service business logic domain behaviour Pipeline families the transformation graph Pattern/rule resources data-driven policy Fixtures & golden outputs test data"},{"location":"12_genericity_matrix/#the-two-axes","title":"The two axes","text":"

    Everything app-specific reduces to two axes:

    1. Resource model \u2014 the set of resources, their fields, relationships, and the OpenAPI contract.
    2. Pipeline family \u2014 only if inputs require multi-step transformation.

    If you can specify those two axes, the rest of the app follows mechanically: Tier A is imported, Tier B is copied, and Tier C is the only thing you author.

    "},{"location":"13_library_registry/","title":"Library Registry","text":""},{"location":"13_library_registry/#summary","title":"Summary","text":"

    The Aetos ecosystem provides internal libraries for the shared concerns of every application. Use them. Writing a private copy of any capability below is a defect.

    Each library also exposes its own documentation as an MCP server. An AI agent can read a library's full API by connecting to its MCP and reading docs://index, docs://nav, and docs://modules/{module}.

    "},{"location":"13_library_registry/#catalog","title":"Catalog","text":"Library Import Purpose Use instead of MCP DAG Pipe dagpipe Deterministic state-transformation DAG engine hand-rolled orchestration/topological ordering :8006 Hexa hexa Declarative DI / composition-root tooling manual wiring, hand-written factories :8008 Mongo Ops mongo_ops Async MongoDB repositories, cache, populate, transactions raw Motor CRUD and connection lifecycle :8007 Omniread omniread Format-agnostic fetch + parse (HTML, PDF, CSV, XLSX) custom scrapers/parsers :8003 OpenAPI First openapi_first Spec-first FastAPI bootstrap, client, codegen decorator routers and hand-written clients :8004 Mail Intake mail_intake Provider-agnostic read-only email ingestion Gmail OAuth + MIME parsing :8002 Py JWT jwtlib JWT auth primitives (register/login/introspect) password hashing + token code :8005 Doc Forge docforge Docstring compiler \u2192 MkDocs + MCP docs custom doc generators :8001 Auth Server (service) Central identity service (register/login/me/logout/introspect) building auth endpoints yourself spec: docs://spec"},{"location":"13_library_registry/#how-to-choose","title":"How to choose","text":"You need to\u2026 Use persist and query documents Mongo Ops compose dependencies Hexa run a multi-step transformation DAG Pipe read/parse an arbitrary input format Omniread expose a contract-first HTTP API OpenAPI First ingest email Mail Intake authenticate users / verify tokens Py JWT (+ Auth Server) generate documentation Doc Forge"},{"location":"13_library_registry/#discovery","title":"Discovery","text":"

    A single standards MCP exposes find_library(capability), which returns the matching library, its import name, its \"use instead of\" guidance, and its MCP endpoint (or, for the auth-server service, a spec pointer). It also serves the pinned auth-server OpenAPI contract at docs://spec. Query it before writing any infrastructure.

    "},{"location":"13_library_registry/#notes","title":"Notes","text":"
    • Hexa is a full library with its own MCP server on :8008: read docs://index, docs://nav, and docs://modules/{module} (e.g. docs://modules/hexa.container) to discover the DI surface \u2014 build(cls, *, instances, config) and the PortNode model.
    • Auth Server is a service, not an importable library: it has no MCP bundle by design. Read its client contract from the pinned OpenAPI document via docs://spec and wire it by declaring a bearerAuth security scheme in the app's own spec (see Auth Integration); py-jwt covers the low-level token path.
    • Library MCP servers expose documentation resources (not executable tools): they tell an agent the available API surface so it does not invent code.
    "},{"location":"14_auth_integration/","title":"Auth Integration","text":""},{"location":"14_auth_integration/#summary","title":"Summary","text":"

    Authentication is a service, not a library. Every Aetos application shares a single identity service \u2014 the auth-server \u2014 and consumes it through its HTTP contract. An app never implements registration, login, password hashing, or token issuance itself.

    The agent does not need an MCP bundle for the auth-server. It reads the pinned OpenAPI contract (below) and declares a bearer security scheme in its own spec; openapi_first then generates the verifying dependency. No auth code is written.

    "},{"location":"14_auth_integration/#read-the-contract","title":"Read the contract","text":"

    The auth-server OpenAPI document is pinned in the standards bundle and served as an MCP resource:

    docs://spec\n

    It is the authoritative client contract (OpenAPI 3.1). Read it to learn the endpoints and the request/response schemas:

    Endpoint Purpose POST /register Create a user (201, returns PublicUser) POST /login Authenticate and issue a JWT (LoginResponse) GET /me Current user's PublicUser (bearer required) POST /logout Stateless logout (LogoutResponse) POST /introspect Internal token introspection (active, user)

    The pinned snapshot is versioned (currently 0.0.5). If the caller has a live auth-server and needs the current contract, they can pass the full endpoint ({AUTH_SERVER}/openapi.json) and read it directly instead of the pin.

    "},{"location":"14_auth_integration/#wire-it-up-declare-dont-code","title":"Wire it up: declare, don't code","text":"

    Authentication is added by editing the app's own openapi.yaml \u2014 nothing else. Declare a global bearer requirement and point the scheme at the auth server (values come from the environment):

    security:\n  - bearerAuth: []\npaths:\n  # ...\ncomponents:\n  securitySchemes:\n    bearerAuth:\n      type: http\n      scheme: bearer\n      bearerFormat: JWT\n      x-server-url: \"{AUTH_SERVER}\"\n      x-introspect-path: \"/introspect\"\n      x-login-path: \"/login\"\n      x-register-path: \"/register\"\n      x-logout-path: \"/logout\"\n      x-me-path: \"/me\"\n

    openapi_first reads securitySchemes + security and generates a FastAPI dependency that extracts the bearer token, POSTs {\"token\": <jwt>} to {AUTH_SERVER}/introspect, and returns the user when active == true. It raises 401 on an invalid or inactive token and 503 when the auth server is unreachable. The generated handlers receive the authenticated user \u2014 you author no authentication code.

    "},{"location":"14_auth_integration/#public-operations","title":"Public operations","text":"

    A route that must stay open opts out by overriding security with an empty list:

    paths:\n  /health:\n    get:\n      operationId: health\n      security: []        # overrides the global requirement\n      responses:\n        \"200\":\n          description: OK\n
    "},{"location":"14_auth_integration/#environment","title":"Environment","text":"
    AUTH_SERVER=http://localhost:8000     # auth-server base URL\nJWT_SERVER=http://localhost:8000      # jwtlib client base URL (seeding/CLI)\n
    "},{"location":"14_auth_integration/#path-1-jwtlib-client-no-generator","title":"Path 1: jwtlib client (no generator)","text":"

    Apps that do not use a generated dependency verify requests with the py-jwt client:

    from jwtlib.introspection import authenticate_request\n\nauthorized = await authenticate_request(\n    should_skip_authentication,  # allow public paths\n    method,\n    path,\n    authorization_token,         # \"Bearer <jwt>\" or None\n)\n

    authenticate_request POSTs to {JWT_SERVER}/introspect (3 second timeout) and treats {\"active\": true, \"user\": {...}} as valid. Use this for seeding scripts and tests (jwtlib.register_user, jwtlib.login_user).

    "},{"location":"14_auth_integration/#golden-rules","title":"Golden rules","text":"
    1. Never trust an unverified token. Decode through the generated dependency or jwtlib before handling the request.
    2. Treat active: false as unauthenticated, even if the JWT decodes.
    3. Do not implement your own JWT parsing. Revocation and issuer changes must stay centralized in the auth-server.
    4. Do not add auth until the app's outcome is validated. Ship the app authless first; layer the security scheme once the core behaviour works.
    "},{"location":"14_auth_integration/#notes","title":"Notes","text":"
    • The default template is authless on purpose. Add the securitySchemes block above only when auth is required. Pull the shared slice with get_app_component(\"auth\").
    • The auth-server is deployed as a service (no importable package); the client surface is the spec, plus jwtlib for the low-level path.
    "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Standards Reference","text":"

    The reference half of the Standards description: the enforceable rules, patterns, and the internal library catalog that agents consult while coding.

    • Build Recipe \u2014 the ordered, agentic checklist for a new app.
    • Layering Rules \u2014 the strict request \u2192 domain \u2192 repository layering and the rules that enforce it.
    • Composition Root \u2014 a single composition point wiring the whole app.
    • Spec-First Routing \u2014 the OpenAPI contract as the routing source of truth.
    • CRUD Template \u2014 the standardized generic resource endpoint scaffold.
    • Pipeline Scaffold \u2014 the deterministic pipeline skeleton for multi-stage jobs.
    • Worker & Progress \u2014 queued work, progress reporting, and visibility.
    • Human-in-the-Loop \u2014 guardrails and approvals inside automations.
    • Infra Adapters \u2014 how infrastructure connects without leaking into domain.
    • Drone Pipelines \u2014 the two CI shapes: a PyPI package or a Docker deployment.
    • Versioning & Changelog \u2014 SemVer, the tag\u2194version contract, and the release changelog.
    • Repository Inventory \u2014 every covered repo, its type, version source, and Drone shape.
    • Genericity Matrix \u2014 what is library-backed, template-provided, or authored.
    • Auth Integration \u2014 consuming the shared auth-server service (spec-driven, no auth code).
    • Library Registry \u2014 the catalog of internal libraries behind all of it.

    Read the Wiki for the philosophy and rationale; these pages are the reference that mirrors the standards MCP bundle.

    "},{"location":"01_build_recipe/","title":"Build Recipe","text":""},{"location":"01_build_recipe/#summary","title":"Summary","text":"

    The ordered, deterministic checklist for generating a new application of the standard shape. Every step is fixed; only the resource model (step 2), the codegen pass (step 3), and the pipeline family (step 8) need app-specific work.

    This page is served by the standards MCP as docs://modules/build_recipe. The start_app prompt on that server collects the two axes and hands off here; pull exact files with get_app_component.

    "},{"location":"01_build_recipe/#bootstrap","title":"\ud83d\ude80 Bootstrap","text":"

    From the standards docs checkout:

    cp -r <docs>/standards/src/templates/app apps/<your-app>\ncd apps/<your-app>\n

    Install the internal libraries \u2014 editable local checkouts (preferred in development) or the private index (CI / fresh machines). Credentials are environment-only; never commit them.

    # local checkouts\npip install -e ../aetos/openapi-first -e ../aetos/mongo-ops -e ../aetos/hexa \\\n            -e ../aetos/dagpipe -e ../aetos/doc-forge\n# private index\npip install --extra-index-url \\\n  \"https://$PIP_REGISTRY_USERNAME:$PIP_REGISTRY_PASSWORD@pip.aetoskia.com/simple\" .\n
    "},{"location":"01_build_recipe/#agent-prompt-copyable","title":"\ud83d\udccb Agent prompt (copyable)","text":"
    # Build a new application from the Aetos Standards blueprint\n\nYou are coding a complete new backend application conforming to the Aetos\nstandard app blueprint. Execute every step in order. Only steps 2\u20134 use the\napp-specific details provided by the user; everything else is deterministic.\n\n## Before writing any code\n\nConnect to the `standards` MCP server and read:\n- `docs://nav` (the module list)\n- `docs://modules/genericity_matrix` (Tier A library / Tier B template / Tier C authored)\n- `docs://modules/layering_rules` (the dependency rules)\n\nThen:\n- call `find_library` with `db`, `di`, `routing`, `ingestion`, `pipeline`, `docs`\n  and note the Tier A libraries that already exist \u2014 never reimplement one;\n- call `list_app_components()` and pull each file you need with\n  `get_app_component(kind, resource=..., family=...)` instead of writing it from\n  scratch.\n\n## Steps\n\n1. **Scaffold** \u2014 copy `standards/src/templates/app/` into `apps/<your-app>/`\n   (or pull the same tree via `get_app_template`). Keep the tree: `domain/`,\n   `infra/`, `interfaces/`, `pipelines/`, `tests/`, `scripts/`, plus\n   `pyproject.toml`, `openapi.yaml`, `config.py`, `init.py`, `main.py`,\n   `worker.py`, `Dockerfile`, `docker-compose.yaml`, `.env.example`.\n\n2. **Author the spec (app-specific)** \u2014 write `openapi.yaml`: resources,\n   schemas, `operationId`s, security, and extension metadata. This is the\n   contract and drives all routing. Every operation MUST have an `operationId`.\n\n3. **Generate the scaffold (codegen)** \u2014 from the spec, generate the wire\n   models and the exact handler signatures:\n   ```bash\n   openapi-first models openapi.yaml -o _gen/models.py\n   openapi-first routes openapi.yaml -o _gen/routes \\\n     --use-models --models-module _gen.models --inject-request --package --template-style\n   ```\n   `_gen/models.py` is the **wire contract** (Pydantic, one class per\n   `components.schemas` entry). `_gen/routes/<resource>/routes.py` lists every\n   `operationId` with its exact parameter signature. `--template-style` makes\n   those stubs `async def` with a `body` parameter, matching the handlers you\n   keep in `interfaces/` (without it they are sync `def` stubs taking\n   `payload`; both bind the same way). Treat `_gen/` as generated\n   (never hand-edit it) \u2014 the canonical handlers live in `interfaces/`.\n\n4. **Write each CRUD slice (app-specific)** \u2014 per resource create the four-file\n   slice: `models.py` (domain model, **no `id`**), `ports/db.py`\n   (`class XDocument(BaseDocument, X)` \u2014 id comes from `BaseDocument`),\n   `ports/service.py`, and optional `converters.py`. Follow the CRUD template.\n\n5. **Wire the composition root** \u2014 in `init.py`, build leaf repositories, then\n   dependent repositories, then services; add infra adapters (db, cache, stores,\n   progress bus, fetchers). Expose `get_svc` overloads.\n\n6. **Add routes** \u2014 create `interfaces/<resource>/routes.py` thin handlers whose\n   names match the `operationId`s (use the signatures from step 3 as your\n   checklist) and re-export them in `interfaces/openapi.py`. Add the cache\n   decorator to read endpoints.\n\n7. **Bootstrap app and worker** \u2014 confirm `main.py` runs the OpenAPI-first app\n   with its lifespan. If the app has long-running jobs, adapt `worker.py` to poll\n   the job collection, run the pipeline, and publish progress.\n\n8. **Add pipeline families (only if data-driven)** \u2014 copy `pipelines/example/`\n   to `pipelines/<family>/` with `abc.py`, `impl.py`, `pipeline.yaml`,\n   `resources/`, and reuse `pipelines/shared/` (loader + registry). Register the\n   root. Add fixtures and a parity test.\n\n9. **Add infrastructure only where needed** \u2014 Tier A capability: use the\n   library. Tier B capability: copy the template. Never hand-write a Tier A\n   library.\n\n10. **Tests** \u2014 integration tests with fakes at the HTTP edge; unit tests for\n    domain and pipeline logic; a config-consistency test for rule-driven\n    pipelines. Include `tests/integration/test_openapi_app_builds.py` (imports\n    the app, asserts `import main` binds every operation).\n\n11. **Scripts and seeds** \u2014 operator scripts under `scripts/` using\n    `init()` / `get_svc()` / `shutdown()`; run as `python -m scripts.<name>`.\n\n12. **Docs** \u2014 author GSDFC docstrings, generate `.pyi` stubs, mark the package\n    `py.typed`, and build the docs.\n\n**Definition of done:**\n- `python -c \"import main\"` succeeds.\n- `pytest` passes.\n- The app serves every operation in the spec; the worker drains its queue.\n- No domain module imports a web framework.\n- No Tier A library was reimplemented.\n
    "},{"location":"01_build_recipe/#where-the-steps-land","title":"\ud83e\udded Where the steps land","text":"

    The steps map onto the layers as follows:

    Step Package / file Depends on 1 \u00b7 Scaffold whole templates/app/ \u2014 2 \u00b7 Spec openapi.yaml \u2014 3 \u00b7 Codegen _gen/ (generated) spec, openapi-first 4 \u00b7 CRUD slices domain/<resource>/ spec, CRUD template 5 \u00b7 Wiring init.py every slice 6 \u00b7 Routes interfaces/<resource>/ services, openapi route registry 7 \u00b7 Bootstrap main.py, worker.py composition root 8 \u00b7 Pipelines pipelines/<family>/, shared/ library pipeline engine 9 \u00b7 Infra infra/ domain ports 10 \u00b7 Tests tests/ app + fixtures 11 \u00b7 Scripts scripts/ composition root 12 \u00b7 Docs docstrings + docs build code, Doc Forge"},{"location":"01_build_recipe/#the-codegen-fast-path-in-detail","title":"\ud83d\udd27 The codegen fast path, in detail","text":"

    openapi-first is spec \u2192 code only (it never generates a spec). Use it to erase the two mechanical parts of the build:

    Generated artifact Replaces Notes _gen/models.py hand-writing Pydantic wire models one class per components.schemas entry _gen/routes/<resource>/routes.py hand-typing handler signatures names == operationIds; request: Request injected

    Rules of the road:

    • Wire models are not domain models. _gen/models.py is the HTTP contract; domain/<resource>/models.py is your business shape. If the spec's schema has a required id: str, keep it off the domain model and let the document get its id from BaseDocument.
    • Use --template-style. Stubs are then async def ...(request, body: ...) matching interfaces/; without it they are sync def ...(payload: ...). Either binds (the router introspects the signature), but --template-style keeps the scaffold consistent with the code you keep.
    • Resource names are sanitized. /fetch-requests \u2192 fetch_requests.py.
    • Multipart bodies expand to UploadFile = File(...) / Form(...) params.
    • _gen/ is disposable. Regenerate on every spec change; git diff shows exactly what moved.
    "},{"location":"01_build_recipe/#definition-of-done","title":"\u26a0\ufe0f Definition of done","text":"
    • python -c \"import main\" succeeds.
    • pytest passes.
    • The app serves the spec's operations; the worker drains its queue.
    • No domain module imports a web framework.
    • No Tier A library was reimplemented.
    "},{"location":"01_build_recipe/#related","title":"Related","text":"
    • 02 \u2013 Layering Rules \u00b7 05 \u2013 CRUD Template \u00b7 06 \u2013 Pipeline Scaffold \u00b7 12 \u2013 Genericity Matrix
    "},{"location":"02_layering_rules/","title":"Layering Rules","text":""},{"location":"02_layering_rules/#summary","title":"Summary","text":"

    The dependency direction is fixed. Violating it is a design defect.

    "},{"location":"02_layering_rules/#allowed-imports","title":"Allowed imports","text":"
    interfaces/*      ->  domain/*            (services, ports, models)\ninterfaces/*      ->  infra/adapters/*    (only read-only value objects)\ndomain/*          ->  domain/*            (same layer)\ndomain/*          ->  pipelines/*         (call a pipeline via a port)\ndomain/*/ports/*  ->  infra/*             (bind adapters + libraries at the seam)\ninfra/adapters/*  ->  domain/ports/*      (implement the interface)\nmain.py/init.py   ->  everything          (composition root only)\n
    "},{"location":"02_layering_rules/#forbidden-imports","title":"Forbidden imports","text":"
    domain/*          ->  interfaces/*        (never)\ndomain/*          ->  fastapi/starlette   (never)\ninfra/adapters/*  ->  interfaces/*        (never)\ninterfaces/*      ->  infra/db/*          (state lives in resources, not imports)\n
    "},{"location":"02_layering_rules/#why","title":"Why","text":"
    • The business logic is testable without a server or an event loop.
    • Adapters can be swapped (in-memory fake, real database) without touching business logic.
    • The HTTP edge stays thin and replaceable.
    "},{"location":"02_layering_rules/#the-portadapter-contract","title":"The port/adapter contract","text":"

    The ports/ package is the seam where the domain meets infrastructure. Each domain/<resource>/ports/ module declares the resource's models/document shape and exposes factory functions that bind a concrete adapter \u2014 so a port module is allowed to import from infra/ and from the persistence libraries. Everything outside ports/ in domain/ stays framework- and driver-free.

    domain/<resource>/ports/db.py       -> document model + create_<resource>_repo()\ndomain/<resource>/ports/service.py  -> service + get_<resource>_service()\ninfra/db/repos/<vendor>.py          -> repository adapter factory\ninfra/adapters/service.py           -> generic CRUD service base\n

    The composition root calls the port factories; nothing else constructs an adapter.

    "},{"location":"02_layering_rules/#enforcement","title":"Enforcement","text":"
    • domain/ must never import the web framework (fastapi / starlette) or interfaces/. Only the ports/ seam, infra/, and the composition root touch drivers.
    • Reviewers (and CI) reject import fastapi inside domain/ or infra/.
    "},{"location":"03_composition_root/","title":"Composition Root","text":""},{"location":"03_composition_root/#summary","title":"Summary","text":"

    All wiring happens in exactly one module. It builds a flat resource registry and exposes it to the HTTP layer and to scripts.

    "},{"location":"03_composition_root/#the-resource-registry","title":"The resource registry","text":"

    init.py returns a plain dict[str, Any]. Keys follow two conventions:

    • <resource>_repo \u2014 a repository adapter for a resource.
    • <resource>_svc \u2014 a service for a resource.

    Plus named infrastructure adaptors:

    • http_cache_store \u2014 response cache backend.
    • progress_bus \u2014 progress/event bus.
    • <vendor>_<kind> \u2014 fetchers, clients, stores.

    The API stores the dict on app.state.db_resources during lifespan startup. Handlers read from it; nothing imports concrete adapters.

    "},{"location":"03_composition_root/#shape","title":"Shape","text":"
    _resources: dict = {}\n_initialized = False\n\nasync def init(settings=None) -> dict:\n    global _initialized\n    if _initialized:\n        return _resources\n\n    await setup_database(uri=settings.mongo_uri, db_name=settings.mongo_db)\n\n    # 1. leaf repositories\n    user_repo = create_user_repo()\n\n    # 2. dependent repositories (dependencies passed by keyword)\n    wallet_repo = create_wallet_repo(user_repo=user_repo)\n\n    # 3. services (build via the DI library, injecting the repo)\n    _resources[\"user_repo\"]   = user_repo\n    _resources[\"wallet_repo\"] = wallet_repo\n    _resources[\"user_svc\"]    = get_user_service(user_repo)\n    _resources[\"wallet_svc\"]  = get_wallet_service(wallet_repo)\n\n    # 4. infrastructure adaptors (optional)\n    _resources[\"http_cache_store\"] = HttpCacheStore(...)\n    _resources[\"progress_bus\"]     = ProgressEventBus()\n\n    _initialized = True\n    return _resources\n\nasync def shutdown() -> None:\n    global _initialized\n    await close_stores(_resources)\n    await shutdown_database()\n    _resources.clear()\n    _initialized = False\n
    "},{"location":"03_composition_root/#typed-accessors","title":"Typed accessors","text":"

    Expose a get_svc(name) helper with one @overload per key so scripts get typing without importing concrete classes:

    @overload\ndef get_svc(name: Literal[\"user_svc\"]) -> UserService: ...\n@overload\ndef get_svc(name: Literal[\"wallet_svc\"]) -> WalletService: ...\n\ndef get_svc(name: str):\n    return _resources[name]\n

    Also expose get_db() (raw database handle) and pure helpers such as compute_fingerprint(payload) (canonical hash used for deduplication).

    "},{"location":"03_composition_root/#rules","title":"Rules","text":"
    • init() is idempotent.
    • The composition root is the only place that imports concrete adapters.
    • Handlers never call init(); they read request.app.state.db_resources.
    • Scripts call init() / shutdown() around their work.
    "},{"location":"04_spec_first_routing/","title":"Spec-First Routing","text":""},{"location":"04_spec_first_routing/#summary","title":"Summary","text":"

    The OpenAPI document is the single source of truth for the HTTP contract. Handlers are bound to it by name; there is no decorator router.

    "},{"location":"04_spec_first_routing/#the-contract","title":"The contract","text":"
    • openapi.yaml (or .json) declares paths, schemas, parameters, responses, and security.
    • A custom operationId names the handler function.
    • The framework (openapi_first) validates requests/responses against the spec and dispatches to the handler whose name equals operationId.
    "},{"location":"04_spec_first_routing/#app-bootstrap","title":"App bootstrap","text":"
    # main.py\nfrom openapi_first.app import OpenAPIFirstApp\n\napp = OpenAPIFirstApp(\n    openapi_path=\"openapi.yaml\",\n    routes_module=interfaces.openapi,   # module whose namespace holds handlers\n    title=\"<App> API\",\n    version=\"0.1.0\",\n    lifespan=lifespan,\n)\n

    lifespan calls the composition root:

    @asynccontextmanager\nasync def lifespan(app):\n    app.state.db_resources = await init()\n    yield\n    await shutdown()\n
    "},{"location":"04_spec_first_routing/#handler-registry","title":"Handler registry","text":"

    interfaces/openapi.py is a flat re-export of every handler, so the framework can resolve operationId across the whole app:

    from interfaces.item.routes import *\nfrom interfaces.wallet.routes import *\nfrom interfaces.progress.sse import *\n
    "},{"location":"04_spec_first_routing/#handler-shape","title":"Handler shape","text":"

    Handlers are thin and synchronous with respect to business logic:

    async def create_item(request: Request, body: dict):\n    svc = request.app.state.db_resources[\"item_svc\"]\n    return await svc.create(Item.model_validate(body))\n

    Generated stubs. openapi-first routes emits this exact shape (async def handlers taking body) when given --template-style; without that flag the stub is def create_item(payload: ItemInput) \u2014 sync, with a payload parameter. Both shapes bind identically: the router resolves handlers by operationId and introspects the FastAPI signature, and it never inspects the request body. Pass --template-style so the generated signatures match the handlers you keep in interfaces/.

    "},{"location":"04_spec_first_routing/#conventions","title":"Conventions","text":"
    • operationId naming: list_<resource>, create_<resource>, get_<resource>, update_<resource>, delete_<resource>.
    • Read-only endpoints may use a cache decorator keyed on path + query + user.
    • Validation errors -> 400; not found -> 404; delete -> 204.
    • Security is declared once in the spec and enforced by the framework; handlers contain no auth code.
    "},{"location":"04_spec_first_routing/#authless-apps","title":"Authless apps","text":"

    Auth is deferred in the standard: the same spec-first app runs with or without it, because security lives entirely in the spec, never in handlers. For an app that needs no auth yet, do not invent per-handler auth checks \u2014 just omit the security keys:

    • Remove the top-level security: block.
    • Remove components.securitySchemes.
    • Do not add security: [] to operations. An explicit empty array is a per-operation override that means \"public\", and it only matters when a global security block exists. Leaving every operation without a security key is the cleanest authless spec.

    Profile endpoints (/users/me) and profile headers (x-profile) still exist in an authless app. Define a stand-in identity in the composition root \u2014 for example get_current_user returns or lazily creates a fixed \"Demo User\" \u2014 so handlers stay auth-agnostic and only the wiring changes when real auth arrives.

    The handlers, services, and composition root are unchanged. When auth is needed later, add the global security block and an introspecting dependency; only handlers that must opt out get security: [].

    "},{"location":"04_spec_first_routing/#codegen","title":"Codegen","text":"

    openapi_first scaffolds models and route stubs from the spec (see the Build Recipe, step 3):

    openapi-first models openapi.yaml -o _gen/models.py\nopenapi-first routes openapi.yaml -o _gen/routes \\\n  --use-models --models-module _gen.models --inject-request --package --template-style\n

    Prefer codegen over hand-writing boilerplate. The result is the wire contract and a set of operationId-named signatures \u2014 not the canonical handlers.

    "},{"location":"05_crud_template/","title":"CRUD Template","text":""},{"location":"05_crud_template/#summary","title":"Summary","text":"

    Every resource follows the same four-file slice. Repetition is intentional: it makes the codebase predictable and generatable.

    "},{"location":"05_crud_template/#the-slice","title":"The slice","text":"
    domain/<resource>/\n    models.py               # pure Pydantic model (no DB fields)\n    ports/\n        db.py               # document model + repository factory\n        service.py          # service class + factory\n        converters.py       # (optional) transforms\n
    "},{"location":"05_crud_template/#the-id-rule-model-vs-document","title":"The id rule (model vs. document)","text":"

    Two different objects, two different jobs:

    Object Lives in Has id? Purpose Domain model domain/<resource>/models.py No business shape, framework-free Document domain/<resource>/ports/db.py Yes (from BaseDocument) Mongo persistence shape

    BaseDocument (mongo-ops) supplies id: Optional[PyObjectId] (aliased to _id) plus created_at / updated_at. The domain model must not declare id; Mongo owns it.

    Trap \u2014 generated wire models. openapi-first models produces the HTTP contract (see the Build Recipe, step 3). Response schemas frequently declare a required id: str, so a generated class is not a domain model. If you write class ItemDocument(Item, BaseDocument) and Item re-exports a required id: str, that field shadows BaseDocument.id and no Mongo _id can ever be set. Fix it one of three ways:

    1. Preferred: keep the domain model id-free (hand-author it from the CRUD template), and keep the required id only on the wire model.
    2. Order the bases so the document wins: class ItemDocument(BaseDocument, Item).
    3. Keep a separate document type and translate with ports/converters.py.
    "},{"location":"05_crud_template/#modelspy","title":"models.py","text":"

    A framework-free Pydantic model describing the business shape (no id).

    class Item(BaseModel):\n    name: str\n    quantity: int = 0\n
    "},{"location":"05_crud_template/#portsdbpy","title":"ports/db.py","text":"

    The persistence model extends the business model and adds database concerns. The repository factory selects the right repository flavour.

    # Item is id-free; BaseDocument adds id/created_at/updated_at.\nclass ItemDocument(Item, BaseDocument):\n    pass\n\ndef create_item_repo(*, owner_repo=None) -> ItemRepository:\n    return repo_factory(\n        collection=\"items\",\n        document=ItemDocument,\n        populate_rules=[PopulateRule(field_name=\"owner\", collection_name=\"users\")],\n        cache=None,               # or a CachedBaseRepository config\n    )\n
    "},{"location":"05_crud_template/#nested-references","title":"Nested references","text":"

    The wire contract often declares a reference as an expanded object (expense.entity: Entity), while the domain model stays id-free. Pick one convention and apply it consistently:

    • Embed (default for small, stable refs) \u2014 store the object as a dict / list[dict] on the document; the API returns it verbatim. No populate wiring.
    • Populate \u2014 store an id and declare a PopulateRule; mongo-ops expands it on read. The referenced repo must be registered with the PopulationEngine.
    • Id only \u2014 store the id and let the client resolve it.

    For populate-backed repositories change a reference with update, not patch: patch rejects changes to populated FK fields by design.

    "},{"location":"05_crud_template/#portsservicepy","title":"ports/service.py","text":"

    The service is built through the DI library, injecting the repository. The generic CRUD base provides create/read/update/patch/delete/search/....

    class ItemService(CrudsServiceAdaptor[Item, ItemDocument]):\n    model = Item\n    schema = ItemDocument\n\ndef get_item_service(repo) -> ItemService:\n    return build(ItemService, instances={\"repo\": repo})\n
    "},{"location":"05_crud_template/#naming-conventions","title":"Naming conventions","text":"Concept Convention collection plural snake case (items) document <Resource>Document repository factory create_<resource>_repo service <Resource>Service service factory get_<resource>_service resource key <resource>_svc operationId list_items, create_item, ..."},{"location":"05_crud_template/#optional-files","title":"Optional files","text":"
    • converters.py \u2014 pure functions mapping between domain types.
    • ports/enrichment.py \u2014 adapts a pipeline into an async callable the service can invoke (used when a resource is populated by a pipeline).
    "},{"location":"06_pipeline_scaffold/","title":"Pipeline Scaffold","text":""},{"location":"06_pipeline_scaffold/#summary","title":"Summary","text":"

    Data-driven processing is expressed as a composition graph. The graph is built by a DI library; execution is driven by a DAG engine. Stages are pure and individually testable.

    "},{"location":"06_pipeline_scaffold/#when-to-use-a-pipeline","title":"When to use a pipeline","text":"

    Use a pipeline when a resource is produced by a multi-step transformation of an input (a document, a file, a message) rather than by a simple CRUD write.

    "},{"location":"06_pipeline_scaffold/#structure-of-a-family","title":"Structure of a family","text":"

    A family is one input shape (e.g. a file format or a message kind). Each family has the same skeleton:

    pipelines/<family>/\n    abc.py            # port contracts (stage interfaces + root interface)\n    impl.py           # concrete stages + root implementation\n    pipeline.yaml     # graph spec: nodes, edges, roots, schema\n    resources/\n        pipeline.yaml # runtime spec consumed by the loader\n        patterns/*.yaml  # rule fragments (pattern registry)\n    banks/<variant>.py   # optional variants that re-pin a few slots\n
    "},{"location":"06_pipeline_scaffold/#shared-scaffolding","title":"Shared scaffolding","text":"
    pipelines/shared/\n    ports.py     # RegistryPort, FinalizePort, etc.\n    loader.py    # build(root_cls) -> wires the graph + engine\n    registry.py  # resolve_root(...) -> root class for a (kind, variant)\n
    "},{"location":"06_pipeline_scaffold/#the-loader","title":"The loader","text":"
    def build(root_cls, *, instances=None, config=None):\n    # merge resources/patterns/*.yaml into a pattern registry\n    # bind registry/config into each graph node by id\n    # build the schema (state) class and the engine\n    root = root_cls()\n    root._engine = Engine(graph, state_cls, payload_cls)\n    return root\n
    "},{"location":"06_pipeline_scaffold/#the-registry","title":"The registry","text":"

    A single lookup replaces hand-rolled if/else selection:

    _FAMILIES = {\n    \"csv\":  {\"acme\": {\"heuristic\": AcmeCsvPipeline}},\n    \"json\": {\"globex\": {\"heuristic\": GlobexJsonPipeline}},\n}\n\ndef resolve_root(kind, variant, mode=\"heuristic\"):\n    return _FAMILIES[kind][variant][mode]\n

    Adding a new variant means adding one class and one registry entry.

    "},{"location":"06_pipeline_scaffold/#driving-a-pipeline","title":"Driving a pipeline","text":"

    Stages are driven explicitly so intermediate state can be persisted:

    pipeline = build(resolve_root(kind, variant))\ncontent = pipeline.ingest.materialize(raw_bytes)\nrecords = pipeline.reader.read(content)\nitems   = pipeline.normalize.build(records)\n
    "},{"location":"06_pipeline_scaffold/#testing","title":"Testing","text":"

    Because stages are pure, test each stage in isolation and test the assembled root against fixture inputs whose expected outputs are stored as golden files. A parity test replays fixtures headlessly.

    "},{"location":"07_worker_and_progress/","title":"Worker & Progress","text":""},{"location":"07_worker_and_progress/#summary","title":"Summary","text":"

    Long-running work runs in a background worker. Jobs are durable documents that move through an explicit status machine. Progress is streamed to clients.

    "},{"location":"07_worker_and_progress/#the-status-machine","title":"The status machine","text":"
    pending -> processing -> completed\n                     \\-> failed    (retried up to N times)\n                     \\-> paused    (waiting for human input)\n
    • pending \u2014 queued, eligible for pickup.
    • processing \u2014 claimed by a worker.
    • paused \u2014 blocked on a human-in-the-loop question.
    • failed \u2014 error; retry_count increments until a max, then skipped.
    • completed \u2014 terminal success.
    "},{"location":"07_worker_and_progress/#the-poll-loop","title":"The poll loop","text":"
    async def poll(resources):\n    backoff = MIN_POLL\n    while True:\n        jobs = await job_svc.search(filter={\"status\": \"pending\"}, limit=100)\n        backoff = MIN_POLL if jobs else min(backoff * 2, MAX_POLL)\n        for job in jobs:\n            if (job.retry_count or 0) >= MAX_RETRIES:\n                continue\n            await job_svc.update_status(job.id, \"processing\")\n            try:\n                await process(job, resources)\n            except PauseForResolution:\n                await job_svc.update_status(job.id, \"paused\")\n            except Exception as e:\n                await job_svc.update_status(\n                    job.id, \"failed\", error=str(e),\n                    retry_count=(job.retry_count or 0) + 1,\n                )\n        await asyncio.sleep(backoff)\n

    Tunables live in environment variables: WORKER_POLL_MIN, WORKER_POLL_MAX, WORKER_MAX_RETRIES.

    "},{"location":"07_worker_and_progress/#progress-events","title":"Progress events","text":"

    A worker publishes structured progress events to a bus (a port). The HTTP edge exposes a streaming endpoint that replays events for a given job id.

    class ProgressEvent(BaseModel):\n    job_id: str\n    step: str\n    status: str            # started | progress | completed | skipped | paused\n    message: dict | None = None\n

    The bus is an in-memory adapter by default; because it is a port, it can be swapped for a durable broker. Emit from the orchestrator at each stage:

    await self.bus.publish(ProgressEvent(job_id=jid, step=\"normalize\",\n                                     status=\"completed\", message={\"count\": n}))\n
    "},{"location":"07_worker_and_progress/#streaming-endpoint","title":"Streaming endpoint","text":"
    async def stream_job_events(request, id):\n    bus = request.app.state.db_resources.get(\"progress_bus\")\n    if bus is None:\n        return {\"events\": []}\n\n    async def gen():\n        sent = 0\n        while True:\n            events = bus.get_events(id)\n            for e in events[sent:]:\n                yield f\"data: {e.model_dump_json(exclude_none=True)}\\n\\n\"\n                sent += 1\n            await asyncio.sleep(0.5)\n\n    return StreamingResponse(gen(), media_type=\"text/event-stream\")\n

    Known limitation. The default in-memory bus is per-process. If the worker and the API run as separate processes, events published by the worker are not visible to the API. For production, back the bus with a shared broker. The port boundary makes this a one-adapter change.

    "},{"location":"08_human_in_loop/","title":"Human-in-the-Loop","text":""},{"location":"08_human_in_loop/#summary","title":"Summary","text":"

    Some inputs are ambiguous and must be resolved by a human before processing can continue. The blueprint models this as a durable pause: an exception is raised, a question is recorded, the job pauses, and later resumes.

    "},{"location":"08_human_in_loop/#the-mechanism","title":"The mechanism","text":"
    1. During processing, a stage raises a domain exception carrying the context needed to ask the question:
    raise PauseForResolution(\n    job_id=jid,\n    reference=\"<stable key for this decision>\",\n    options=[...],\n    context={...},\n)\n
    1. The orchestrator catches it, records a question document, and re-raises so the worker marks the job paused.
    2. A client lists pending questions and answers one:
    GET  /jobs/{id}/questions            -> list pending questions\nPOST /questions/{qid}/resolve  {choice}  -> record the choice\n
    1. When the last pending question is resolved, the resolve endpoint flips the parent job back to pending.
    2. The worker picks it up again, rebuilds a resolution map from previously answered questions, and seeds it into the pipeline so the same decision is not asked twice.
    "},{"location":"08_human_in_loop/#the-question-document","title":"The question document","text":"
    class Question(BaseDocument):\n    job_id: str\n    reference: str            # stable key: stage|field|value\n    status: str               # pending | resolved\n    options: list[dict]\n    context: dict\n    chosen: dict | None = None\n    resolved_at: str | None = None\n
    "},{"location":"08_human_in_loop/#resume-map","title":"Resume map","text":"

    The worker turns answered questions into a lookup keyed by reference, then injects it into the pipeline so that stage can skip re-raising:

    resolved = {q.reference: q.chosen for q in await svc.search(\n    filter={\"job_id\": jid, \"status\": \"resolved\"})}\n\npipeline = build(root, instances={\"pause\": handler}, config={\"resolved\": resolved})\n
    "},{"location":"08_human_in_loop/#resolve-endpoint","title":"Resolve endpoint","text":"
    async def resolve_question(request, id, body):\n    svc = request.app.state.db_resources[\"question_svc\"]\n    q = await svc.read(id)\n    await svc.update(id, {\"chosen\": body[\"chosen\"], \"status\": \"resolved\",\n                          \"resolved_at\": now()})\n\n    pending = await svc.search(filter={\"job_id\": q.job_id, \"status\": \"pending\"},\n                               limit=1)\n    if not pending:\n        jobs = request.app.state.db_resources[\"job_svc\"]\n        job = await jobs.read(q.job_id)\n        if job and job.status == \"paused\":\n            await jobs.update_status(q.job_id, \"pending\")\n    return q\n
    "},{"location":"08_human_in_loop/#cli-parity","title":"CLI parity","text":"

    The same flow is available through scripts/CLI: list, get, create, questions, resolve, retry.

    "},{"location":"09_infra_adaptors/","title":"Infra Adapters","text":""},{"location":"09_infra_adaptors/#summary","title":"Summary","text":"

    All external systems are reached through adapters in infra/. Prefer an existing internal library over writing a new adapter; where no library exists, copy the Tier B scaffold from templates/app. See the Genericity Matrix for the Tier A / B / C split.

    "},{"location":"09_infra_adaptors/#database-mongodb","title":"Database (MongoDB)","text":"
    • A single connection manager owns the client lifecycle. setup_database(uri, db_name) / shutdown_database().
    • A repository factory selects the repository flavour:
    repo_factory(collection, document, engine=None,\n             populate_rules=None, cache=None)\n
    • base repository \u2014 plain CRUD;
    • populating repository \u2014 resolves referenced documents (foreign keys);
    • cached repository \u2014 an LRU/TTL cache in front of reads.

    • Referenced documents are described declaratively:

    PopulateRule(field_name=\"owner\", collection_name=\"users\",\n             nested_rules=[], max_depth=2, projection=None)\n
    • Transactions use a session context manager provided by the library.

    Tier A \u2014 Library (Mongo Ops). Do not write raw Motor calls in the domain; consult the registry and the library's MCP before touching the driver.

    "},{"location":"09_infra_adaptors/#http-response-cache","title":"HTTP response cache","text":"

    Tier B \u2014 template. Copy from templates/app; not a standalone library.

    A generic GET cache sits behind a decorator.

    @cache_response(ttl=60)\nasync def list_items(request): ...\n
    • Keyed on path + query + user.
    • No-op when no store is wired.
    • invalidate(*resources) bumps a generation counter for write-triggered invalidation.
    "},{"location":"09_infra_adaptors/#event-progress-bus","title":"Event / progress bus","text":"

    Tier B \u2014 template. Copy from templates/app.

    A port with an in-memory default adapter (publish, get_events). Swap for a durable broker in production (see Worker & Progress).

    "},{"location":"09_infra_adaptors/#external-clients-ingestion","title":"External clients (ingestion)","text":"

    External fetchers (files, mail, HTTP) are adapters that wrap ingestion libraries. Construct them in the composition root and inject into orchestrators.

    Tier A \u2014 Libraries: Omniread (formats) and Mail Intake (email).

    "},{"location":"09_infra_adaptors/#llm-clients","title":"LLM clients","text":"

    Tier B \u2014 template. Copy the pool scaffold from templates/app.

    When a pipeline calls a model provider, route through a pool adaptor that handles provider selection, retries, and client lifecycle:

    pool = setup_async_pool(provider=settings.llm_provider)\nresult = await pool.complete(model=\"...\", messages=[...])\n

    Providers are selected by LLM_PROVIDER and configured by environment.

    "},{"location":"09_infra_adaptors/#key-value-store","title":"Key-value store","text":"

    Tier B \u2014 template. Copy from templates/app.

    For report/snapshot storage, provide a pluggable store port with a Redis adapter and an in-memory fallback.

    "},{"location":"09_infra_adaptors/#rule","title":"Rule","text":"
    • Tier A (libraries: DB, DI, ingestion, mail, auth, docs, pipelines) \u2014 use the library; writing a private copy is a defect. Query find_library first.
    • Tier B (cache, progress bus, LLM pool, KV store, composition shape, worker, tests) \u2014 these are template code, not libraries: copy them from templates/app rather than searching the registry.
    • Tier C (models, business logic, pipeline families, rules) \u2014 author them yourself.
    "},{"location":"10_drone_pipelines/","title":"Drone Pipelines","text":""},{"location":"10_drone_pipelines/#summary","title":"Summary","text":"

    Every Aetos repository ships a Drone CI definition at .drone.yml. There is exactly one standard per repository, and there are two types of file, chosen by what the repository produces:

    Type File Produces Repos A \u2014 PyPI package templates/drone/python-lib.yaml A wheel + sdist on the private index dagpipe, doc-forge, hexa, mail-intake, mongo-ops, omniread, openapi-first, py-jwt B \u2014 Docker deployment templates/drone/service-docker.yaml An image pushed to the registry and run as a container auth-server, docs, mcp

    Both templates run on platform: linux / arm64 with the workspace at /drone/src. Copy the matching template to <repo>/.drone.yml; the Type A file needs no edits, the Type B file needs its placeholders filled in (below).

    Conventions: .drone.yml (not .yaml), one file per repo, secrets injected with from_secret \u2014 never commit credentials.

    "},{"location":"10_drone_pipelines/#type-a-pypi-package-python-libyaml","title":"Type A \u2014 PyPI package (python-lib.yaml)","text":"

    For internal libraries. The file contains two pipelines:

    1. build-and-publish-pypi \u2014 triggered on tag:
    2. check-version \u2014 guard: fail unless $DRONE_TAG equals the version in pyproject.toml; then read name / version and query $PIP_REPO_URL/simple/<package>/; if that version already exists, exit 78 and skip the whole build (see 11 \u2013 Versioning & Changelog).
    3. quality-gate \u2014 install the package with its [dev] extras from the private index, then black --check, ruff check, mypy, pydoclint, pytest.
    4. build-package \u2014 python -m build into dist/.
    5. upload-to-private-pypi \u2014 twine upload to $PIP_REPO_URL.
    6. backfill-pypi-from-tags \u2014 triggered on custom:
    7. fetch-tags \u2014 git fetch --tags --force.
    8. build-and-upload-missing \u2014 walk every tag in version order, skip the ones already on the index, git checkout the rest, verify tag == pyproject version at that commit, build, and upload. This is the disaster-recovery / replay path.

    Secrets: PIP_REPO_URL, PIP_USERNAME, PIP_PASSWORD.

    • Ship as-is. Package name and version come from pyproject.toml, so the same file is reused verbatim across every library.
    "},{"location":"10_drone_pipelines/#type-b-docker-deployment-service-dockeryaml","title":"Type B \u2014 Docker deployment (service-docker.yaml)","text":"

    For services and sites that ship a container image. The file contains two pipelines, each mirroring a repo family:

    1. build-and-deploy-service \u2014 triggered on tag (a long-running API/worker service, e.g. auth-server):
    2. fetch-tags \u2014 resolve the latest tag into LATEST_TAG.txt; fail if there are no tags.
    3. check-version \u2014 guard: fail unless $DRONE_TAG equals the repo-root VERSION file (see 11 \u2013 Versioning & Changelog).
    4. check-remote-image \u2014 if aetos/<app>:<tag> already exists locally, exit 78 and skip the build.
    5. quality-gate \u2014 install from requirements.txt and run black / ruff / mypy / pytest.
    6. build-image \u2014 docker build with the private-index build args, tagged aetos/<app>:<tag> and :latest.
    7. push-image \u2014 login, re-tag with $REGISTRY_HOST, push both tags.
    8. stop-old \u2014 docker rm -f <app>.
    9. run-container \u2014 docker run -d --name <app> -p <host>:<container> --restart always with the service's -e environment.
    10. build-and-deploy-site \u2014 triggered on push (a static/HTTP site, e.g. docs, mcp): build-image \u2192 push-image \u2192 stop-old \u2192 run-container, with no tag resolution, no quality gate, and no version guard (it ships :latest only).

    Secrets: PIP_REPO_URL, PIP_USERNAME, PIP_PASSWORD (service build args), REGISTRY_HOST, REGISTRY_USER, REGISTRY_PASS, plus the service runtime env (for example MONGO_*, JWT_SECRET).

    Placeholders to fill in per repo:

    Placeholder Meaning Example <app> service image / container name auth-server aetos/<app> image repository on the registry aetos/auth-server <host-port> / <container-port> published : in-image port 9003:8000 <site> site image / container name docs <ENV_VAR> runtime environment variable MONGO_HOST"},{"location":"10_drone_pipelines/#what-not-to-do","title":"What not to do","text":"
    • Do not hand-roll a third shape. A repo is either Type A or Type B, never both.
    • Do not inline secrets; always use from_secret.
    • Do not drop the check-version / check-remote-image skip \u2014 it guards the index and the running container against duplicate publishes.
    • Do not drop the tag\u2194version guard. A package needs its pyproject.toml version to equal the tag; a service needs a root VERSION file that equals the tag. See 11 \u2013 Versioning & Changelog.
    • Do not rename the pipelines; tooling and runbooks key off build-and-publish-pypi, build-and-deploy-service, and build-and-deploy-site.
    "},{"location":"10_drone_pipelines/#related","title":"Related","text":"
    • 01 \u2013 Build Recipe \u00b7 09 \u2013 Infra Adapters \u00b7 11 \u2013 Versioning & Changelog \u00b7 13 \u2013 Library Registry
    "},{"location":"11_versioning_and_changelog/","title":"Versioning & Changelog","text":""},{"location":"11_versioning_and_changelog/#summary","title":"Summary","text":"

    Every Aetos artifact \u2014 library, service, or site \u2014 is versioned with Semantic Versioning and documents its releases in a Keep a Changelog file. The version file is the source of truth, the git tag must equal it, and a Drone guard enforces that equality before anything is published. Releases are cut manually; a tag is what triggers the pipeline.

    This page pairs with 10 \u2013 Drone Pipelines: the version and tag contract is exactly what those two CI shapes consume.

    "},{"location":"11_versioning_and_changelog/#the-version-contract","title":"The version contract","text":"Artifact Source of truth Notes Library (PyPI package) version in pyproject.toml check-version also reads it to skip duplicates Service / site (Docker) VERSION file at the repo root one line, x.y.z

    Rules:

    1. One version per repository. No per-module versions.
    2. Tag = version. The git tag is bare SemVer (0.0.6), no v prefix, and it MUST match the version file byte-for-byte. The Drone guard fails the build otherwise \u2014 this is what stops a tag from silently publishing nothing.
    3. A release is a tag, created after the change is merged. The version bump and the changelog promotion travel inside the merge request (MR); the tag is added on the merged commit and pushed. See Tagging strategy.
    4. Never reuse a tag. If a release is wrong, cut a new patch version.
    "},{"location":"11_versioning_and_changelog/#pre-10-0yz","title":"Pre-1.0 (0.y.z)","text":"

    While a package is 0.y.z, 0.y is treated as the major line:

    • breaking change \u2192 0.(y+1).0
    • new feature \u2192 0.y.(z+1)
    • bug fix \u2192 0.y.(z+1)

    Once a package reaches 1.0.0, normal SemVer applies. Do not ship 1.0.0 until the public API is considered stable.

    "},{"location":"11_versioning_and_changelog/#the-changelog","title":"The changelog","text":"

    CHANGELOG.md at the repo root, in Keep a Changelog form. It always has exactly one open [Unreleased] section with the change categories that apply:

    ## [Unreleased]\n\n### Added\n### Changed\n### Deprecated\n### Removed\n### Fixed\n### Security\n

    On release you promote it \u2014 never delete history:

    ## [0.0.6] - 2026-03-07\n\n### Added\n- ...\n

    and add a link reference at the bottom:

    [Unreleased]: https://git.aetoskia.com/aetos/<repo>/compare/0.0.6...HEAD\n[0.0.6]: https://git.aetoskia.com/aetos/<repo>/compare/0.0.5...0.0.6\n

    Conventions:

    • Write entries for humans: one line each, imperative, referencing the user impact, not the commit hash.
    • Categories: Added, Changed, Deprecated, Removed, Fixed, Security. Omit empty categories.
    • Security fixes get their own entry even if the change is otherwise a bug fix.
    • The [Unreleased] heading is never renamed; copy its content into the new version heading and clear it.
    "},{"location":"11_versioning_and_changelog/#tagging-strategy-mr-based","title":"Tagging strategy (MR-based)","text":"

    The release version is known while the change is still a merge request, so the bump travels with the change and only the tag is added afterwards:

    1. In the MR \u2014 set the intended release version: version in pyproject.toml (or the VERSION file) to x.y.z, and promote the changelog (below). Changelog entries and link references name the version/tag, never a commit id.
    2. Merge or squash the MR into main.
    3. Create the tag x.y.z on the resulting commit (the merge/squash commit).
    4. Push the tag (git push origin x.y.z) \u2014 Drone builds the release.

    Because the version bump is inside the tagged commit, the guard's tag == version check can only fail if the wrong commit was tagged.

    "},{"location":"11_versioning_and_changelog/#agent-assisted-tagging","title":"Agent-assisted tagging","text":"

    The agent neither authors nor merges the MR, and never tags before the merge. After the user confirms the MR is merged/squashed and says to proceed:

    1. Wait for that explicit go-ahead.
    2. Find the commit that introduced the version bump:
    3. packages: git log -S 'version = \"x.y.z\"' -n 1 --format='%H %s' -- pyproject.toml
    4. services: git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION
    5. Confirm that commit's version file equals x.y.z, then tag only that commit, lightweight and bare: git tag x.y.z <sha>.
    6. Do not push. Ask the user to push the tag: git push origin x.y.z.
    "},{"location":"11_versioning_and_changelog/#release-checklist","title":"Release checklist","text":"
    1. Confirm the quality gate is green and main is up to date.
    2. In the MR: move every [Unreleased] entry under the new version heading with the target date (## [x.y.z] - YYYY-MM-DD); restore an empty [Unreleased] on top.
    3. In the MR: add the two compare-link references at the bottom of the changelog, naming the version/tag (never a commit id).
    4. In the MR: set the version file \u2014 pyproject.toml (version = \"x.y.z\") or VERSION \u2014 to the intended release version.
    5. Merge or squash the MR into main.
    6. Create the tag on the resulting commit: lightweight git tag x.y.z.
    7. Push the tag (git push origin x.y.z). Watch Drone: Type A publishes the wheel/sdist, Type B builds and deploys the image; both first assert tag == version.
    8. Do not reuse the tag if the run fails \u2014 fix and cut x.y.(z+1).
    "},{"location":"11_versioning_and_changelog/#why-the-guard-matters","title":"Why the guard matters","text":"

    The version file and the tag are two facts that must agree; nothing in git enforces that by itself. A mismatch is not a theoretical risk \u2014 a package can be tagged 0.0.2 while its pyproject.toml still says 0.0.1, and the publish step (which compares the file against the index) then skips the build entirely, so 0.0.2 never reaches the index while looking like a release. The Drone guard turns that silent no-op into a hard failure.

    "},{"location":"11_versioning_and_changelog/#related","title":"Related","text":"
    • 10 \u2013 Drone Pipelines \u00b7 15 \u2013 Repository Inventory \u00b7 01 \u2013 Build Recipe \u00b7 13 \u2013 Library Registry
    "},{"location":"12_genericity_matrix/","title":"Genericity Matrix","text":""},{"location":"12_genericity_matrix/#summary","title":"Summary","text":"

    This page states precisely what is library-backed, what is template-provided, and what is app-specific and must be authored. Use it to scope a new build and to know, for any given capability, whether to call a library, copy template code, or write it yourself.

    "},{"location":"12_genericity_matrix/#tier-a-library-backed-use-never-reimplement","title":"Tier A \u2014 Library-backed (use; never reimplement)","text":"

    These capabilities already exist as internal libraries. Reach them through the library registry MCP (find_library(capability)) and read the library's own MCP for its API. Writing a private copy of any of these is a defect.

    Capability Library MCP Persistence: repositories, cache, populate, transactions Mongo Ops (mongo_ops) :8007 Dependency injection / composition Hexa (hexa) :8008 Deterministic multi-step transformation engine DAG Pipe (dagpipe) :8006 Spec-first HTTP edge, client, codegen OpenAPI First (openapi_first) :8004 Format-agnostic fetch + parse (HTML, PDF, CSV, XLSX) Omniread (omniread) :8003 Read-only email ingestion Mail Intake (mail_intake) :8002 JWT auth primitives (register, login, introspect) Py JWT (jwtlib) :8005 Documentation build (MkDocs + MCP) Doc Forge (docforge) :8001"},{"location":"12_genericity_matrix/#tier-b-template-provided-copy-from-templatesapp-then-adapt","title":"Tier B \u2014 Template-provided (copy from templates/app, then adapt)","text":"

    These are reusable internal components shipped inside the template \u2014 they are not independent libraries. Copy them as-is, then rename/populate only what is app-specific. They give every app the same wiring shape as the reference app. Fetch them by kind with get_app_component, or the whole tree with get_app_template.

    Component Template location Action Shipped Layering & dependency rule the package layout + import rules keep \u2705 Composition root shape init.py (get_svc/get_db, idempotency) keep \u2705 Spec-first web edge interfaces/openapi.py, thin handlers bound to operationId keep \u2705 CRUD slice pattern domain/<resource>/{models.py, ports/db.py, ports/service.py, converters.py} rename + fill \u2705 Generic CRUD service infra/adapters/service.py (CrudsServiceAdaptor) keep \u2705 Repository factory infra/db/repos/mongo.py (_repo_factory) keep \u2705 Worker poll + status loop worker.py keep \u2705 Progress bus infra/adapters/sse.py (keyed in-memory bus) + an app SSE endpoint keep \u2705 HTTP response cache infra/http_cache.py (cache_response + generation invalidation) keep \u2705 Key-value store infra/adapters/kv.py (port + in-memory + Redis adaptor) keep \u2705 Pipeline scaffold pipelines/shared/{ports,loader,registry}.py + pipelines/<family>/ rename + fill \u2705 Operator scripts scripts/ (init() / get_svc() / shutdown()) rename \u2705 Testing harness integration fakes + fixture-parity pattern keep \u2705 Project scaffolding pyproject.toml, Dockerfile, docker-compose.yaml, .env.example, openapi.yaml rename + fill \u2705"},{"location":"12_genericity_matrix/#tier-b-patterns-port-from-the-reference-app","title":"Tier B (patterns) \u2014 port from the reference app","text":"

    A few Tier B capabilities are real and reusable, but are shaped by the app or the provider, so the template does not ship them verbatim \u2014 copying them blindly would carry app-specific names. Treat them as patterns: lift the shape from the reference app and rename per app.

    Component Reference location Action Shipped Human-in-the-loop durable pause + question document + resolve endpoint + resume map port + reshape \u2717 LLM client pool provider-select + retry/rotation pool scaffold port + reshape \u2717"},{"location":"12_genericity_matrix/#tier-c-app-specific-must-be-authored","title":"Tier C \u2014 App-specific (must be authored)","text":"Artifact Why Resource models the business shape Repository populate/cache rules the relationships Service business logic domain behaviour Pipeline families the transformation graph Pattern/rule resources data-driven policy Fixtures & golden outputs test data"},{"location":"12_genericity_matrix/#the-two-axes","title":"The two axes","text":"

    Everything app-specific reduces to two axes:

    1. Resource model \u2014 the set of resources, their fields, relationships, and the OpenAPI contract.
    2. Pipeline family \u2014 only if inputs require multi-step transformation.

    If you can specify those two axes, the rest of the app follows mechanically: Tier A is imported, Tier B is copied, and Tier C is the only thing you author.

    "},{"location":"13_library_registry/","title":"Library Registry","text":""},{"location":"13_library_registry/#summary","title":"Summary","text":"

    The Aetos ecosystem provides internal libraries for the shared concerns of every application. Use them. Writing a private copy of any capability below is a defect.

    Each library also exposes its own documentation as an MCP server. An AI agent can read a library's full API by connecting to its MCP and reading docs://index, docs://nav, and docs://modules/{module}.

    "},{"location":"13_library_registry/#catalog","title":"Catalog","text":"Library Import Purpose Use instead of MCP DAG Pipe dagpipe Deterministic state-transformation DAG engine hand-rolled orchestration/topological ordering :8006 Hexa hexa Declarative DI / composition-root tooling manual wiring, hand-written factories :8008 Mongo Ops mongo_ops Async MongoDB repositories, cache, populate, transactions raw Motor CRUD and connection lifecycle :8007 Omniread omniread Format-agnostic fetch + parse (HTML, PDF, CSV, XLSX) custom scrapers/parsers :8003 OpenAPI First openapi_first Spec-first FastAPI bootstrap, client, codegen decorator routers and hand-written clients :8004 Mail Intake mail_intake Provider-agnostic read-only email ingestion Gmail OAuth + MIME parsing :8002 Py JWT jwtlib JWT auth primitives (register/login/introspect) password hashing + token code :8005 Doc Forge docforge Docstring compiler \u2192 MkDocs + MCP docs custom doc generators :8001 Auth Server (service) Central identity service (register/login/me/logout/introspect) building auth endpoints yourself spec: docs://spec"},{"location":"13_library_registry/#how-to-choose","title":"How to choose","text":"You need to\u2026 Use persist and query documents Mongo Ops compose dependencies Hexa run a multi-step transformation DAG Pipe read/parse an arbitrary input format Omniread expose a contract-first HTTP API OpenAPI First ingest email Mail Intake authenticate users / verify tokens Py JWT (+ Auth Server) generate documentation Doc Forge"},{"location":"13_library_registry/#discovery","title":"Discovery","text":"

    A single standards MCP exposes find_library(capability), which returns the matching library, its import name, its \"use instead of\" guidance, and its MCP endpoint (or, for the auth-server service, a spec pointer). It also serves the pinned auth-server OpenAPI contract at docs://spec. Query it before writing any infrastructure.

    "},{"location":"13_library_registry/#notes","title":"Notes","text":"
    • Hexa is a full library with its own MCP server on :8008: read docs://index, docs://nav, and docs://modules/{module} (e.g. docs://modules/hexa.container) to discover the DI surface \u2014 build(cls, *, instances, config) and the PortNode model.
    • Auth Server is a service, not an importable library: it has no MCP bundle by design. Read its client contract from the pinned OpenAPI document via docs://spec and wire it by declaring a bearerAuth security scheme in the app's own spec (see Auth Integration); py-jwt covers the low-level token path.
    • Library MCP servers expose documentation resources (not executable tools): they tell an agent the available API surface so it does not invent code.
    "},{"location":"14_auth_integration/","title":"Auth Integration","text":""},{"location":"14_auth_integration/#summary","title":"Summary","text":"

    Authentication is a service, not a library. Every Aetos application shares a single identity service \u2014 the auth-server \u2014 and consumes it through its HTTP contract. An app never implements registration, login, password hashing, or token issuance itself.

    The agent does not need an MCP bundle for the auth-server. It reads the pinned OpenAPI contract (below) and declares a bearer security scheme in its own spec; openapi_first then generates the verifying dependency. No auth code is written.

    "},{"location":"14_auth_integration/#read-the-contract","title":"Read the contract","text":"

    The auth-server OpenAPI document is pinned in the standards bundle and served as an MCP resource:

    docs://spec\n

    It is the authoritative client contract (OpenAPI 3.1). Read it to learn the endpoints and the request/response schemas:

    Endpoint Purpose POST /register Create a user (201, returns PublicUser) POST /login Authenticate and issue a JWT (LoginResponse) GET /me Current user's PublicUser (bearer required) POST /logout Stateless logout (LogoutResponse) POST /introspect Internal token introspection (active, user)

    The pinned snapshot is versioned (currently 0.0.5). If the caller has a live auth-server and needs the current contract, they can pass the full endpoint ({AUTH_SERVER}/openapi.json) and read it directly instead of the pin.

    "},{"location":"14_auth_integration/#wire-it-up-declare-dont-code","title":"Wire it up: declare, don't code","text":"

    Authentication is added by editing the app's own openapi.yaml \u2014 nothing else. Declare a global bearer requirement and point the scheme at the auth server (values come from the environment):

    security:\n  - bearerAuth: []\npaths:\n  # ...\ncomponents:\n  securitySchemes:\n    bearerAuth:\n      type: http\n      scheme: bearer\n      bearerFormat: JWT\n      x-server-url: \"{AUTH_SERVER}\"\n      x-introspect-path: \"/introspect\"\n      x-login-path: \"/login\"\n      x-register-path: \"/register\"\n      x-logout-path: \"/logout\"\n      x-me-path: \"/me\"\n

    openapi_first reads securitySchemes + security and generates a FastAPI dependency that extracts the bearer token, POSTs {\"token\": <jwt>} to {AUTH_SERVER}/introspect, and returns the user when active == true. It raises 401 on an invalid or inactive token and 503 when the auth server is unreachable. The generated handlers receive the authenticated user \u2014 you author no authentication code.

    "},{"location":"14_auth_integration/#public-operations","title":"Public operations","text":"

    A route that must stay open opts out by overriding security with an empty list:

    paths:\n  /health:\n    get:\n      operationId: health\n      security: []        # overrides the global requirement\n      responses:\n        \"200\":\n          description: OK\n
    "},{"location":"14_auth_integration/#environment","title":"Environment","text":"
    AUTH_SERVER=http://localhost:8000     # auth-server base URL\nJWT_SERVER=http://localhost:8000      # jwtlib client base URL (seeding/CLI)\n
    "},{"location":"14_auth_integration/#path-1-jwtlib-client-no-generator","title":"Path 1: jwtlib client (no generator)","text":"

    Apps that do not use a generated dependency verify requests with the py-jwt client:

    from jwtlib.introspection import authenticate_request\n\nauthorized = await authenticate_request(\n    should_skip_authentication,  # allow public paths\n    method,\n    path,\n    authorization_token,         # \"Bearer <jwt>\" or None\n)\n

    authenticate_request POSTs to {JWT_SERVER}/introspect (3 second timeout) and treats {\"active\": true, \"user\": {...}} as valid. Use this for seeding scripts and tests (jwtlib.register_user, jwtlib.login_user).

    "},{"location":"14_auth_integration/#golden-rules","title":"Golden rules","text":"
    1. Never trust an unverified token. Decode through the generated dependency or jwtlib before handling the request.
    2. Treat active: false as unauthenticated, even if the JWT decodes.
    3. Do not implement your own JWT parsing. Revocation and issuer changes must stay centralized in the auth-server.
    4. Do not add auth until the app's outcome is validated. Ship the app authless first; layer the security scheme once the core behaviour works.
    "},{"location":"14_auth_integration/#notes","title":"Notes","text":"
    • The default template is authless on purpose. Add the securitySchemes block above only when auth is required. Pull the shared slice with get_app_component(\"auth\").
    • The auth-server is deployed as a service (no importable package); the client surface is the spec, plus jwtlib for the low-level path.
    "},{"location":"15_repository_inventory/","title":"Repository Inventory","text":""},{"location":"15_repository_inventory/#summary","title":"Summary","text":"

    The canonical list of Aetos repositories covered by the CI and versioning standards, with the artifact each one produces, its version source, and its Drone shape. Every entry maps to the contract in 11 \u2013 Versioning & Changelog and the two CI files in 10 \u2013 Drone Pipelines.

    The same data is published machine-readably as the registry://repos MCP resource (and the list_repos tool), sourced from standards/src/repos.json. Paths are relative to the aetos/ workspace root.

    "},{"location":"15_repository_inventory/#packages-type-a","title":"Packages (Type A)","text":"

    A wheel + sdist published to the private index. Version source is pyproject.toml; Drone file is python-lib.yaml (tag-triggered).

    Repo Path Docs MCP server dagpipe dagpipe lib, wiki dagpipe:8006 doc-forge doc-forge lib, wiki docforge:8001 hexa hexa lib, wiki hexa:8008 mail-intake mail-intake lib, wiki mail_intake:8002 mongo-ops mongo-ops lib, wiki mongo_ops:8007 omniread omniread lib, wiki omniread:8003 openapi-first openapi-first lib, wiki openapi_first:8004 py-jwt py-jwt lib, wiki jwtlib:8005"},{"location":"15_repository_inventory/#services-sites-type-b","title":"Services & sites (Type B)","text":"

    A container image pushed to the registry and run on the Docker host. Version source is the VERSION file; Drone file is service-docker.yaml.

    Repo Type Path Trigger Docs auth-server service auth-server tag api, lib, wiki docs site docs push \u2014 mcp site mcp push \u2014

    The service variant is tag-triggered and enforces tag == VERSION. The site variant is push-triggered, ships :latest, and has no tag guard.

    "},{"location":"15_repository_inventory/#required-files-per-repo","title":"Required files per repo","text":"Type Version source Changelog Drone package pyproject.toml CHANGELOG.md python-lib.yaml service / site VERSION CHANGELOG.md service-docker.yaml

    Every covered repository must be able to satisfy tag == version: the version file (never a commit id) is bumped in the release MR, the MR is merged, and the tag is created on the merged commit.

    "},{"location":"15_repository_inventory/#reading-this-at-runtime","title":"Reading this at runtime","text":"
    • Resource: registry://repos
    • Tool: list_repos()
    • Humans: this page (mirror of standards/src/repos.json).
    "},{"location":"15_repository_inventory/#related","title":"Related","text":"
    • 10 \u2013 Drone Pipelines \u00b7 11 \u2013 Versioning & Changelog \u00b7 13 \u2013 Library Registry
    "}]} \ No newline at end of file diff --git a/standards/mcp/index.json b/standards/mcp/index.json index 5971c70..618c238 100644 --- a/standards/mcp/index.json +++ b/standards/mcp/index.json @@ -1,6 +1,6 @@ { "project": "standards", "type": "standards", - "modules_count": 15, + "modules_count": 16, "source": "hand-authored" } \ No newline at end of file diff --git a/standards/mcp/modules/index.json b/standards/mcp/modules/index.json index 4e1b85d..9b9e433 100644 --- a/standards/mcp/modules/index.json +++ b/standards/mcp/modules/index.json @@ -2,7 +2,7 @@ "module": "index", "content": { "path": "index", - "docstring": "# Standards Reference\n\nThe reference half of the Standards description: the enforceable rules,\npatterns, and the internal library catalog that agents consult while coding.\n\n- **Build Recipe** — the ordered, agentic checklist for a new app.\n- **Layering Rules** — the strict request → domain → repository layering and\n the rules that enforce it.\n- **Composition Root** — a single composition point wiring the whole app.\n- **Spec-First Routing** — the OpenAPI contract as the routing source of truth.\n- **CRUD Template** — the standardized generic resource endpoint scaffold.\n- **Pipeline Scaffold** — the deterministic pipeline skeleton for multi-stage\n jobs.\n- **Worker & Progress** — queued work, progress reporting, and visibility.\n- **Human-in-the-Loop** — guardrails and approvals inside automations.\n- **Infra Adapters** — how infrastructure connects without leaking into domain.\n- **Drone Pipelines** — the two CI shapes: a PyPI package or a Docker deployment.\n- **Versioning & Changelog** — SemVer, the tag↔version contract, and the release\n changelog.\n- **Genericity Matrix** — what is library-backed, template-provided, or authored.\n- **Auth Integration** — consuming the shared auth-server service (spec-driven,\n no auth code).\n- **Library Registry** — the catalog of internal libraries behind all of it.\n\nRead the **Wiki** for the philosophy and rationale; these pages are the\nreference that mirrors the `standards` MCP bundle.\n", + "docstring": "# Standards Reference\n\nThe reference half of the Standards description: the enforceable rules,\npatterns, and the internal library catalog that agents consult while coding.\n\n- **Build Recipe** — the ordered, agentic checklist for a new app.\n- **Layering Rules** — the strict request → domain → repository layering and\n the rules that enforce it.\n- **Composition Root** — a single composition point wiring the whole app.\n- **Spec-First Routing** — the OpenAPI contract as the routing source of truth.\n- **CRUD Template** — the standardized generic resource endpoint scaffold.\n- **Pipeline Scaffold** — the deterministic pipeline skeleton for multi-stage\n jobs.\n- **Worker & Progress** — queued work, progress reporting, and visibility.\n- **Human-in-the-Loop** — guardrails and approvals inside automations.\n- **Infra Adapters** — how infrastructure connects without leaking into domain.\n- **Drone Pipelines** — the two CI shapes: a PyPI package or a Docker deployment.\n- **Versioning & Changelog** — SemVer, the tag↔version contract, and the release\n changelog.\n- **Repository Inventory** — every covered repo, its type, version source, and\n Drone shape.\n- **Genericity Matrix** — what is library-backed, template-provided, or authored.\n- **Auth Integration** — consuming the shared auth-server service (spec-driven,\n no auth code).\n- **Library Registry** — the catalog of internal libraries behind all of it.\n\nRead the **Wiki** for the philosophy and rationale; these pages are the\nreference that mirrors the `standards` MCP bundle.\n", "objects": {} } } \ No newline at end of file diff --git a/standards/mcp/modules/repository_inventory.json b/standards/mcp/modules/repository_inventory.json new file mode 100644 index 0000000..8a61185 --- /dev/null +++ b/standards/mcp/modules/repository_inventory.json @@ -0,0 +1,8 @@ +{ + "module": "repository_inventory", + "content": { + "path": "repository_inventory", + "docstring": "# Repository Inventory\n\n## Summary\n\nThe canonical list of Aetos repositories covered by the CI and versioning\nstandards, with the artifact each one produces, its version source, and its\nDrone shape. Every entry maps to the contract in\n[11 – Versioning & Changelog](11_versioning_and_changelog.md) and the two CI\nfiles in [10 – Drone Pipelines](10_drone_pipelines.md).\n\nThe same data is published machine-readably as the `registry://repos` MCP\nresource (and the `list_repos` tool), sourced from `standards/src/repos.json`.\nPaths are relative to the `aetos/` workspace root.\n\n---\n\n## Packages (Type A)\n\nA wheel + sdist published to the private index. Version source is\n`pyproject.toml`; Drone file is `python-lib.yaml` (tag-triggered).\n\n| Repo | Path | Docs | MCP server |\n|------|------|------|------------|\n| `dagpipe` | `dagpipe` | lib, wiki | `dagpipe:8006` |\n| `doc-forge` | `doc-forge` | lib, wiki | `docforge:8001` |\n| `hexa` | `hexa` | lib, wiki | `hexa:8008` |\n| `mail-intake` | `mail-intake` | lib, wiki | `mail_intake:8002` |\n| `mongo-ops` | `mongo-ops` | lib, wiki | `mongo_ops:8007` |\n| `omniread` | `omniread` | lib, wiki | `omniread:8003` |\n| `openapi-first` | `openapi-first` | lib, wiki | `openapi_first:8004` |\n| `py-jwt` | `py-jwt` | lib, wiki | `jwtlib:8005` |\n\n---\n\n## Services & sites (Type B)\n\nA container image pushed to the registry and run on the Docker host. Version\nsource is the `VERSION` file; Drone file is `service-docker.yaml`.\n\n| Repo | Type | Path | Trigger | Docs |\n|------|------|------|---------|------|\n| `auth-server` | service | `auth-server` | tag | api, lib, wiki |\n| `docs` | site | `docs` | push | — |\n| `mcp` | site | `mcp` | push | — |\n\nThe **service** variant is tag-triggered and enforces `tag == VERSION`. The\n**site** variant is push-triggered, ships `:latest`, and has no tag guard.\n\n---\n\n## Required files per repo\n\n| Type | Version source | Changelog | Drone |\n|------|----------------|-----------|-------|\n| package | `pyproject.toml` | `CHANGELOG.md` | `python-lib.yaml` |\n| service / site | `VERSION` | `CHANGELOG.md` | `service-docker.yaml` |\n\nEvery covered repository must be able to satisfy `tag == version`:\nthe version file (never a commit id) is bumped in the release MR, the MR is\nmerged, and the tag is created on the merged commit.\n\n---\n\n## Reading this at runtime\n\n- Resource: `registry://repos`\n- Tool: `list_repos()`\n- Humans: this page (mirror of `standards/src/repos.json`).\n\n---\n\n## Related\n\n- [10 – Drone Pipelines](10_drone_pipelines.md) · [11 – Versioning & Changelog](11_versioning_and_changelog.md) · [13 – Library Registry](13_library_registry.md)\n", + "objects": {} + } +} \ No newline at end of file diff --git a/standards/mcp/modules/versioning_and_changelog.json b/standards/mcp/modules/versioning_and_changelog.json index 8541d00..8a9d33b 100644 --- a/standards/mcp/modules/versioning_and_changelog.json +++ b/standards/mcp/modules/versioning_and_changelog.json @@ -2,7 +2,7 @@ "module": "versioning_and_changelog", "content": { "path": "versioning_and_changelog", - "docstring": "# Versioning & Changelog\n\n## Summary\n\nEvery Aetos artifact — library, service, or site — is versioned with\n[Semantic Versioning](https://semver.org/spec/v2.0.0.html) and documents its\nreleases in a [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) file.\nThe **version file is the source of truth**, the **git tag must equal it**, and\na Drone guard enforces that equality before anything is published. Releases are\ncut manually; a tag is what triggers the pipeline.\n\nThis page pairs with [10 – Drone Pipelines](10_drone_pipelines.md): the version\nand tag contract is exactly what those two CI shapes consume.\n\n---\n\n## The version contract\n\n| Artifact | Source of truth | Notes |\n|----------|-----------------|-------|\n| Library (PyPI package) | `version` in `pyproject.toml` | `check-version` also reads it to skip duplicates |\n| Service / site (Docker) | `VERSION` file at the repo root | one line, `x.y.z` |\n\nRules:\n\n1. **One version per repository.** No per-module versions.\n2. **Tag = version.** The git tag is bare SemVer (`0.0.6`), no `v` prefix, and\n it MUST match the version file byte-for-byte. The Drone guard fails the\n build otherwise — this is what stops a tag from silently publishing nothing.\n3. **A release is a tag.** Bump the version file, promote the changelog, commit,\n tag, push. Everything else is automated by Drone.\n4. **Never reuse a tag.** If a release is wrong, cut a new patch version.\n\n### Pre-1.0 (0.y.z)\n\nWhile a package is `0.y.z`, **`0.y` is treated as the major line**:\n\n- breaking change → `0.(y+1).0`\n- new feature → `0.y.(z+1)`\n- bug fix → `0.y.(z+1)`\n\nOnce a package reaches `1.0.0`, normal SemVer applies. Do not ship `1.0.0`\nuntil the public API is considered stable.\n\n---\n\n## The changelog\n\n`CHANGELOG.md` at the repo root, in Keep a Changelog form. It always has exactly\none open `[Unreleased]` section with the change categories that apply:\n\n```markdown\n## [Unreleased]\n\n### Added\n### Changed\n### Deprecated\n### Removed\n### Fixed\n### Security\n```\n\nOn release you **promote** it — never delete history:\n\n```markdown\n## [0.0.6] - 2026-03-07\n\n### Added\n- ...\n```\n\nand add a link reference at the bottom:\n\n```markdown\n[Unreleased]: https://git.aetoskia.com/aetos//compare/0.0.6...HEAD\n[0.0.6]: https://git.aetoskia.com/aetos//compare/0.0.5...0.0.6\n```\n\nConventions:\n\n- Write entries for humans: one line each, imperative, referencing the user\n impact, not the commit hash.\n- Categories: **Added**, **Changed**, **Deprecated**, **Removed**, **Fixed**,\n **Security**. Omit empty categories.\n- Security fixes get their own entry even if the change is otherwise a bug fix.\n- The `[Unreleased]` heading is never renamed; copy its content into the new\n version heading and clear it.\n\n---\n\n## Release checklist\n\n1. Confirm the quality gate is green on `main`.\n2. Move every `[Unreleased]` entry under the new version heading with today's\n date (`## [x.y.z] - YYYY-MM-DD`); restore an empty `[Unreleased]` on top.\n3. Add the two compare-link references at the bottom of the changelog.\n4. Set the version file: `pyproject.toml` (`version = \"x.y.z\"`) or `VERSION`.\n5. Commit: `chore(release): x.y.z`.\n6. Tag: `git tag x.y.z` and push the tag (`git push origin x.y.z`).\n7. Watch Drone: Type A publishes the wheel/sdist, Type B builds and deploys the\n image. Both first assert `tag == version`.\n8. Do not reuse the tag if the run fails — fix and cut `x.y.(z+1)`.\n\n---\n\n## Why the guard matters\n\nThe version file and the tag are two facts that must agree; nothing in git\nenforces that by itself. A mismatch is not a theoretical risk — a package can be\ntagged `0.0.2` while its `pyproject.toml` still says `0.0.1`, and the publish\nstep (which compares the **file** against the index) then skips the build\nentirely, so `0.0.2` never reaches the index while looking like a release. The\nDrone guard turns that silent no-op into a hard failure.\n\n---\n\n## Related\n\n- [10 – Drone Pipelines](10_drone_pipelines.md) · [01 – Build Recipe](01_build_recipe.md) · [13 – Library Registry](13_library_registry.md)\n", + "docstring": "# Versioning & Changelog\n\n## Summary\n\nEvery Aetos artifact — library, service, or site — is versioned with\n[Semantic Versioning](https://semver.org/spec/v2.0.0.html) and documents its\nreleases in a [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) file.\nThe **version file is the source of truth**, the **git tag must equal it**, and\na Drone guard enforces that equality before anything is published. Releases are\ncut manually; a tag is what triggers the pipeline.\n\nThis page pairs with [10 – Drone Pipelines](10_drone_pipelines.md): the version\nand tag contract is exactly what those two CI shapes consume.\n\n---\n\n## The version contract\n\n| Artifact | Source of truth | Notes |\n|----------|-----------------|-------|\n| Library (PyPI package) | `version` in `pyproject.toml` | `check-version` also reads it to skip duplicates |\n| Service / site (Docker) | `VERSION` file at the repo root | one line, `x.y.z` |\n\nRules:\n\n1. **One version per repository.** No per-module versions.\n2. **Tag = version.** The git tag is bare SemVer (`0.0.6`), no `v` prefix, and\n it MUST match the version file byte-for-byte. The Drone guard fails the\n build otherwise — this is what stops a tag from silently publishing nothing.\n3. **A release is a tag, created after the change is merged.** The version bump\n and the changelog promotion travel inside the merge request (MR); the tag is\n added on the merged commit and pushed. See [Tagging strategy](#tagging-strategy-mr-based).\n4. **Never reuse a tag.** If a release is wrong, cut a new patch version.\n\n### Pre-1.0 (0.y.z)\n\nWhile a package is `0.y.z`, **`0.y` is treated as the major line**:\n\n- breaking change → `0.(y+1).0`\n- new feature → `0.y.(z+1)`\n- bug fix → `0.y.(z+1)`\n\nOnce a package reaches `1.0.0`, normal SemVer applies. Do not ship `1.0.0`\nuntil the public API is considered stable.\n\n---\n\n## The changelog\n\n`CHANGELOG.md` at the repo root, in Keep a Changelog form. It always has exactly\none open `[Unreleased]` section with the change categories that apply:\n\n```markdown\n## [Unreleased]\n\n### Added\n### Changed\n### Deprecated\n### Removed\n### Fixed\n### Security\n```\n\nOn release you **promote** it — never delete history:\n\n```markdown\n## [0.0.6] - 2026-03-07\n\n### Added\n- ...\n```\n\nand add a link reference at the bottom:\n\n```markdown\n[Unreleased]: https://git.aetoskia.com/aetos//compare/0.0.6...HEAD\n[0.0.6]: https://git.aetoskia.com/aetos//compare/0.0.5...0.0.6\n```\n\nConventions:\n\n- Write entries for humans: one line each, imperative, referencing the user\n impact, not the commit hash.\n- Categories: **Added**, **Changed**, **Deprecated**, **Removed**, **Fixed**,\n **Security**. Omit empty categories.\n- Security fixes get their own entry even if the change is otherwise a bug fix.\n- The `[Unreleased]` heading is never renamed; copy its content into the new\n version heading and clear it.\n\n---\n\n## Tagging strategy (MR-based)\n\nThe release version is known while the change is still a merge request, so the\nbump travels with the change and only the tag is added afterwards:\n\n1. **In the MR** — set the intended release version: `version` in\n `pyproject.toml` (or the `VERSION` file) to `x.y.z`, and promote the\n changelog (below). Changelog entries and link references name the\n **version/tag**, never a commit id.\n2. **Merge or squash** the MR into `main`.\n3. **Create the tag** `x.y.z` on the resulting commit (the merge/squash commit).\n4. **Push the tag** (`git push origin x.y.z`) — Drone builds the release.\n\nBecause the version bump is inside the tagged commit, the guard's\n`tag == version` check can only fail if the wrong commit was tagged.\n\n### Agent-assisted tagging\n\nThe agent neither authors nor merges the MR, and never tags before the merge.\nAfter the user confirms the MR is merged/squashed and says to proceed:\n\n1. **Wait** for that explicit go-ahead.\n2. Find the commit that introduced the version bump:\n - packages:\n `git log -S 'version = \"x.y.z\"' -n 1 --format='%H %s' -- pyproject.toml`\n - services:\n `git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION`\n3. Confirm that commit's version file equals `x.y.z`, then tag **only** that\n commit, lightweight and bare: `git tag x.y.z `.\n4. **Do not push.** Ask the user to push the tag: `git push origin x.y.z`.\n\n---\n\n## Release checklist\n\n1. Confirm the quality gate is green and `main` is up to date.\n2. In the MR: move every `[Unreleased]` entry under the new version heading with\n the target date (`## [x.y.z] - YYYY-MM-DD`); restore an empty `[Unreleased]`\n on top.\n3. In the MR: add the two compare-link references at the bottom of the\n changelog, naming the version/tag (never a commit id).\n4. In the MR: set the version file — `pyproject.toml` (`version = \"x.y.z\"`) or\n `VERSION` — to the intended release version.\n5. Merge or squash the MR into `main`.\n6. Create the tag on the resulting commit: lightweight `git tag x.y.z`.\n7. Push the tag (`git push origin x.y.z`). Watch Drone: Type A publishes the\n wheel/sdist, Type B builds and deploys the image; both first assert\n `tag == version`.\n8. Do not reuse the tag if the run fails — fix and cut `x.y.(z+1)`.\n\n---\n\n## Why the guard matters\n\nThe version file and the tag are two facts that must agree; nothing in git\nenforces that by itself. A mismatch is not a theoretical risk — a package can be\ntagged `0.0.2` while its `pyproject.toml` still says `0.0.1`, and the publish\nstep (which compares the **file** against the index) then skips the build\nentirely, so `0.0.2` never reaches the index while looking like a release. The\nDrone guard turns that silent no-op into a hard failure.\n\n---\n\n## Related\n\n- [10 – Drone Pipelines](10_drone_pipelines.md) · [15 – Repository Inventory](15_repository_inventory.md) · [01 – Build Recipe](01_build_recipe.md) · [13 – Library Registry](13_library_registry.md)\n", "objects": {} } } \ No newline at end of file diff --git a/standards/mcp/nav.json b/standards/mcp/nav.json index b0cbab2..93f45de 100644 --- a/standards/mcp/nav.json +++ b/standards/mcp/nav.json @@ -69,6 +69,11 @@ "resource": "docs://modules/auth_integration", "title": "Auth Integration" }, + { + "module": "repository_inventory", + "resource": "docs://modules/repository_inventory", + "title": "Repository Inventory" + }, { "module": "index", "resource": "docs://modules/index", diff --git a/standards/mcp/repos.json b/standards/mcp/repos.json new file mode 100644 index 0000000..935474d --- /dev/null +++ b/standards/mcp/repos.json @@ -0,0 +1,169 @@ +{ + "project": "standards", + "note": "Machine-readable repository inventory. Mirrors standards/src/lib/15_repository_inventory.md. Read it with the registry://repos resource or the list_repos tool.", + "path_convention": "relative to the aetos/ workspace root", + "repos": [ + { + "name": "dagpipe", + "type": "package", + "path": "dagpipe", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "dagpipe", + "port": 8006 + } + }, + { + "name": "doc-forge", + "type": "package", + "path": "doc-forge", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "docforge", + "port": 8001 + } + }, + { + "name": "hexa", + "type": "package", + "path": "hexa", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "hexa", + "port": 8008 + } + }, + { + "name": "mail-intake", + "type": "package", + "path": "mail-intake", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "mail_intake", + "port": 8002 + } + }, + { + "name": "mongo-ops", + "type": "package", + "path": "mongo-ops", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "mongo_ops", + "port": 8007 + } + }, + { + "name": "omniread", + "type": "package", + "path": "omniread", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "omniread", + "port": 8003 + } + }, + { + "name": "openapi-first", + "type": "package", + "path": "openapi-first", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "openapi_first", + "port": 8004 + } + }, + { + "name": "py-jwt", + "type": "package", + "path": "py-jwt", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": [ + "lib", + "wiki" + ], + "mcp": { + "server": "jwtlib", + "port": 8005 + } + }, + { + "name": "auth-server", + "type": "service", + "path": "auth-server", + "version_source": "VERSION", + "drone": "service-docker.yaml", + "trigger": "tag", + "docs": [ + "api", + "lib", + "wiki" + ], + "mcp": null + }, + { + "name": "docs", + "type": "site", + "path": "docs", + "version_source": "VERSION", + "drone": "service-docker.yaml", + "trigger": "push", + "docs": [], + "mcp": null + }, + { + "name": "mcp", + "type": "site", + "path": "mcp", + "version_source": "VERSION", + "drone": "service-docker.yaml", + "trigger": "push", + "docs": [], + "mcp": null + } + ] +} \ No newline at end of file diff --git a/standards/mcp/templates/release/CHANGELOG.md b/standards/mcp/templates/release/CHANGELOG.md index b778577..7d22bd6 100644 --- a/standards/mcp/templates/release/CHANGELOG.md +++ b/standards/mcp/templates/release/CHANGELOG.md @@ -20,16 +20,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security [Unreleased]: /compare/0.1.0...HEAD diff --git a/standards/src/lib/11_versioning_and_changelog.md b/standards/src/lib/11_versioning_and_changelog.md index fb36204..8654ea3 100644 --- a/standards/src/lib/11_versioning_and_changelog.md +++ b/standards/src/lib/11_versioning_and_changelog.md @@ -27,8 +27,9 @@ Rules: 2. **Tag = version.** The git tag is bare SemVer (`0.0.6`), no `v` prefix, and it MUST match the version file byte-for-byte. The Drone guard fails the build otherwise — this is what stops a tag from silently publishing nothing. -3. **A release is a tag.** Bump the version file, promote the changelog, commit, - tag, push. Everything else is automated by Drone. +3. **A release is a tag, created after the change is merged.** The version bump + and the changelog promotion travel inside the merge request (MR); the tag is + added on the merged commit and pushed. See [Tagging strategy](#tagging-strategy-mr-based). 4. **Never reuse a tag.** If a release is wrong, cut a new patch version. ### Pre-1.0 (0.y.z) @@ -88,17 +89,54 @@ Conventions: --- +## Tagging strategy (MR-based) + +The release version is known while the change is still a merge request, so the +bump travels with the change and only the tag is added afterwards: + +1. **In the MR** — set the intended release version: `version` in + `pyproject.toml` (or the `VERSION` file) to `x.y.z`, and promote the + changelog (below). Changelog entries and link references name the + **version/tag**, never a commit id. +2. **Merge or squash** the MR into `main`. +3. **Create the tag** `x.y.z` on the resulting commit (the merge/squash commit). +4. **Push the tag** (`git push origin x.y.z`) — Drone builds the release. + +Because the version bump is inside the tagged commit, the guard's +`tag == version` check can only fail if the wrong commit was tagged. + +### Agent-assisted tagging + +The agent neither authors nor merges the MR, and never tags before the merge. +After the user confirms the MR is merged/squashed and says to proceed: + +1. **Wait** for that explicit go-ahead. +2. Find the commit that introduced the version bump: + - packages: + `git log -S 'version = "x.y.z"' -n 1 --format='%H %s' -- pyproject.toml` + - services: + `git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION` +3. Confirm that commit's version file equals `x.y.z`, then tag **only** that + commit, lightweight and bare: `git tag x.y.z `. +4. **Do not push.** Ask the user to push the tag: `git push origin x.y.z`. + +--- + ## Release checklist -1. Confirm the quality gate is green on `main`. -2. Move every `[Unreleased]` entry under the new version heading with today's - date (`## [x.y.z] - YYYY-MM-DD`); restore an empty `[Unreleased]` on top. -3. Add the two compare-link references at the bottom of the changelog. -4. Set the version file: `pyproject.toml` (`version = "x.y.z"`) or `VERSION`. -5. Commit: `chore(release): x.y.z`. -6. Tag: `git tag x.y.z` and push the tag (`git push origin x.y.z`). -7. Watch Drone: Type A publishes the wheel/sdist, Type B builds and deploys the - image. Both first assert `tag == version`. +1. Confirm the quality gate is green and `main` is up to date. +2. In the MR: move every `[Unreleased]` entry under the new version heading with + the target date (`## [x.y.z] - YYYY-MM-DD`); restore an empty `[Unreleased]` + on top. +3. In the MR: add the two compare-link references at the bottom of the + changelog, naming the version/tag (never a commit id). +4. In the MR: set the version file — `pyproject.toml` (`version = "x.y.z"`) or + `VERSION` — to the intended release version. +5. Merge or squash the MR into `main`. +6. Create the tag on the resulting commit: lightweight `git tag x.y.z`. +7. Push the tag (`git push origin x.y.z`). Watch Drone: Type A publishes the + wheel/sdist, Type B builds and deploys the image; both first assert + `tag == version`. 8. Do not reuse the tag if the run fails — fix and cut `x.y.(z+1)`. --- @@ -116,4 +154,4 @@ Drone guard turns that silent no-op into a hard failure. ## Related -- [10 – Drone Pipelines](10_drone_pipelines.md) · [01 – Build Recipe](01_build_recipe.md) · [13 – Library Registry](13_library_registry.md) +- [10 – Drone Pipelines](10_drone_pipelines.md) · [15 – Repository Inventory](15_repository_inventory.md) · [01 – Build Recipe](01_build_recipe.md) · [13 – Library Registry](13_library_registry.md) diff --git a/standards/src/lib/15_repository_inventory.md b/standards/src/lib/15_repository_inventory.md new file mode 100644 index 0000000..e580c91 --- /dev/null +++ b/standards/src/lib/15_repository_inventory.md @@ -0,0 +1,74 @@ +# Repository Inventory + +## Summary + +The canonical list of Aetos repositories covered by the CI and versioning +standards, with the artifact each one produces, its version source, and its +Drone shape. Every entry maps to the contract in +[11 – Versioning & Changelog](11_versioning_and_changelog.md) and the two CI +files in [10 – Drone Pipelines](10_drone_pipelines.md). + +The same data is published machine-readably as the `registry://repos` MCP +resource (and the `list_repos` tool), sourced from `standards/src/repos.json`. +Paths are relative to the `aetos/` workspace root. + +--- + +## Packages (Type A) + +A wheel + sdist published to the private index. Version source is +`pyproject.toml`; Drone file is `python-lib.yaml` (tag-triggered). + +| Repo | Path | Docs | MCP server | +|------|------|------|------------| +| `dagpipe` | `dagpipe` | lib, wiki | `dagpipe:8006` | +| `doc-forge` | `doc-forge` | lib, wiki | `docforge:8001` | +| `hexa` | `hexa` | lib, wiki | `hexa:8008` | +| `mail-intake` | `mail-intake` | lib, wiki | `mail_intake:8002` | +| `mongo-ops` | `mongo-ops` | lib, wiki | `mongo_ops:8007` | +| `omniread` | `omniread` | lib, wiki | `omniread:8003` | +| `openapi-first` | `openapi-first` | lib, wiki | `openapi_first:8004` | +| `py-jwt` | `py-jwt` | lib, wiki | `jwtlib:8005` | + +--- + +## Services & sites (Type B) + +A container image pushed to the registry and run on the Docker host. Version +source is the `VERSION` file; Drone file is `service-docker.yaml`. + +| Repo | Type | Path | Trigger | Docs | +|------|------|------|---------|------| +| `auth-server` | service | `auth-server` | tag | api, lib, wiki | +| `docs` | site | `docs` | push | — | +| `mcp` | site | `mcp` | push | — | + +The **service** variant is tag-triggered and enforces `tag == VERSION`. The +**site** variant is push-triggered, ships `:latest`, and has no tag guard. + +--- + +## Required files per repo + +| Type | Version source | Changelog | Drone | +|------|----------------|-----------|-------| +| package | `pyproject.toml` | `CHANGELOG.md` | `python-lib.yaml` | +| service / site | `VERSION` | `CHANGELOG.md` | `service-docker.yaml` | + +Every covered repository must be able to satisfy `tag == version`: +the version file (never a commit id) is bumped in the release MR, the MR is +merged, and the tag is created on the merged commit. + +--- + +## Reading this at runtime + +- Resource: `registry://repos` +- Tool: `list_repos()` +- Humans: this page (mirror of `standards/src/repos.json`). + +--- + +## Related + +- [10 – Drone Pipelines](10_drone_pipelines.md) · [11 – Versioning & Changelog](11_versioning_and_changelog.md) · [13 – Library Registry](13_library_registry.md) diff --git a/standards/src/lib/index.md b/standards/src/lib/index.md index 9817442..9631f7e 100644 --- a/standards/src/lib/index.md +++ b/standards/src/lib/index.md @@ -17,6 +17,8 @@ patterns, and the internal library catalog that agents consult while coding. - **Drone Pipelines** — the two CI shapes: a PyPI package or a Docker deployment. - **Versioning & Changelog** — SemVer, the tag↔version contract, and the release changelog. +- **Repository Inventory** — every covered repo, its type, version source, and + Drone shape. - **Genericity Matrix** — what is library-backed, template-provided, or authored. - **Auth Integration** — consuming the shared auth-server service (spec-driven, no auth code). diff --git a/standards/src/mkdocs.lib.yml b/standards/src/mkdocs.lib.yml index 0ab9c73..042bd86 100644 --- a/standards/src/mkdocs.lib.yml +++ b/standards/src/mkdocs.lib.yml @@ -65,6 +65,7 @@ nav: - Infra Adapters: 09_infra_adaptors.md - Drone Pipelines: 10_drone_pipelines.md - Versioning & Changelog: 11_versioning_and_changelog.md + - Repository Inventory: 15_repository_inventory.md - Genericity Matrix: 12_genericity_matrix.md - Auth Integration: 14_auth_integration.md - Library Registry: 13_library_registry.md \ No newline at end of file diff --git a/standards/src/repos.json b/standards/src/repos.json new file mode 100644 index 0000000..029f817 --- /dev/null +++ b/standards/src/repos.json @@ -0,0 +1,117 @@ +{ + "project": "standards", + "note": "Machine-readable repository inventory. Mirrors standards/src/lib/15_repository_inventory.md. Read it with the registry://repos resource or the list_repos tool.", + "path_convention": "relative to the aetos/ workspace root", + "repos": [ + { + "name": "dagpipe", + "type": "package", + "path": "dagpipe", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "dagpipe", "port": 8006 } + }, + { + "name": "doc-forge", + "type": "package", + "path": "doc-forge", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "docforge", "port": 8001 } + }, + { + "name": "hexa", + "type": "package", + "path": "hexa", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "hexa", "port": 8008 } + }, + { + "name": "mail-intake", + "type": "package", + "path": "mail-intake", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "mail_intake", "port": 8002 } + }, + { + "name": "mongo-ops", + "type": "package", + "path": "mongo-ops", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "mongo_ops", "port": 8007 } + }, + { + "name": "omniread", + "type": "package", + "path": "omniread", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "omniread", "port": 8003 } + }, + { + "name": "openapi-first", + "type": "package", + "path": "openapi-first", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "openapi_first", "port": 8004 } + }, + { + "name": "py-jwt", + "type": "package", + "path": "py-jwt", + "version_source": "pyproject.toml", + "drone": "python-lib.yaml", + "trigger": "tag", + "docs": ["lib", "wiki"], + "mcp": { "server": "jwtlib", "port": 8005 } + }, + { + "name": "auth-server", + "type": "service", + "path": "auth-server", + "version_source": "VERSION", + "drone": "service-docker.yaml", + "trigger": "tag", + "docs": ["api", "lib", "wiki"], + "mcp": null + }, + { + "name": "docs", + "type": "site", + "path": "docs", + "version_source": "VERSION", + "drone": "service-docker.yaml", + "trigger": "push", + "docs": [], + "mcp": null + }, + { + "name": "mcp", + "type": "site", + "path": "mcp", + "version_source": "VERSION", + "drone": "service-docker.yaml", + "trigger": "push", + "docs": [], + "mcp": null + } + ] +} diff --git a/standards/src/templates/release/CHANGELOG.md b/standards/src/templates/release/CHANGELOG.md index b778577..7d22bd6 100644 --- a/standards/src/templates/release/CHANGELOG.md +++ b/standards/src/templates/release/CHANGELOG.md @@ -20,16 +20,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security [Unreleased]: /compare/0.1.0...HEAD diff --git a/standards/src/wiki/04_development/02_releasing.md b/standards/src/wiki/04_development/02_releasing.md index 839d4cf..4a6cd5f 100644 --- a/standards/src/wiki/04_development/02_releasing.md +++ b/standards/src/wiki/04_development/02_releasing.md @@ -5,14 +5,16 @@ page [Versioning & Changelog](../lib/11_versioning_and_changelog/); this is the runbook you follow. Every repository is one of two Drone shapes — a **PyPI package** or a **Docker -deployment** ([Drone Pipelines](../lib/10_drone_pipelines/)). Both are -released the same way: bump the version file, promote the changelog, tag. +deployment** ([Drone Pipelines](../lib/10_drone_pipelines/)). Both release the +same way: the version bump and changelog promotion go **in the merge request**, +and the tag is created on the merged commit. --- ## 🧾 Before you start -- `main` is green (the Drone quality gate passed on the last run). +- You have an open **merge request** holding the change, and `main` is green + (the Drone quality gate passed on the last run). - You know whether this is a **breaking**, **feature**, or **fix** release. - The version file exists: - package → `version` in `pyproject.toml` @@ -33,36 +35,46 @@ line (see the reference page); once at `1.0.0`, normal SemVer applies. --- -## ✍️ Promote the changelog +## 🌿 Release in the MR -In `CHANGELOG.md`: +The version is known while the change is still a merge request, so the bump +rides along with it. Do both edits **in the MR**: -1. Rename the content under `[Unreleased]` into a new - `## [x.y.z] - YYYY-MM-DD` heading (keep the sections that apply). -2. Leave a fresh, empty `## [Unreleased]` on top. -3. Add the compare links at the bottom: +- **Promote the changelog** in `CHANGELOG.md`: move the `[Unreleased]` content + under a new `## [x.y.z] - YYYY-MM-DD` heading, leave a fresh empty + `[Unreleased]` on top, and add the compare links — naming the **version/tag**, + never a commit id: - ```markdown - [Unreleased]: https://git.aetoskia.com/aetos//compare/x.y.z...HEAD - [x.y.z]: https://git.aetoskia.com/aetos//compare/x.y.(z-1)...x.y.z - ``` + ```markdown + [Unreleased]: https://git.aetoskia.com/aetos//compare/x.y.z...HEAD + [x.y.z]: https://git.aetoskia.com/aetos//compare/x.y.(z-1)...x.y.z + ``` + +- **Bump the version file** to the intended release version: `version = "x.y.z"` + in `pyproject.toml` (packages) or the `VERSION` file (services/sites). --- -## 🔢 Bump the version file +## 🏷️ Tag the merged commit -- **Package:** edit `version = "x.y.z"` in `pyproject.toml`. -- **Service / site:** edit the `VERSION` file. +1. **Merge or squash** the MR into `main`. +2. **Create the tag** on the resulting commit: `git tag x.y.z` (lightweight). +3. **Push the tag** (`git push origin x.y.z`) — Drone builds the release. -Then commit and tag: +### 🤖 Agent-assisted tagging -```bash -git add CHANGELOG.md pyproject.toml # or VERSION -git commit -m "chore(release): x.y.z" -git tag x.y.z -git push origin HEAD -git push origin x.y.z -``` +The agent does not author or merge the MR and never tags before the merge. After +you confirm the MR is merged/squashed and tell it to proceed, the agent: + +1. Waits for that explicit go-ahead. +2. Finds the commit that introduced the bump: + - package: + `git log -S 'version = "x.y.z"' -n 1 --format='%H %s' -- pyproject.toml` + - service / site: + `git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION` +3. Verifies that commit's version file equals `x.y.z`, then tags **only** that + commit: `git tag x.y.z `. +4. Does **not** push — it asks you to run `git push origin x.y.z`. --- diff --git a/standards/wiki/04_development/02_releasing/index.html b/standards/wiki/04_development/02_releasing/index.html index 7d210a2..2c69329 100644 --- a/standards/wiki/04_development/02_releasing/index.html +++ b/standards/wiki/04_development/02_releasing/index.html @@ -528,21 +528,36 @@
  • - + - ✍️ Promote the changelog + 🌿 Release in the MR
  • - + - 🔢 Bump the version file + 🏷️ Tag the merged commit + +
  • @@ -610,12 +625,14 @@ page Versioning & Changelog; this is the runbook you follow.

    Every repository is one of two Drone shapes — a PyPI package or a Docker -deployment (Drone Pipelines). Both are -released the same way: bump the version file, promote the changelog, tag.

    +deployment (Drone Pipelines). Both release the +same way: the version bump and changelog promotion go in the merge request, +and the tag is created on the merged commit.


    🧾 Before you start

      -
    • main is green (the Drone quality gate passed on the last run).
    • +
    • You have an open merge request holding the change, and main is green + (the Drone quality gate passed on the last run).
    • You know whether this is a breaking, feature, or fix release.
    • The version file exists:
    • package → version in pyproject.toml
    • @@ -652,35 +669,44 @@ line (see the reference page); once at 1.0.0, normal SemVer applies
      -

      ✍️ Promote the changelog

      -

      In CHANGELOG.md:

      -
        -
      1. Rename the content under [Unreleased] into a new - ## [x.y.z] - YYYY-MM-DD heading (keep the sections that apply).
      2. -
      3. Leave a fresh, empty ## [Unreleased] on top.
      4. -
      5. Add the compare links at the bottom:
      6. -
      +

      🌿 Release in the MR

      +

      The version is known while the change is still a merge request, so the bump +rides along with it. Do both edits in the MR:

      +
        +
      • Promote the changelog in CHANGELOG.md: move the [Unreleased] content + under a new ## [x.y.z] - YYYY-MM-DD heading, leave a fresh empty + [Unreleased] on top, and add the compare links — naming the version/tag, + never a commit id:
      • +
      [Unreleased]: https://git.aetoskia.com/aetos/<repo>/compare/x.y.z...HEAD
       [x.y.z]: https://git.aetoskia.com/aetos/<repo>/compare/x.y.(z-1)...x.y.z
       
      -
      -

      🔢 Bump the version file

        -
      • Package: edit version = "x.y.z" in pyproject.toml.
      • -
      • Service / site: edit the VERSION file.
      • +
      • Bump the version file to the intended release version: version = "x.y.z" + in pyproject.toml (packages) or the VERSION file (services/sites).
      -

      Then commit and tag:

      -
      1
      -2
      -3
      -4
      -5
      git add CHANGELOG.md pyproject.toml   # or VERSION
      -git commit -m "chore(release): x.y.z"
      -git tag x.y.z
      -git push origin HEAD
      -git push origin x.y.z
      -
      +
      +

      🏷️ Tag the merged commit

      +
        +
      1. Merge or squash the MR into main.
      2. +
      3. Create the tag on the resulting commit: git tag x.y.z (lightweight).
      4. +
      5. Push the tag (git push origin x.y.z) — Drone builds the release.
      6. +
      +

      🤖 Agent-assisted tagging

      +

      The agent does not author or merge the MR and never tags before the merge. After +you confirm the MR is merged/squashed and tell it to proceed, the agent:

      +
        +
      1. Waits for that explicit go-ahead.
      2. +
      3. Finds the commit that introduced the bump:
      4. +
      5. package: + git log -S 'version = "x.y.z"' -n 1 --format='%H %s' -- pyproject.toml
      6. +
      7. service / site: + git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION
      8. +
      9. Verifies that commit's version file equals x.y.z, then tags only that + commit: git tag x.y.z <sha>.
      10. +
      11. Does not push — it asks you to run git push origin x.y.z.
      12. +

      🤖 What Drone does

        diff --git a/standards/wiki/search/search_index.json b/standards/wiki/search/search_index.json index fbc1fde..90624d6 100644 --- a/standards/wiki/search/search_index.json +++ b/standards/wiki/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"\ud83e\udde9 Standards \u2014 the Aetos App Blueprint","text":"

        One reusable architecture for every backend application in the Aetos ecosystem: a spec-first HTTP edge, a framework-free domain core, a pluggable infrastructure layer, and a single composition root.

        Fill in two axes only and a new app is done: your resource model, and (if needed) your pipeline family. The blueprint itself never names a business domain \u2014 expenses, health metrics, inventory, and analytics are all the same shape underneath.

        Doc model: this wiki is written for humans \u2014 how-to guides, the build recipe, and quality gates. The enforceable rules (layering, composition root, CRUD template, pipeline scaffold) and the library registry live in the reference pages, mirrored by the machine-readable standards MCP bundle. Query find_library before writing any infrastructure.

        "},{"location":"#key-features","title":"\ud83d\ude80 Key Features","text":"
        • \ud83e\udded Spec-first routing \u2014 the OpenAPI document, not decorator routers, is the source of truth (operationId lookup)
        • \ud83c\udfd7\ufe0f One-way layering \u2014 interfaces \u2192 domain \u2192 infra, enforced
        • \ud83d\udd0c Single composition root \u2014 every dependency is wired in exactly one place
        • \ud83e\udde9 Generic, not app-specific \u2014 reusable rules versus two authoring axes
        • \ud83d\udcda Library-backed \u2014 DB, DI, pipelines, ingestion, auth, and docs come from internal libraries, never hand-written
        • \ud83d\udea6 Explicit state machines \u2014 durable job statuses, progress, and human-in-the-loop pauses
        "},{"location":"#documentation-structure","title":"\ud83d\udcc1 Documentation Structure","text":"Section Description Overview Philosophy, the one-way dependency rule, architecture App Components The component model and how the pieces wire together Start an App The entry point: gather the two axes, then build Testing & Quality Test layout and acceptance gates

        Reference (separate site, mirrors the MCP bundle): the enforceable rules \u2014 Build Recipe, Layering, Composition Root, Spec-First Routing, CRUD Template, Pipeline Scaffold, Worker & Progress, Human-in-the-Loop, Infra Adapters, Genericity Matrix, Library Registry.

        "},{"location":"#related-resources","title":"\ud83d\udd17 Related Resources","text":"
        • MCP bundle \u2014 standards server on :8009: read docs://index, docs://nav, docs://modules/{module}; call find_library(capability)
        • Library registry \u2014 the catalog of internal libraries behind every app (libraries.json, served as registry://libraries)
        • Template \u2014 the runnable skeleton at standards/src/templates/app/
        • Start a build \u2014 invoke the start_app prompt on the standards server, or read the Start an App guide

        \u00a9 Aetoskia Internal \u2014 standards

        "},{"location":"01_overview/","title":"Overview","text":"

        The blueprint is a hexagonal (ports & adapters) application with a spec-first web edge and a single composition root. It favors explicit wiring over implicit magic and existing internal libraries over hand-written infrastructure. Start here to build the mental model; the enforceable details live in the reference pages.

        "},{"location":"01_overview/#architecture","title":"\ud83c\udfd7\ufe0f Architecture","text":"
        flowchart LR\n    subgraph EDGE[\"interfaces/ \u2014 HTTP edge\"]\n        OAS[\"openapi.yaml<br/>operationId contract\"]\n        RT[\"<resource>/routes.py<br/>thin handlers\"]\n    end\n\n    subgraph CORE[\"domain/ \u2014 business core\"]\n        MD[\"models\"]\n        PT[\"ports (adapter binding seam)\"]\n        SV[\"services\"]\n    end\n\n    subgraph INFRA[\"infra/ \u2014 adapters\"]\n        RP[\"mongo repos (mongo-ops)\"]\n        AD[\"cache \u00b7 stores \u00b7 llm \u00b7 mail\"]\n        DB[(\"MongoDB\")]\n    end\n\n    CR[\"init.py<br/>composition root\"]\n\n    OAS --> RT\n    RT --> SV\n    SV --> PT\n    SV --> RP\n    PT -. depends on .- RP\n    CR --- RT\n    CR --- SV\n    CR --- RP\n    RP --> DB\n    AD --- CR

        The rule holds at every edge: code in an outer ring may depend on a ring closer to the core, never the reverse. domain/ never imports a web framework; only its ports/ seam reaches into infra/ to bind adapters.

        Legend \u2014 solid arrows are compile-time calls; dotted arrows are the port/adapter binding, performed by the composition root at startup.

        "},{"location":"01_overview/#the-one-way-dependency-rule","title":"\ud83d\udd04 The one-way dependency rule","text":"Ring May import Never imports interfaces/ domain, framework glue (glue only) business logic, infra directly domain/ its own models + its ports/ seam (which binds infra/libraries) web frameworks, interfaces/ infra/ domain ports, drivers, libraries \u2014 init.py everything (the wiring point) \u2014"},{"location":"01_overview/#core-principles","title":"\ud83e\udded Core principles","text":"
        1. One-way dependencies. interfaces -> domain -> infra is allowed; the reverse is forbidden.
        2. Ports in the domain, adapters in infra. A service depends on a port; the port's factory binds the concrete adapter, and the composition root calls those factories.
        3. One composition root. Nothing constructs its own dependencies. All wiring lives in one module (init.py) exposed as a flat resource registry.
        4. Spec-first. The HTTP contract is declared in openapi.yaml; route handlers are looked up by operationId. There are no decorator routers.
        5. Reuse the libraries. Orchestration, DI, Mongo repositories, ingestion, auth, and docs come from internal libraries \u2014 see the Library Registry.
        6. Explicit state machines. Long-running work moves through explicit, durable statuses and can pause for human input.
        "},{"location":"01_overview/#runtime-processes","title":"\u2699\ufe0f Runtime processes","text":"

        A standard app may run as up to three processes that share the same composition root:

        Process Entry point Responsibility API main.py serve HTTP; start/stop resources via lifespan Worker worker.py poll durable jobs, run pipelines, publish progress Scripts python -m scripts.<name> one-shot operator tasks"},{"location":"01_overview/#read-next","title":"\u27a1\ufe0f Read Next","text":"
        • 02 \u2013 App Components \u00b7 03 \u2013 Start an App
        "},{"location":"02_components/","title":"App Components","text":"

        What ships in every standard app, and how the pieces relate. This is the blueprint's component model \u2014 templates/app/ is a runnable instance of it.

        "},{"location":"02_components/#component-model","title":"\ud83d\uddc2\ufe0f Component model","text":"

        The blueprint has two orthogonal views: runtime flow (who calls whom) and composition-root wiring (who constructs whom). Keeping them separate makes the layering visible instead of hiding it behind a hub.

        "},{"location":"02_components/#runtime-flow","title":"\ud83d\udd00 Runtime flow","text":"

        Who calls whom at request and job time:

        %%{init: {\"flowchart\": {\"nodeSpacing\": 50, \"rankSpacing\": 80}}}%%\nflowchart TB\n    subgraph REQ[\"Request path \u2014 API process\"]\n        direction LR\n        CL([\"Client<br/>operationId\"]) --> RT[\"interfaces/&lt;resource&gt;/routes.py\"]\n        RT --> SVC[\"&lt;resource&gt;_svc\"]\n        SVC --> REPO[\"&lt;resource&gt;_repo\"]\n    end\n\n    subgraph WRK[\"Background path \u2014 worker process\"]\n        direction LR\n        W[\"worker.py\"] --> JSVC[\"job_svc\"]\n        W --> PIPE[\"pipelines/&lt;family&gt;\"]\n        PIPE --> ISVC[\"item_svc\"]\n        JSVC --> JREPO[\"job_repo\"]\n        ISVC --> IREPO[\"item_repo\"]\n    end\n\n    subgraph INFRA[\"infra/ \u2014 adapters\"]\n        MONGO[(\"MongoDB / mongo_ops\")]\n    end\n\n    REPO --> MONGO\n    JREPO --> MONGO\n    IREPO --> MONGO

        Legend \u2014 solid arrows are runtime calls. Nothing is self-constructed.

        "},{"location":"02_components/#composition-root-wiring","title":"\ud83e\uddf5 Composition-root wiring","text":"

        Who constructs what at startup:

        %%{init: {\"flowchart\": {\"nodeSpacing\": 50, \"rankSpacing\": 80}}}%%\nflowchart TB\n    INIT[\"init.py \u2014 composition root\"]\n    SETUP[\"infra/db/setup.py\"]\n    FACT[\"domain/*/ports/*<br/>factory seams\"]\n    REPOS[\"repos<br/>infra/db/repos/mongo.py\"]\n    SVCES[\"services<br/>CrudsServiceAdaptor\"]\n    STATE[\"app.state.db_resources\"]\n    HEXA[\"hexa.build\"]\n    RT[\"routes.py\"]\n    WK[\"worker.py\"]\n\n    INIT --> SETUP\n    INIT --> FACT\n    FACT --> REPOS\n    FACT --> SVCES\n    REPOS --> SVCES\n    HEXA -.-> SVCES\n    INIT --> STATE\n    STATE --> RT\n    INIT --> WK

        Legend \u2014 init.py is the only place that imports concrete adapters. The ports/ factory seams bind infra; the API reads resources from app.state.db_resources, the worker calls init() directly.

        "},{"location":"02_components/#component-roles","title":"\ud83d\udce6 Component roles","text":""},{"location":"02_components/#1-interfaces-the-edge","title":"1. interfaces/ \u2014 the edge","text":"

        Thin handlers bound to openapi.yaml operationIds. They parse the request, call a service, and shape the response. No business rules, no I/O.

        • interfaces/openapi.py re-exports every route module so the OpenAPI-first app can resolve handlers.
        • Routes may mount the cache decorator on read endpoints.
        "},{"location":"02_components/#2-domain-the-core","title":"2. domain/ \u2014 the core","text":"

        Models, ports, and services (use cases). No framework imports. The ports/ package is the one seam allowed to reach into infra/: each port module declares the document shape and a factory that binds the adapter.

        • <aggregate>/models.py \u2014 dataclasses, enums, document shapes.
        • <aggregate>/ports/db.py \u2014 document model + create_<aggregate>_repo().
        • <aggregate>/ports/service.py \u2014 service + get_<aggregate>_service(repo).
        • Services compose ports and enforce the business rules; the port factories bind the implementations, and the composition root calls them.
        "},{"location":"02_components/#3-infra-the-adapters","title":"3. infra/ \u2014 the adapters","text":"

        Concrete implementations of the domain ports plus cross-cutting infrastructure:

        • db/ \u2014 mongo-ops repositories and the connection lifecycle.
        • adapters/ \u2014 cache store, progress bus, storages, fetchers (library-backed).
        • Anything else the domain needs, implemented against its ports.
        "},{"location":"02_components/#4-pipelines-data-driven-families-optional","title":"4. pipelines/ \u2014 data-driven families (optional)","text":"

        Extraction and enrichment families, each a deterministic step chain (abc.py / impl.py / pipeline.yaml / resources/). Roots are registered in the pattern registry and driven either by a worker job or a CLI.

        "},{"location":"02_components/#5-workerpy-the-job-worker-optional","title":"5. worker.py \u2014 the job worker (optional)","text":"

        A separate process that polls durable job collections, runs pipeline roots, and publishes progress to the progress bus. It shares the same composition root as the API.

        "},{"location":"02_components/#6-initpy-the-composition-root","title":"6. init.py \u2014 the composition root","text":"

        The only place anything is constructed: leaf repositories \u2192 dependent repositories \u2192 services \u2192 adapters. Exposes get_svc overloads and starts / stops resources on the app lifespan.

        "},{"location":"02_components/#how-the-request-flows","title":"\ud83d\udd17 How the request flows","text":"
        sequenceDiagram\n    participant C as Client\n    participant R as route (interfaces)\n    participant S as service (port factory / adapter)\n    participant P as repo (infra)\n    participant DB as MongoDB\n\n    C->>R: POST /items (operationId)\n    R->>S: svc.create(payload)\n    S->>P: repo.insert(doc)\n    P->>DB: insert\n    DB-->>P: ack\n    P-->>S: doc\n    S-->>R: result\n    R-->>C: 200 JSON
        "},{"location":"02_components/#related","title":"Related","text":"
        • 01 \u2013 Overview \u00b7 03 \u2013 Start an App \u00b7 04 \u2013 Testing & Quality
        "},{"location":"03_start_an_app/","title":"\ud83d\ude80 Start an App","text":"

        This is the entry point for building a new application from the blueprint. The goal is one deterministic pass: you supply only the two axes, and the agent does the rest by reading the standards MCP, importing Tier A libraries, and copying Tier B template components.

        Doc model: this page is the human entry point. The deterministic, machine-facing checklist lives in the reference page Build Recipe, served as docs://modules/build_recipe.

        "},{"location":"03_start_an_app/#what-the-agent-needs-from-you","title":"\ud83e\uddfe What the agent needs from you","text":"

        Gather these before starting \u2014 the start_app MCP prompt asks for them:

        1. App name + one-line purpose.
        2. Axis 1 \u2014 resources. Each resource, its fields, and relationships. Paste openapi.yaml if you already have it.
        3. Axis 2 \u2014 pipelines. Only if an input needs a multi-step transformation: the families and their input formats (or \"none\").
        4. Auth needed now? Default no. Auth is deferred (py-jwt primitives only), and an authless app is just a spec with no security keys \u2014 see Spec-First Routing \u2192 Authless apps.
        5. Integrations. Mongo, ingestion formats, email, LLM provider.

        If you can state axes 1 and 2, the rest is mechanical.

        "},{"location":"03_start_an_app/#how-to-start","title":"\u25b6\ufe0f How to start","text":"

        From an MCP client connected to the standards server:

        1. Invoke the intake prompt (or start_app with no arguments) to get the intake questions.
        2. Answer them, then invoke build (build(app_name=..., resources=..., pipelines=..., auth=...)), or use start_app to intake-and-build in one call.
        3. The prompt hands off to docs://modules/build_recipe; the agent scaffolds with get_app_template() and pulls exact files with get_app_component(kind, resource=..., family=...), authoring only the app-specific parts.
        4. To validate the standard without touching a real app, invoke trial (trial(app_name=..., build_path=...)) to build into a scratch directory, prove it builds, and report findings.

        Manual alternative \u2014 copy the skeleton and follow the reference recipe:

        cp -r <docs>/standards/src/templates/app apps/<your-app>\n
        "},{"location":"03_start_an_app/#reference","title":"\ud83d\udcda Reference","text":"
        • Build Recipe \u2014 the deterministic checklist
        • Genericity Matrix \u2014 Tier A / B / C
        • Library Registry \u2014 the Tier A catalog
        • App Components \u2014 the component model
        "},{"location":"03_start_an_app/#related","title":"Related","text":"
        • 01 \u2013 Overview \u00b7 02 \u2013 App Components \u00b7 04 \u2013 Testing & Quality
        "},{"location":"04_development/01_testing/","title":"Testing & Quality Gates","text":"

        Two suites run under pytest with asyncio auto mode: integration (the HTTP edge against fakes) and unit (pure domain and pipeline logic). Finish a blueprint app only when every gate below passes.

        "},{"location":"04_development/01_testing/#layout","title":"\ud83d\uddc2\ufe0f Layout","text":"
        tests/\n    integration/     # TestClient(app) + mocked resources\n    unit/            # models, converters, pipeline stages/roots\n    conftest.py      # fixtures\n
        "},{"location":"04_development/01_testing/#integration-tests","title":"\ud83d\ude80 Integration tests","text":"
        • Build the app with TestClient.
        • Replace app.state.db_resources with fake repositories/services so no database is required.
        • Patch the auth introspection call (httpx.AsyncClient.post) to return a canned identity.
        • Assert status codes and bodies for list/get/create/update/delete, plus 400, 404, 204, and the streaming endpoint's fallback.
        client = TestClient(app)\napp.state.db_resources = {\"item_svc\": FakeItemService(), ...}\n\ndef test_create_item():\n    r = client.post(\"/items\", json={\"name\": \"x\"})\n    assert r.status_code == 200\n
        "},{"location":"04_development/01_testing/#unit-tests","title":"\ud83e\uddea Unit tests","text":"
        • Domain models and converters: pure, no I/O.
        • Pipeline stages: feed a fixture state, assert the transformed state.
        • Assembled pipeline roots: fixture parity \u2014 replay a stored fixture input and compare against a golden output file.
        "},{"location":"04_development/01_testing/#config-consistency-tests","title":"\ud83d\udd10 Config-consistency tests","text":"

        For rule-driven pipelines, add a test that cross-references rules against the declared pattern registry: every flag emitted must be defined; every defined flag must be reachable. This catches drift without running the pipeline.

        "},{"location":"04_development/01_testing/#quality-gates","title":"\u2705 Quality gates","text":"

        A definition of done for any standard app:

        • python -c \"import main\" succeeds.
        • pytest passes.
        • The app serves the spec's operations; the worker drains its queue.
        • No domain module imports a web framework.
        • No infrastructure was reimplemented that a library already provides.
        "},{"location":"04_development/01_testing/#conventions","title":"\ud83d\udca1 Conventions","text":"
        • asyncio_mode = \"auto\"; no manual event loops.
        • Fixtures are checked into the repo (inputs + golden outputs).
        • Tests skip (not fail) when a required fixture is absent.
        • Do not mock the domain; mock only the infrastructure edge.
        "},{"location":"04_development/01_testing/#related","title":"Related","text":"
        • 02 \u2013 App Components \u00b7 03 \u2013 Start an App \u00b7 Overview
        "},{"location":"04_development/02_releasing/","title":"Releasing & Versioning","text":"

        How to cut a release of any Aetos repository. The rule lives in the reference page Versioning & Changelog; this is the runbook you follow.

        Every repository is one of two Drone shapes \u2014 a PyPI package or a Docker deployment (Drone Pipelines). Both are released the same way: bump the version file, promote the changelog, tag.

        "},{"location":"04_development/02_releasing/#before-you-start","title":"\ud83e\uddfe Before you start","text":"
        • main is green (the Drone quality gate passed on the last run).
        • You know whether this is a breaking, feature, or fix release.
        • The version file exists:
        • package \u2192 version in pyproject.toml
        • service / site \u2192 VERSION at the repo root
        "},{"location":"04_development/02_releasing/#pick-the-next-version","title":"\ud83d\udea6 Pick the next version","text":"

        The version file and the tag must be identical. For 0.y.z, 0.y is the major line (see the reference page); once at 1.0.0, normal SemVer applies.

        Change 0.y.z \u2192 1.0.0+ \u2192 Breaking 0.(y+1).0 (x+1).0.0 Feature 0.y.(z+1) x.(y+1).0 Fix 0.y.(z+1) x.y.(z+1)"},{"location":"04_development/02_releasing/#promote-the-changelog","title":"\u270d\ufe0f Promote the changelog","text":"

        In CHANGELOG.md:

        1. Rename the content under [Unreleased] into a new ## [x.y.z] - YYYY-MM-DD heading (keep the sections that apply).
        2. Leave a fresh, empty ## [Unreleased] on top.
        3. Add the compare links at the bottom:
        [Unreleased]: https://git.aetoskia.com/aetos/<repo>/compare/x.y.z...HEAD\n[x.y.z]: https://git.aetoskia.com/aetos/<repo>/compare/x.y.(z-1)...x.y.z\n
        "},{"location":"04_development/02_releasing/#bump-the-version-file","title":"\ud83d\udd22 Bump the version file","text":"
        • Package: edit version = \"x.y.z\" in pyproject.toml.
        • Service / site: edit the VERSION file.

        Then commit and tag:

        git add CHANGELOG.md pyproject.toml   # or VERSION\ngit commit -m \"chore(release): x.y.z\"\ngit tag x.y.z\ngit push origin HEAD\ngit push origin x.y.z\n
        "},{"location":"04_development/02_releasing/#what-drone-does","title":"\ud83e\udd16 What Drone does","text":"
        • Type A (package): asserts tag == pyproject version, then skips if that version already exists on the index, runs the quality gate, builds, and uploads the wheel + sdist.
        • Type B (service): asserts tag == VERSION, resolves the tag, skips if the image already exists, runs the quality gate, builds, pushes, and restarts the container.
        • Type B (site): triggered on push, ships :latest and has no tag guard.

        If the guard fails, nothing is published \u2014 fix the version file, amend the commit, and move the tag only if it was never pushed.

        "},{"location":"04_development/02_releasing/#backfill-recovery","title":"\ud83d\udedf Backfill / recovery","text":"

        If an older tag never published (a past version-file mismatch, an index outage):

        • Package: run the backfill-pypi-from-tags pipeline (custom event). It checks out every tag, verifies tag == pyproject version at that commit, and uploads the ones missing from the index. Already-fixed history is never rewritten.
        • Service: rebuild the image for the missing tag with a fresh commit and a new patch version; do not move a published tag.
        "},{"location":"04_development/02_releasing/#if-a-release-is-wrong","title":"\ud83d\udd01 If a release is wrong","text":"
        • Never reuse or force-move a pushed tag.
        • Fix forward: bump to the next patch, promote the changelog, tag again.
        "},{"location":"04_development/02_releasing/#related","title":"Related","text":"
        • Testing & Quality Gates \u00b7 Versioning & Changelog \u00b7 Drone Pipelines
        "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"\ud83e\udde9 Standards \u2014 the Aetos App Blueprint","text":"

        One reusable architecture for every backend application in the Aetos ecosystem: a spec-first HTTP edge, a framework-free domain core, a pluggable infrastructure layer, and a single composition root.

        Fill in two axes only and a new app is done: your resource model, and (if needed) your pipeline family. The blueprint itself never names a business domain \u2014 expenses, health metrics, inventory, and analytics are all the same shape underneath.

        Doc model: this wiki is written for humans \u2014 how-to guides, the build recipe, and quality gates. The enforceable rules (layering, composition root, CRUD template, pipeline scaffold) and the library registry live in the reference pages, mirrored by the machine-readable standards MCP bundle. Query find_library before writing any infrastructure.

        "},{"location":"#key-features","title":"\ud83d\ude80 Key Features","text":"
        • \ud83e\udded Spec-first routing \u2014 the OpenAPI document, not decorator routers, is the source of truth (operationId lookup)
        • \ud83c\udfd7\ufe0f One-way layering \u2014 interfaces \u2192 domain \u2192 infra, enforced
        • \ud83d\udd0c Single composition root \u2014 every dependency is wired in exactly one place
        • \ud83e\udde9 Generic, not app-specific \u2014 reusable rules versus two authoring axes
        • \ud83d\udcda Library-backed \u2014 DB, DI, pipelines, ingestion, auth, and docs come from internal libraries, never hand-written
        • \ud83d\udea6 Explicit state machines \u2014 durable job statuses, progress, and human-in-the-loop pauses
        "},{"location":"#documentation-structure","title":"\ud83d\udcc1 Documentation Structure","text":"Section Description Overview Philosophy, the one-way dependency rule, architecture App Components The component model and how the pieces wire together Start an App The entry point: gather the two axes, then build Testing & Quality Test layout and acceptance gates

        Reference (separate site, mirrors the MCP bundle): the enforceable rules \u2014 Build Recipe, Layering, Composition Root, Spec-First Routing, CRUD Template, Pipeline Scaffold, Worker & Progress, Human-in-the-Loop, Infra Adapters, Genericity Matrix, Library Registry.

        "},{"location":"#related-resources","title":"\ud83d\udd17 Related Resources","text":"
        • MCP bundle \u2014 standards server on :8009: read docs://index, docs://nav, docs://modules/{module}; call find_library(capability)
        • Library registry \u2014 the catalog of internal libraries behind every app (libraries.json, served as registry://libraries)
        • Template \u2014 the runnable skeleton at standards/src/templates/app/
        • Start a build \u2014 invoke the start_app prompt on the standards server, or read the Start an App guide

        \u00a9 Aetoskia Internal \u2014 standards

        "},{"location":"01_overview/","title":"Overview","text":"

        The blueprint is a hexagonal (ports & adapters) application with a spec-first web edge and a single composition root. It favors explicit wiring over implicit magic and existing internal libraries over hand-written infrastructure. Start here to build the mental model; the enforceable details live in the reference pages.

        "},{"location":"01_overview/#architecture","title":"\ud83c\udfd7\ufe0f Architecture","text":"
        flowchart LR\n    subgraph EDGE[\"interfaces/ \u2014 HTTP edge\"]\n        OAS[\"openapi.yaml<br/>operationId contract\"]\n        RT[\"<resource>/routes.py<br/>thin handlers\"]\n    end\n\n    subgraph CORE[\"domain/ \u2014 business core\"]\n        MD[\"models\"]\n        PT[\"ports (adapter binding seam)\"]\n        SV[\"services\"]\n    end\n\n    subgraph INFRA[\"infra/ \u2014 adapters\"]\n        RP[\"mongo repos (mongo-ops)\"]\n        AD[\"cache \u00b7 stores \u00b7 llm \u00b7 mail\"]\n        DB[(\"MongoDB\")]\n    end\n\n    CR[\"init.py<br/>composition root\"]\n\n    OAS --> RT\n    RT --> SV\n    SV --> PT\n    SV --> RP\n    PT -. depends on .- RP\n    CR --- RT\n    CR --- SV\n    CR --- RP\n    RP --> DB\n    AD --- CR

        The rule holds at every edge: code in an outer ring may depend on a ring closer to the core, never the reverse. domain/ never imports a web framework; only its ports/ seam reaches into infra/ to bind adapters.

        Legend \u2014 solid arrows are compile-time calls; dotted arrows are the port/adapter binding, performed by the composition root at startup.

        "},{"location":"01_overview/#the-one-way-dependency-rule","title":"\ud83d\udd04 The one-way dependency rule","text":"Ring May import Never imports interfaces/ domain, framework glue (glue only) business logic, infra directly domain/ its own models + its ports/ seam (which binds infra/libraries) web frameworks, interfaces/ infra/ domain ports, drivers, libraries \u2014 init.py everything (the wiring point) \u2014"},{"location":"01_overview/#core-principles","title":"\ud83e\udded Core principles","text":"
        1. One-way dependencies. interfaces -> domain -> infra is allowed; the reverse is forbidden.
        2. Ports in the domain, adapters in infra. A service depends on a port; the port's factory binds the concrete adapter, and the composition root calls those factories.
        3. One composition root. Nothing constructs its own dependencies. All wiring lives in one module (init.py) exposed as a flat resource registry.
        4. Spec-first. The HTTP contract is declared in openapi.yaml; route handlers are looked up by operationId. There are no decorator routers.
        5. Reuse the libraries. Orchestration, DI, Mongo repositories, ingestion, auth, and docs come from internal libraries \u2014 see the Library Registry.
        6. Explicit state machines. Long-running work moves through explicit, durable statuses and can pause for human input.
        "},{"location":"01_overview/#runtime-processes","title":"\u2699\ufe0f Runtime processes","text":"

        A standard app may run as up to three processes that share the same composition root:

        Process Entry point Responsibility API main.py serve HTTP; start/stop resources via lifespan Worker worker.py poll durable jobs, run pipelines, publish progress Scripts python -m scripts.<name> one-shot operator tasks"},{"location":"01_overview/#read-next","title":"\u27a1\ufe0f Read Next","text":"
        • 02 \u2013 App Components \u00b7 03 \u2013 Start an App
        "},{"location":"02_components/","title":"App Components","text":"

        What ships in every standard app, and how the pieces relate. This is the blueprint's component model \u2014 templates/app/ is a runnable instance of it.

        "},{"location":"02_components/#component-model","title":"\ud83d\uddc2\ufe0f Component model","text":"

        The blueprint has two orthogonal views: runtime flow (who calls whom) and composition-root wiring (who constructs whom). Keeping them separate makes the layering visible instead of hiding it behind a hub.

        "},{"location":"02_components/#runtime-flow","title":"\ud83d\udd00 Runtime flow","text":"

        Who calls whom at request and job time:

        %%{init: {\"flowchart\": {\"nodeSpacing\": 50, \"rankSpacing\": 80}}}%%\nflowchart TB\n    subgraph REQ[\"Request path \u2014 API process\"]\n        direction LR\n        CL([\"Client<br/>operationId\"]) --> RT[\"interfaces/&lt;resource&gt;/routes.py\"]\n        RT --> SVC[\"&lt;resource&gt;_svc\"]\n        SVC --> REPO[\"&lt;resource&gt;_repo\"]\n    end\n\n    subgraph WRK[\"Background path \u2014 worker process\"]\n        direction LR\n        W[\"worker.py\"] --> JSVC[\"job_svc\"]\n        W --> PIPE[\"pipelines/&lt;family&gt;\"]\n        PIPE --> ISVC[\"item_svc\"]\n        JSVC --> JREPO[\"job_repo\"]\n        ISVC --> IREPO[\"item_repo\"]\n    end\n\n    subgraph INFRA[\"infra/ \u2014 adapters\"]\n        MONGO[(\"MongoDB / mongo_ops\")]\n    end\n\n    REPO --> MONGO\n    JREPO --> MONGO\n    IREPO --> MONGO

        Legend \u2014 solid arrows are runtime calls. Nothing is self-constructed.

        "},{"location":"02_components/#composition-root-wiring","title":"\ud83e\uddf5 Composition-root wiring","text":"

        Who constructs what at startup:

        %%{init: {\"flowchart\": {\"nodeSpacing\": 50, \"rankSpacing\": 80}}}%%\nflowchart TB\n    INIT[\"init.py \u2014 composition root\"]\n    SETUP[\"infra/db/setup.py\"]\n    FACT[\"domain/*/ports/*<br/>factory seams\"]\n    REPOS[\"repos<br/>infra/db/repos/mongo.py\"]\n    SVCES[\"services<br/>CrudsServiceAdaptor\"]\n    STATE[\"app.state.db_resources\"]\n    HEXA[\"hexa.build\"]\n    RT[\"routes.py\"]\n    WK[\"worker.py\"]\n\n    INIT --> SETUP\n    INIT --> FACT\n    FACT --> REPOS\n    FACT --> SVCES\n    REPOS --> SVCES\n    HEXA -.-> SVCES\n    INIT --> STATE\n    STATE --> RT\n    INIT --> WK

        Legend \u2014 init.py is the only place that imports concrete adapters. The ports/ factory seams bind infra; the API reads resources from app.state.db_resources, the worker calls init() directly.

        "},{"location":"02_components/#component-roles","title":"\ud83d\udce6 Component roles","text":""},{"location":"02_components/#1-interfaces-the-edge","title":"1. interfaces/ \u2014 the edge","text":"

        Thin handlers bound to openapi.yaml operationIds. They parse the request, call a service, and shape the response. No business rules, no I/O.

        • interfaces/openapi.py re-exports every route module so the OpenAPI-first app can resolve handlers.
        • Routes may mount the cache decorator on read endpoints.
        "},{"location":"02_components/#2-domain-the-core","title":"2. domain/ \u2014 the core","text":"

        Models, ports, and services (use cases). No framework imports. The ports/ package is the one seam allowed to reach into infra/: each port module declares the document shape and a factory that binds the adapter.

        • <aggregate>/models.py \u2014 dataclasses, enums, document shapes.
        • <aggregate>/ports/db.py \u2014 document model + create_<aggregate>_repo().
        • <aggregate>/ports/service.py \u2014 service + get_<aggregate>_service(repo).
        • Services compose ports and enforce the business rules; the port factories bind the implementations, and the composition root calls them.
        "},{"location":"02_components/#3-infra-the-adapters","title":"3. infra/ \u2014 the adapters","text":"

        Concrete implementations of the domain ports plus cross-cutting infrastructure:

        • db/ \u2014 mongo-ops repositories and the connection lifecycle.
        • adapters/ \u2014 cache store, progress bus, storages, fetchers (library-backed).
        • Anything else the domain needs, implemented against its ports.
        "},{"location":"02_components/#4-pipelines-data-driven-families-optional","title":"4. pipelines/ \u2014 data-driven families (optional)","text":"

        Extraction and enrichment families, each a deterministic step chain (abc.py / impl.py / pipeline.yaml / resources/). Roots are registered in the pattern registry and driven either by a worker job or a CLI.

        "},{"location":"02_components/#5-workerpy-the-job-worker-optional","title":"5. worker.py \u2014 the job worker (optional)","text":"

        A separate process that polls durable job collections, runs pipeline roots, and publishes progress to the progress bus. It shares the same composition root as the API.

        "},{"location":"02_components/#6-initpy-the-composition-root","title":"6. init.py \u2014 the composition root","text":"

        The only place anything is constructed: leaf repositories \u2192 dependent repositories \u2192 services \u2192 adapters. Exposes get_svc overloads and starts / stops resources on the app lifespan.

        "},{"location":"02_components/#how-the-request-flows","title":"\ud83d\udd17 How the request flows","text":"
        sequenceDiagram\n    participant C as Client\n    participant R as route (interfaces)\n    participant S as service (port factory / adapter)\n    participant P as repo (infra)\n    participant DB as MongoDB\n\n    C->>R: POST /items (operationId)\n    R->>S: svc.create(payload)\n    S->>P: repo.insert(doc)\n    P->>DB: insert\n    DB-->>P: ack\n    P-->>S: doc\n    S-->>R: result\n    R-->>C: 200 JSON
        "},{"location":"02_components/#related","title":"Related","text":"
        • 01 \u2013 Overview \u00b7 03 \u2013 Start an App \u00b7 04 \u2013 Testing & Quality
        "},{"location":"03_start_an_app/","title":"\ud83d\ude80 Start an App","text":"

        This is the entry point for building a new application from the blueprint. The goal is one deterministic pass: you supply only the two axes, and the agent does the rest by reading the standards MCP, importing Tier A libraries, and copying Tier B template components.

        Doc model: this page is the human entry point. The deterministic, machine-facing checklist lives in the reference page Build Recipe, served as docs://modules/build_recipe.

        "},{"location":"03_start_an_app/#what-the-agent-needs-from-you","title":"\ud83e\uddfe What the agent needs from you","text":"

        Gather these before starting \u2014 the start_app MCP prompt asks for them:

        1. App name + one-line purpose.
        2. Axis 1 \u2014 resources. Each resource, its fields, and relationships. Paste openapi.yaml if you already have it.
        3. Axis 2 \u2014 pipelines. Only if an input needs a multi-step transformation: the families and their input formats (or \"none\").
        4. Auth needed now? Default no. Auth is deferred (py-jwt primitives only), and an authless app is just a spec with no security keys \u2014 see Spec-First Routing \u2192 Authless apps.
        5. Integrations. Mongo, ingestion formats, email, LLM provider.

        If you can state axes 1 and 2, the rest is mechanical.

        "},{"location":"03_start_an_app/#how-to-start","title":"\u25b6\ufe0f How to start","text":"

        From an MCP client connected to the standards server:

        1. Invoke the intake prompt (or start_app with no arguments) to get the intake questions.
        2. Answer them, then invoke build (build(app_name=..., resources=..., pipelines=..., auth=...)), or use start_app to intake-and-build in one call.
        3. The prompt hands off to docs://modules/build_recipe; the agent scaffolds with get_app_template() and pulls exact files with get_app_component(kind, resource=..., family=...), authoring only the app-specific parts.
        4. To validate the standard without touching a real app, invoke trial (trial(app_name=..., build_path=...)) to build into a scratch directory, prove it builds, and report findings.

        Manual alternative \u2014 copy the skeleton and follow the reference recipe:

        cp -r <docs>/standards/src/templates/app apps/<your-app>\n
        "},{"location":"03_start_an_app/#reference","title":"\ud83d\udcda Reference","text":"
        • Build Recipe \u2014 the deterministic checklist
        • Genericity Matrix \u2014 Tier A / B / C
        • Library Registry \u2014 the Tier A catalog
        • App Components \u2014 the component model
        "},{"location":"03_start_an_app/#related","title":"Related","text":"
        • 01 \u2013 Overview \u00b7 02 \u2013 App Components \u00b7 04 \u2013 Testing & Quality
        "},{"location":"04_development/01_testing/","title":"Testing & Quality Gates","text":"

        Two suites run under pytest with asyncio auto mode: integration (the HTTP edge against fakes) and unit (pure domain and pipeline logic). Finish a blueprint app only when every gate below passes.

        "},{"location":"04_development/01_testing/#layout","title":"\ud83d\uddc2\ufe0f Layout","text":"
        tests/\n    integration/     # TestClient(app) + mocked resources\n    unit/            # models, converters, pipeline stages/roots\n    conftest.py      # fixtures\n
        "},{"location":"04_development/01_testing/#integration-tests","title":"\ud83d\ude80 Integration tests","text":"
        • Build the app with TestClient.
        • Replace app.state.db_resources with fake repositories/services so no database is required.
        • Patch the auth introspection call (httpx.AsyncClient.post) to return a canned identity.
        • Assert status codes and bodies for list/get/create/update/delete, plus 400, 404, 204, and the streaming endpoint's fallback.
        client = TestClient(app)\napp.state.db_resources = {\"item_svc\": FakeItemService(), ...}\n\ndef test_create_item():\n    r = client.post(\"/items\", json={\"name\": \"x\"})\n    assert r.status_code == 200\n
        "},{"location":"04_development/01_testing/#unit-tests","title":"\ud83e\uddea Unit tests","text":"
        • Domain models and converters: pure, no I/O.
        • Pipeline stages: feed a fixture state, assert the transformed state.
        • Assembled pipeline roots: fixture parity \u2014 replay a stored fixture input and compare against a golden output file.
        "},{"location":"04_development/01_testing/#config-consistency-tests","title":"\ud83d\udd10 Config-consistency tests","text":"

        For rule-driven pipelines, add a test that cross-references rules against the declared pattern registry: every flag emitted must be defined; every defined flag must be reachable. This catches drift without running the pipeline.

        "},{"location":"04_development/01_testing/#quality-gates","title":"\u2705 Quality gates","text":"

        A definition of done for any standard app:

        • python -c \"import main\" succeeds.
        • pytest passes.
        • The app serves the spec's operations; the worker drains its queue.
        • No domain module imports a web framework.
        • No infrastructure was reimplemented that a library already provides.
        "},{"location":"04_development/01_testing/#conventions","title":"\ud83d\udca1 Conventions","text":"
        • asyncio_mode = \"auto\"; no manual event loops.
        • Fixtures are checked into the repo (inputs + golden outputs).
        • Tests skip (not fail) when a required fixture is absent.
        • Do not mock the domain; mock only the infrastructure edge.
        "},{"location":"04_development/01_testing/#related","title":"Related","text":"
        • 02 \u2013 App Components \u00b7 03 \u2013 Start an App \u00b7 Overview
        "},{"location":"04_development/02_releasing/","title":"Releasing & Versioning","text":"

        How to cut a release of any Aetos repository. The rule lives in the reference page Versioning & Changelog; this is the runbook you follow.

        Every repository is one of two Drone shapes \u2014 a PyPI package or a Docker deployment (Drone Pipelines). Both release the same way: the version bump and changelog promotion go in the merge request, and the tag is created on the merged commit.

        "},{"location":"04_development/02_releasing/#before-you-start","title":"\ud83e\uddfe Before you start","text":"
        • You have an open merge request holding the change, and main is green (the Drone quality gate passed on the last run).
        • You know whether this is a breaking, feature, or fix release.
        • The version file exists:
        • package \u2192 version in pyproject.toml
        • service / site \u2192 VERSION at the repo root
        "},{"location":"04_development/02_releasing/#pick-the-next-version","title":"\ud83d\udea6 Pick the next version","text":"

        The version file and the tag must be identical. For 0.y.z, 0.y is the major line (see the reference page); once at 1.0.0, normal SemVer applies.

        Change 0.y.z \u2192 1.0.0+ \u2192 Breaking 0.(y+1).0 (x+1).0.0 Feature 0.y.(z+1) x.(y+1).0 Fix 0.y.(z+1) x.y.(z+1)"},{"location":"04_development/02_releasing/#release-in-the-mr","title":"\ud83c\udf3f Release in the MR","text":"

        The version is known while the change is still a merge request, so the bump rides along with it. Do both edits in the MR:

        • Promote the changelog in CHANGELOG.md: move the [Unreleased] content under a new ## [x.y.z] - YYYY-MM-DD heading, leave a fresh empty [Unreleased] on top, and add the compare links \u2014 naming the version/tag, never a commit id:
        [Unreleased]: https://git.aetoskia.com/aetos/<repo>/compare/x.y.z...HEAD\n[x.y.z]: https://git.aetoskia.com/aetos/<repo>/compare/x.y.(z-1)...x.y.z\n
        • Bump the version file to the intended release version: version = \"x.y.z\" in pyproject.toml (packages) or the VERSION file (services/sites).
        "},{"location":"04_development/02_releasing/#tag-the-merged-commit","title":"\ud83c\udff7\ufe0f Tag the merged commit","text":"
        1. Merge or squash the MR into main.
        2. Create the tag on the resulting commit: git tag x.y.z (lightweight).
        3. Push the tag (git push origin x.y.z) \u2014 Drone builds the release.
        "},{"location":"04_development/02_releasing/#agent-assisted-tagging","title":"\ud83e\udd16 Agent-assisted tagging","text":"

        The agent does not author or merge the MR and never tags before the merge. After you confirm the MR is merged/squashed and tell it to proceed, the agent:

        1. Waits for that explicit go-ahead.
        2. Finds the commit that introduced the bump:
        3. package: git log -S 'version = \"x.y.z\"' -n 1 --format='%H %s' -- pyproject.toml
        4. service / site: git log -S 'x.y.z' -n 1 --format='%H %s' -- VERSION
        5. Verifies that commit's version file equals x.y.z, then tags only that commit: git tag x.y.z <sha>.
        6. Does not push \u2014 it asks you to run git push origin x.y.z.
        "},{"location":"04_development/02_releasing/#what-drone-does","title":"\ud83e\udd16 What Drone does","text":"
        • Type A (package): asserts tag == pyproject version, then skips if that version already exists on the index, runs the quality gate, builds, and uploads the wheel + sdist.
        • Type B (service): asserts tag == VERSION, resolves the tag, skips if the image already exists, runs the quality gate, builds, pushes, and restarts the container.
        • Type B (site): triggered on push, ships :latest and has no tag guard.

        If the guard fails, nothing is published \u2014 fix the version file, amend the commit, and move the tag only if it was never pushed.

        "},{"location":"04_development/02_releasing/#backfill-recovery","title":"\ud83d\udedf Backfill / recovery","text":"

        If an older tag never published (a past version-file mismatch, an index outage):

        • Package: run the backfill-pypi-from-tags pipeline (custom event). It checks out every tag, verifies tag == pyproject version at that commit, and uploads the ones missing from the index. Already-fixed history is never rewritten.
        • Service: rebuild the image for the missing tag with a fresh commit and a new patch version; do not move a published tag.
        "},{"location":"04_development/02_releasing/#if-a-release-is-wrong","title":"\ud83d\udd01 If a release is wrong","text":"
        • Never reuse or force-move a pushed tag.
        • Fix forward: bump to the next patch, promote the changelog, tag again.
        "},{"location":"04_development/02_releasing/#related","title":"Related","text":"
        • Testing & Quality Gates \u00b7 Versioning & Changelog \u00b7 Drone Pipelines
        "}]} \ No newline at end of file