# ibm/tksfw architecture

> Architecture diagram of the GitHub repository ibm/tksfw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ibm/tksfw
- Repository: https://github.com/ibm/tksfw

## Overview

KeelStone is a harness-level framework for structuring, delegating, and governing agent work through project files and hooks. A typical flow starts with a human initializing a project, then an agent works inside Claude Code or Codex: hooks supply project context and route delegation, while edit tracking and ledger skills record and validate work. State refresh and stop-time checks support resumability and auditability. The graph uses documented capabilities and shown hook relationships; unsampled implementation details are not inferred.

Main entry points: [`plugins/tksfw/hooks/inject_state.py`](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/inject_state.py) (Context injection), [`plugins/tksfw/hooks/track_edits.py`](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/track_edits.py) (Edit tracking), [`plugins/tksfw/hooks/route_model.py`](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/route_model.py) (Model routing), [`template/.agents/workarea`](https://github.com/ibm/tksfw/tree/main/template/.agents/workarea) (Project ledgers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_project["Project setup"]
  node_init["Project initializer<br/>[new_project.py]"]
  node_method["Project method<br/>[AGENTS.md]"]
end

subgraph group_runtime["Agent runtime"]
  node_layers["Layer resolver<br/>[layers.py]"]
  node_context["Context injection<br/>[inject_state.py]"]
  node_state["State projection<br/>[refresh_state.py]"]
  node_routing["Model routing<br/>[route_model.py]"]
  node_agents["Agent definitions<br/>[agentlib.py]"]
  node_session_end["Session cleanup<br/>[session_end.py]"]
end

subgraph group_governance["Work governance"]
  node_delegation["Work delegation<br/>[SKILL.md]"]
  node_subagents["Subagent tracking<br/>[subagent_track.py]"]
  node_edit_tracking["Edit tracking<br/>[track_edits.py]"]
  node_ledger_skill["Ledger operations<br/>[SKILL.md]"]
  node_validation["Ledger validation"]
  node_ledgers[("Project ledgers<br/>[workarea]")]
  node_stop_checks["Turn-end checks"]
end

subgraph group_integrations["Harness integrations"]
  node_tools_plugin["Optional MCP tools"]
end

node_human(("Human operator"))
node_harness["Agent harness"]

node_human -->|"initializes project"| node_init
node_init -->|"instantiates method"| node_method
node_human -->|"works in"| node_harness
node_harness -->|"starts session"| node_context
node_context -->|"refreshes state"| node_state
node_context -->|"resolves layers"| node_layers
node_harness -->|"dispatches delegation"| node_routing
node_routing -->|"checks live agents"| node_subagents
node_agents -.->|"provides agent tier"| node_routing
node_human -->|"delegates work"| node_delegation
node_harness -->|"tracks edits"| node_edit_tracking
node_edit_tracking -->|"validates ledgers"| node_validation
node_edit_tracking -->|"journals changes"| node_ledgers
node_human -->|"records work"| node_ledger_skill
node_ledger_skill -->|"updates ledgers"| node_ledgers
node_harness -->|"checks turn end"| node_stop_checks
node_stop_checks -->|"checks completeness"| node_ledgers
node_harness -->|"ends session"| node_session_end
node_session_end -->|"clears live set"| node_subagents
node_harness -.->|"optionally uses"| node_tools_plugin

click node_init "https://github.com/ibm/tksfw/blob/main/tools/new_project.py"
click node_method "https://github.com/ibm/tksfw/blob/main/template/AGENTS.md"
click node_layers "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/layers.py"
click node_context "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/inject_state.py"
click node_state "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/refresh_state.py"
click node_routing "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/route_model.py"
click node_agents "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/agentlib.py"
click node_delegation "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/skills/delegate-work/SKILL.md"
click node_subagents "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/subagent_track.py"
click node_edit_tracking "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/track_edits.py"
click node_ledger_skill "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/skills/yaml-log-entry/SKILL.md"
click node_validation "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/skills/yaml-log-entry/assets/validate_yaml_log.py"
click node_ledgers "https://github.com/ibm/tksfw/tree/main/template/.agents/workarea"
click node_stop_checks "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/check_ledgers_on_stop.py"
click node_session_end "https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/session_end.py"
click node_tools_plugin "https://github.com/ibm/tksfw/tree/main/plugins/tksfw-tools"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_init,node_method toneBlue
class node_layers,node_context,node_state,node_routing,node_agents,node_session_end toneAmber
class node_delegation,node_subagents,node_edit_tracking,node_ledger_skill,node_validation,node_ledgers,node_stop_checks toneMint
class node_tools_plugin toneRose
class node_human,node_harness toneIndigo
```

## Components

### Project setup

- [Project initializer](https://github.com/ibm/tksfw/blob/main/tools/new_project.py): `tools/new_project.py`
- [Project method](https://github.com/ibm/tksfw/blob/main/template/AGENTS.md): `template/AGENTS.md`

### Agent runtime

- [Layer resolver](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/layers.py): `plugins/tksfw/hooks/layers.py`
- [Context injection](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/inject_state.py): `plugins/tksfw/hooks/inject_state.py`
- [State projection](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/refresh_state.py): `plugins/tksfw/hooks/refresh_state.py`
- [Model routing](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/route_model.py): `plugins/tksfw/hooks/route_model.py`
- [Agent definitions](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/agentlib.py): `plugins/tksfw/hooks/agentlib.py`
- [Session cleanup](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/session_end.py): `plugins/tksfw/hooks/session_end.py`

### Work governance

- [Work delegation](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/skills/delegate-work/SKILL.md): `plugins/tksfw/skills/delegate-work/SKILL.md`
- [Subagent tracking](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/subagent_track.py): `plugins/tksfw/hooks/subagent_track.py`
- [Edit tracking](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/track_edits.py): `plugins/tksfw/hooks/track_edits.py`
- [Ledger operations](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/skills/yaml-log-entry/SKILL.md): `plugins/tksfw/skills/yaml-log-entry/SKILL.md`
- [Ledger validation](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/skills/yaml-log-entry/assets/validate_yaml_log.py): `plugins/tksfw/skills/yaml-log-entry/assets/validate_yaml_log.py`
- [Project ledgers](https://github.com/ibm/tksfw/tree/main/template/.agents/workarea): `template/.agents/workarea`
- [Turn-end checks](https://github.com/ibm/tksfw/blob/main/plugins/tksfw/hooks/check_ledgers_on_stop.py): `plugins/tksfw/hooks/check_ledgers_on_stop.py`

### Harness integrations

- [Optional MCP tools](https://github.com/ibm/tksfw/tree/main/plugins/tksfw-tools): `plugins/tksfw-tools`

### Other components

- **Human operator**
- **Agent harness**

## Connections

- Human operator → Project initializer: initializes project (evidence: `README.md`)
- Project initializer → Project method: instantiates method (evidence: `README.md`)
- Human operator → Agent harness: works in (evidence: `README.md`)
- Agent harness → Context injection: starts session (evidence: `plugins/tksfw/hooks/inject_state.py`)
- Context injection → State projection: refreshes state (evidence: `plugins/tksfw/hooks/inject_state.py`)
- Context injection → Layer resolver: resolves layers (evidence: `plugins/tksfw/hooks/inject_state.py`)
- Agent harness → Model routing: dispatches delegation (evidence: `plugins/tksfw/hooks/route_model.py`)
- Model routing → Subagent tracking: checks live agents (evidence: `plugins/tksfw/hooks/route_model.py`)
- Agent definitions → Model routing: provides agent tier (evidence: `plugins/tksfw/hooks/agentlib.py`)
- Human operator → Work delegation: delegates work (evidence: `README.md`)
- Agent harness → Edit tracking: tracks edits (evidence: `plugins/tksfw/hooks/track_edits.py`)
- Edit tracking → Ledger validation: validates ledgers (evidence: `plugins/tksfw/hooks/track_edits.py`)
- Edit tracking → Project ledgers: journals changes (evidence: `plugins/tksfw/hooks/track_edits.py`)
- Human operator → Ledger operations: records work (evidence: `README.md`)
- Ledger operations → Project ledgers: updates ledgers (evidence: `README.md`)
- Agent harness → Turn-end checks: checks turn end (evidence: `plugins/tksfw/hooks/check_ledgers_on_stop.py`)
- Turn-end checks → Project ledgers: checks completeness (evidence: `plugins/tksfw/hooks/check_ledgers_on_stop.py`)
- Agent harness → Session cleanup: ends session (evidence: `plugins/tksfw/hooks/session_end.py`)
- Session cleanup → Subagent tracking: clears live set (evidence: `plugins/tksfw/hooks/session_end.py`)
- Agent harness → Optional MCP tools: optionally uses (evidence: `README.md`)
