Resolve task service¶
akms.task_context.resolve_task_service
¶
Deterministic task-knowledge resolution service (CLI + MCP shared core).
This module is the single implementation behind akms resolve-task and the
optional akms_resolve_task MCP tool. It is intentionally offline: no LLM
calls, no network I/O. Graph and route inputs are loaded from the local
filesystem only.
Public entry points:
- :func:
resolve_task— full resolve → loadout + manifest write - :func:
load_task_mapping— validate and load a task JSON mapping - :func:
ResolveTaskResult— stable machine-readable result contract
ResolveTaskResult
dataclass
¶
ResolveTaskResult(
status: ResolveStatus,
loadout_path: str | None = None,
manifest_path: str | None = None,
fingerprint: str | None = None,
graph_version: str | None = None,
route_index_hash: str | None = None,
required_count: int = 0,
coactivated_count: int = 0,
advisory_count: int = 0,
node_count: int = 0,
role: str | None = None,
task_id: str | None = None,
phase: int | None = None,
mode: str | None = None,
changed_paths: tuple[str, ...] = (),
error: str | None = None,
error_code: str | None = None,
query_result: TaskKnowledgeQueryResult | None = None,
manifest: ResolutionManifest | None = None,
resolved_seeds: ResolvedSeeds | None = None,
)
Stable machine-readable resolution result.
Serialised to JSON with sorted keys for CLI stdout and MCP tool returns.
to_json_dict
¶
Return a JSON-serialisable dict (excludes non-serial fields).
Source code in packages/akms/src/akms/task_context/resolve_task_service.py
ResolveTaskError
¶
load_task_mapping
¶
Load and lightly validate a task JSON mapping.
Source code in packages/akms/src/akms/task_context/resolve_task_service.py
load_changed_paths_manifest
¶
load_changed_paths_manifest(
source: Mapping[str, Any]
| Sequence[str]
| str
| Path
| None,
) -> tuple[str, ...]
Load an explicit changed-path list from JSON or an in-memory sequence.
Accepted shapes:
* ["src/a.py", "src/b.py"]
* {"changed_paths": [...]} / {"changed_files": [...]} / {"paths": [...]}
Source code in packages/akms/src/akms/task_context/resolve_task_service.py
resolve_git_changed_paths
¶
resolve_git_changed_paths(
repo_root: str | Path, *, base: str, head: str = "HEAD"
) -> tuple[str, ...]
Return repository-relative paths changed between base and head.
Uses git diff --name-only. Failures raise :class:ResolveTaskError
(callers that want soft fallback should catch it).
Source code in packages/akms/src/akms/task_context/resolve_task_service.py
resolve_task
¶
resolve_task(
*,
repo_root: str | Path,
task: Mapping[str, Any] | str | Path,
route_index: TaskRouteIndex
| Mapping[str, Any]
| str
| Path,
agent_role: AgentRole | str = AgentRole.IMPLEMENTER,
changed_paths: Mapping[str, Any]
| Sequence[str]
| str
| Path
| None = None,
base: str | None = None,
head: str | None = None,
graph_path: str | Path | None = None,
loadout_path: str | Path | None = None,
manifest_path: str | Path | None = None,
mode: LoadoutMode | str = LoadoutMode.ROUTING,
available_context: int = 0,
max_depth: int = 2,
phase: int | None = None,
config: PropagationConfig | None = None,
write_artifacts: bool = True,
) -> ResolveTaskResult
Resolve exact + advisory task knowledge and write loadout + manifest.
Parameters¶
repo_root:
Repository root used for graph, loadout, and content resolution.
task:
Task JSON mapping or path to a task JSON file.
route_index:
Parsed :class:TaskRouteIndex, mapping, or path to a route index file.
agent_role:
Role profile for advisory query filters.
changed_paths:
Explicit sequence of repository-relative paths (or a JSON file /
mapping containing such a sequence). A bare path string is rejected.
base, head:
Optional git revisions. When base is set, changed paths are taken
from git diff --name-only base...head (head defaults to HEAD).
Mutually exclusive with a non-empty changed_paths input.
graph_path:
Optional compiled graph path (default knowledge/graph/graph.json).
loadout_path, manifest_path:
Optional output paths (relative paths resolve against repo_root).
mode:
Loadout content mode (routing or full).
write_artifacts:
When False, compute results in memory without writing files (tests).
Returns¶
ResolveTaskResult
Stable counts, paths, fingerprint, and status. On recoverable input
validation failure this still returns status="error" rather than
raising, so CLI/MCP adapters can print pure JSON.
Source code in packages/akms/src/akms/task_context/resolve_task_service.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | |
resolve_task_as_dict
¶
Convenience wrapper returning :meth:ResolveTaskResult.to_json_dict.