Tag Derivation¶
akms.graph.tag_derivation
¶
tag_derivation.py — Hybrid Tag Derivation Engine (§4 of schema spec).
Derives akms_tags for task JSONs when not explicitly set by the developer.
Two strategies, run in sequence, results unioned:
-
Scope-based: Match task
scopefile paths against code-mirror nodesource_filefields and global nodecontent_reffields. Extract the owning node's tags. -
Text-based: Concatenate
title + objective + implementation_steps, then match against node titles (whole-word) and node tags (substring, minmin_tag_lengthchars).
No LLM calls. Pure deterministic string matching.
derive_tags
¶
Derive AKMS tags for a task using hybrid (scope + text) derivation.
If the task already has non-empty akms_tags, returns them unchanged
(explicit tags from developer take precedence).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
DiGraph
|
Compiled knowledge graph. |
required |
task
|
dict
|
Task JSON dict. Expected keys:
- |
required |
config
|
PropagationConfig | None
|
PropagationConfig (uses |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of derived tags. |
Source code in packages/akms/src/akms/graph/tag_derivation.py
fill_task_tags
¶
fill_task_tags(
G: DiGraph,
tasks: list[dict],
config: PropagationConfig | None = None,
) -> list[dict]
Derive and fill akms_tags for a list of tasks.
Modifies tasks in-place and returns them. Only fills tags for tasks
where akms_tags is empty or missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
DiGraph
|
Compiled knowledge graph. |
required |
tasks
|
list[dict]
|
List of task JSON dicts. |
required |
config
|
PropagationConfig | None
|
PropagationConfig. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
The same list of tasks (modified in-place). |
Source code in packages/akms/src/akms/graph/tag_derivation.py
derive_review_seeds
¶
derive_review_seeds(
G: DiGraph,
files_modified: list[str],
fallback_tags: list[str] | None = None,
) -> list[str]
Seed tags for reviewer loadouts based on phase-branch changes.
Walks files_modified (from git diff against the phase-parent
branch) and collects tags from:
- Code-mirror nodes whose source_file matches (intended primary
entry point per FR-T03).
- Concept nodes whose content_ref matches.
When files_modified is empty (e.g. first phase, or the reviewer runs
before any file change lands), fall back to fallback_tags — typically
the union of completed-task akms_tags for this phase.
The return value is a deterministically ordered list so downstream
query_subgraph calls produce reproducible loadouts.