From 7ba1e5737f91c8cfa2586f74d597ea3e7872508d Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 14 Apr 2026 10:40:57 +0000 Subject: [PATCH] docs(spec): document context_tier_hydrator module in ACMS architecture section Adds Context Tier Hydration subsection to the ACMS Architecture section of the specification, documenting the context_tier_hydrator module's public interface (hydrate_tiers_for_plan, hydrate_tiers_from_project), file listing strategy (git ls-files for git-checkout resources, os.walk fallback), budget limits (256 KB per file, 10 MB total per project), and fragment structure (TieredFragment with ContextTier.HOT placement, metadata keys path/detail_depth/relevance_score). Also updates CHANGELOG.md under [Unreleased] > Documentation and adds contribution entry to CONTRIBUTORS.md. ISSUES CLOSED: #6175 --- CHANGELOG.md | 10 +++++++++ CONTRIBUTORS.md | 1 + docs/specification.md | 51 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index adaeda325..27a30e7a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -174,6 +174,16 @@ ensuring data is stored with proper parameter values. `src/cleveragents/cli/commands/plan.py` to show correct positional argument order. CONTRIBUTING.md updated with the required CLI docstring example style guide. +### Documentation + +- **`context_tier_hydrator` module documented in ACMS architecture section** (#9208): Added + a new **Context Tier Hydration** subsection to the ACMS Architecture section of the + specification (`docs/specification.md`), documenting the `context_tier_hydrator` module's + public interface (`hydrate_tiers_for_plan`, `hydrate_tiers_from_project`), file listing + strategy (git ls-files for git-checkout, os.walk fallback), budget limits (256 KB per file, + 10 MB total per project), and fragment structure (`TieredFragment` with HOT tier placement + and metadata keys `path`, `detail_depth`, `relevance_score`). Closes #6175. + ### Fixed - **fileConfig error handling in alembic env.py** (#7874): Wrapped the `fileConfig()` diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e0b305e7b..0bc3d3e03 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -72,3 +72,4 @@ Below are some of the specific details of various contributions. * HAL 9000 has contributed the plan tree JSON `decision_id` fix (#9096): updated `step_tree_json_valid` in features/steps/plan_explain_steps.py to correctly handle the {"data": [...]} envelope structure produced by format_output, and removed @tdd_expected_fail from the @tdd_issue_4254 scenario so it runs as a permanent regression guard. * HAL 9000 has contributed the TDD scenario for plan tree correction visual marking (PR #8671 / issue #8576): added a failing BDD scenario proving that corrected nodes (decisions with is_correction=True) are not visually distinguished in the plan tree output, formalizing Spec Requirement #7 as an executable specification. * HAL 9000 has contributed the `--clone-into` CLI argument for `container-instance`, the `CloneIntoHandler` module, the `devcontainer-instance` snapshot sandbox strategy, and the `ContainerLifecycleState.DISCOVERED` terminology alignment (PR #8304, issue #7555). +* HAL 9000 has contributed the ACMS Context Tier Hydration documentation (PR #9208 / issue #6175): documented the `context_tier_hydrator` module in the ACMS Architecture section of the specification, covering its public interface, file listing strategy, budget limits, and fragment structure. diff --git a/docs/specification.md b/docs/specification.md index 820490811..05b65b8a6 100644 --- a/docs/specification.md +++ b/docs/specification.md @@ -45928,6 +45928,57 @@ Organizations can adopt ACMS features progressively. At each stage, existing res This design ensures agents never wait for index building during execution, providing a responsive and predictable experience even on massive codebases. +#### Context Tier Hydration + +Before context assembly begins, `ContextTierService` must be populated from the project's linked resources. This hydration step is performed by the `context_tier_hydrator` module (`src/cleveragents/application/services/context_tier_hydrator.py`). + +**Integration Point:** Hydration runs inside `LLMExecuteActor.execute()` before the context assembly pipeline is invoked. Without this step, `ContextTierService` starts empty on every CLI invocation and the LLM receives zero file context. + +**Public Interface:** + +```python +def hydrate_tiers_for_plan( + tier_service: ContextTierService, + project_names: list[str], + project_repository: ProjectRepository, + resource_registry: ResourceRegistry, +) -> int: + """Hydrate all projects linked to a plan. Returns total fragment count.""" + +def hydrate_tiers_from_project( + tier_service: ContextTierService, + project_name: str, + resource_id: str, + resource_location: str, + resource_type: str, +) -> int: + """Hydrate a single project resource. Returns fragment count.""" +``` + +**File Listing Strategy:** + +- For `git-checkout` resources: uses `git ls-files` to enumerate tracked files only +- For all other resource types: falls back to `os.walk` directory traversal + +**Budget Limits (per project):** + +- Maximum file size: 256 KB — files exceeding this limit are skipped +- Maximum total size: 10 MB — hydration stops when the per-project budget is exhausted +- Binary files are skipped automatically +- Common non-source directories are excluded: `.git`, `node_modules`, `__pycache__`, `.venv`, `dist`, `build` + +**Fragment Structure:** + +Each file is stored as a `TieredFragment` in `ContextTierService` with: + +- `tier`: `ContextTier.HOT` (all hydrated fragments start in the hot tier) +- `metadata["path"]`: relative file path (string) +- `metadata["detail_depth"]`: depth indicator (string, not int) +- `metadata["relevance_score"]`: relevance score (string, not float) + +!!! note + `detail_depth` and `relevance_score` are stored as strings. This was a deliberate fix (PR #5998) — earlier versions stored these as numeric types, causing serialization inconsistencies. + ### Storage and Persistence !!! adr "Architecture Decision"