Skip to content

Commit 2723f64

Browse files
Merge pull request #2 from rayyagari2-create/sprint-3/trust-subject-schema
Sprint 3 - Trust Subject Schema + Design Doc Alignment
2 parents 560ba4a + fb8dfaa commit 2723f64

4 files changed

Lines changed: 147 additions & 15 deletions

File tree

‎docs/adapter-designs/DESIGN-01.md‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ means no observed violation. It does not mean no violation occurred.
350350
| Surface | Value | Notes |
351351
|---|---|---|
352352
| contextInjectionSurface | `rules_file` + `agents_md` | .cursor/rules/*.mdc + AGENTS.md |
353-
| eventSurface | `hook_rich` | 18 hook events including subagentStart/Stop |
353+
| eventSurface | `hook_rich` | ~21 hook events including subagentStart/Stop; includes Tab hooks and workspaceOpen |
354354
| controlSurface | `tool_level` | failClosed: true blocks on hook failure |
355355
| approvalSurface | `pre_tool` + `pre_session` | AWF intake gate + per-tool via hooks |
356356
| artifactSurface | `git_diff` + `pr_url` + `test_results` + `handoff_note` | Cloud agent REST API artifacts |
@@ -361,15 +361,21 @@ means no observed violation. It does not mean no violation occurred.
361361
| sandboxSurface | `sandbox_mode` + `worktree` | --sandbox + --worktree flags |
362362
| trustSubjectType | `agent` | .cursor/agents/ definitions |
363363
| enforcementDepth | `tool_level` | Event-rich, comparable to Claude Code |
364-
| currentEvidenceStrength | E1 | Artifact level until hooks wired to AWF |
365-
| targetEvidenceStrength | E3 | Local hooks / E2 cloud agents (SSE) |
364+
| currentEvidenceStrength | per-mode (see below) | Mode A local: E1 until hooks wired. Mode B cloud: E1 before adapter / E2 after Gate 2 SSE verification. Mode C self-hosted: E1. Mode D human: E1. |
365+
| targetEvidenceStrength | per-mode (see below) | Mode A local: E3 (conditions in DESIGN-06 §8). Mode B cloud: E2 hard ceiling. Mode C self-hosted: E3 pending worker hook test. Mode D human: E3-observed not E3-enforced. |
366366
| requiresRuntimeHookInstall | true | AWF hooks deployed to .cursor/hooks.json |
367-
| supportsFailClosed | true | failClosed: true blocks on hook failure |
367+
| supportsFailClosed | true — requires failClosed: true per blocking hook entry. Default is fail-open. E3 claims require Cursor build >= 2026-05-14 patched release. | See DESIGN-06 §8 |
368368

369369
**Notes:**
370370
- Cloud agent outbound webhooks: "coming soon." Use SSE stream as substitute.
371371
- Cursor is classified event-rich/controlled. Closer to Claude Code than Codex.
372372

373+
**Known gaps:**
374+
- Fail-closed requires explicit per-hook opt-in; default is fail-open.
375+
- E3 claims require Cursor build >= 2026-05-14 patch.
376+
- SDK has no canUseTool-equivalent; hooks are the only synchronous enforcement path.
377+
- Enterprise audit log is admin-action only, not a tool-call audit surface.
378+
373379
---
374380

375381
### Devin

‎docs/adapter-designs/DESIGN-02.md‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ OpenClaw (sub-agents via ACP)
7979

8080
**subject_key pattern:**
8181
```
82-
{runtime}::subagent::{parent_agent_id}::{task_class}::{session_id}
82+
{runtime}::subagent::{parent_agent_id}::{task_class}::{workspace}::{repo}::{session_id}
8383
```
8484

8585
**Examples:**
@@ -148,7 +148,7 @@ No internal agent decomposition is visible to AWF.
148148

149149
**subject_key pattern:**
150150
```
151-
{runtime}::session::{workspace}::{task_type}::{playbook_or_config}
151+
{runtime}::session::{workspace}::{repo}::{task_type}::{playbook_or_config}
152152
```
153153

154154
**Examples:**
@@ -215,7 +215,7 @@ not an autonomous agent's behavior.
215215

216216
**subject_key pattern:**
217217
```
218-
{runtime}::human::{human_actor_id}::{workspace}::{task_type}
218+
{runtime}::human::{human_actor_id}::{workspace}::{repo}::{task_type}
219219
```
220220

221221
**Examples:**
@@ -348,11 +348,11 @@ the same subject_key.
348348
| Trust type | Stable components | Unstable (exclude) |
349349
|---|---|---|
350350
| agent | runtime, "agent", agent_name, workspace | session_id, run_id |
351-
| subagent | runtime, "subagent", parent_agent_id, task_class, session_id | run_id |
352-
| role_profile | runtime, role, workspace, task_type, risk_lane, sandbox_mode, skill_set | session_id |
353-
| session | runtime, "session", workspace, task_type, playbook | session_id, run_id |
351+
| subagent | runtime, "subagent", parent_agent_id, task_class, workspace, repo, session_id | run_id |
352+
| role_profile | runtime, role, workspace, repo, task_type, risk_lane, sandbox_mode, skill_set | session_id |
353+
| session | runtime, "session", workspace, repo, task_type, playbook | session_id, run_id |
354354
| graph_node | "langgraph", graph_id, node_name, workspace | invocation_id |
355-
| human_runtime | runtime, "human", human_actor_id, workspace, task_type | session_id |
355+
| human_runtime | runtime, "human", human_actor_id, workspace, repo, task_type | session_id |
356356
| task | runtime, "task", workspace, task_class, work_item_id | run_id |
357357

358358
---
@@ -409,7 +409,7 @@ confidence in a STANDARD tier (not enough sessions to be certain).
409409
An agent-srv with HIGH trust on Claude Code starts PROVISIONAL on Codex.
410410

411411
2. **Trust subjects are runtime-scoped.**
412-
`claude_code::agent::agent-srv::ruvoni` and `codex::worker::ruvoni::backend::medium-risk::workspace-write`
412+
`claude_code::agent::agent-srv::ruvoni::family-trip-ai` and `codex::worker::ruvoni::family-trip-ai::backend::medium-risk::workspace-write::backend-skill`
413413
are different trust subjects even if they represent the same "backend agent concept."
414414

415415
3. **Workspace isolation is enforced.**
@@ -433,6 +433,11 @@ confidence in a STANDARD tier (not enough sessions to be certain).
433433
trust subject was created. It covers agent instruction files, role TOML configs,
434434
Devin playbook content and skill_set composition.
435435

436+
config_hash covers agent/role/playbook definition, allowed tools, skill set,
437+
sandbox mode, and governance-relevant runtime config. Changing allowed tools
438+
or sandbox mode resets the confidence band even if the prompt definition is
439+
unchanged.
440+
436441
**When config_hash changes:**
437442
- The trust_subject_id remains the same (history is preserved)
438443
- confidence_band resets to LOW unless the change is verified cosmetic
@@ -449,8 +454,10 @@ Devin playbook content and skill_set composition.
449454

450455
## Open Questions
451456

452-
1. Should subagent trust_subject_id accumulate across sessions for named subagents in Claude Code?
453-
Currently specified as session-scoped. Needs decision.
457+
1. OQ-1 RESOLVED: Subagent trust remains session-scoped by default. If a runtime exposes
458+
persistent named subagents with stable definitions and reliable lifecycle events, AWF may
459+
promote them to agent trust subjects in a future adapter version. Until then, subagents are
460+
contributing subjects only, not long-lived primary trust subjects.
454461
2. For Codex role_profile subjects, if the .codex/agents/*.toml file is modified mid-sprint,
455462
should config_hash check fire before or after session start?
456463
3. LangGraph: should graph_node trust_subject_id be per-graph version or per-graph-name?

‎schemas/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
Generic, product-agnostic JSON Schemas for the Agentic Workforce Framework.
44
All schemas are written for **AJV with JSON Schema Draft 2020-12**.
55

6-
These schemas describe five governance artifacts that any single-workspace
6+
These schemas describe six governance artifacts that any single-workspace
77
deployment must produce and consume:
88

99
- **AgentTaskManifest** the dispatch contract. No manifest = no dispatch.
1010
- **QAVerdict** structured QA result with defect classification and trust impact.
1111
- **FailureRecord** entry in the self-learning failure library (17-class taxonomy).
1212
- **TrustScore** D1-D4 session score plus the 8-dimension long-term profile.
13+
- **TrustSubject** accountable identity AWF scores: agent, subagent, role_profile, session, graph_node, human_runtime, or task (DESIGN-02).
1314

1415
## v1 schemas (current)
1516

@@ -19,6 +20,7 @@ deployment must produce and consume:
1920
| [`v1/qa-verdict.schema.json`](v1/qa-verdict.schema.json) | `QAVerdict` | Structured QA verdict with per-finding evidence and trust delta |
2021
| [`v1/failure-record.schema.json`](v1/failure-record.schema.json) | `FailureRecord` | 17-class taxonomy, recurrence count, prevention artifacts, agents involved |
2122
| [`v1/trust-score.schema.json`](v1/trust-score.schema.json) | `TrustScore` | D1-D4 session score plus 8-dimension continuous profile, trust tier, confidence band |
23+
| [`v1/trust-subject.schema.json`](v1/trust-subject.schema.json) | `TrustSubject` | Accountable trust subject (agent, subagent, role_profile, session, graph_node, human_runtime, task) with subject_key construction rules, config_hash, archive lifecycle (DESIGN-02) |
2224
| [AgentSpawnSidecar](v1/agent-spawn-sidecar.schema.json) | Hook-readable spawn authorization record. Written by the Orchestrator before Agent tool call. Validated by PreToolUse hook. The enforcement artifact for agent spawn governance. |
2325

2426
> **Schema dependency:** The AgentSpawnSidecar schema is the
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://github.com/agentic-workforce-framework/schemas/v1/trust-subject.schema.json",
4+
"title": "TrustSubject",
5+
"description": "Accountable trust subject for every unit of agentic work. The trust subject is what AWF actually scores, replacing the V4.3 assumption that every runtime exposes a stable agent identity. The subject_type is determined by what the runtime exposes (agent, subagent, role_profile, session, graph_node, human_runtime, or task), not by what we would prefer it to expose. Trust subjects are runtime-scoped, workspace-isolated, and immutable once created (archive, never delete). See DESIGN-02 (Trust Subject Model) for the full specification.",
6+
"version": "1.0",
7+
"type": "object",
8+
"required": [
9+
"id",
10+
"subject_type",
11+
"runtime_provider",
12+
"subject_key",
13+
"workspace_id",
14+
"created_at"
15+
],
16+
"properties": {
17+
"id": {
18+
"type": "string",
19+
"format": "uuid",
20+
"description": "Immutable UUID primary key. Once assigned, this value never changes. Failure records and capability profiles reference this id. To retire a subject, set archived_at — do not delete."
21+
},
22+
"subject_type": {
23+
"type": "string",
24+
"enum": [
25+
"agent",
26+
"subagent",
27+
"role_profile",
28+
"session",
29+
"graph_node",
30+
"human_runtime",
31+
"task"
32+
],
33+
"description": "Which of the seven trust subject types this row represents. Determined by what the runtime exposes: agent (named agent with stable identity, e.g. Claude Code, Cursor, OpenClaw), subagent (spawned within a session), role_profile (Codex worker/explorer/custom roles), session (Devin, Multica — runtime exposes no internal agent structure), graph_node (LangGraph node/edge with embedded AWF governance), human_runtime (human + runtime pair for IDE-assisted work), task (lowest-granularity fallback when no higher subject type is identifiable)."
34+
},
35+
"runtime_provider": {
36+
"type": "string",
37+
"enum": [
38+
"claude_code",
39+
"codex",
40+
"cursor",
41+
"openclaw",
42+
"devin",
43+
"multica",
44+
"langgraph"
45+
],
46+
"description": "Runtime that produces sessions for this subject. Trust does not transfer across runtimes — the same logical agent on a new runtime starts PROVISIONAL. Implementations may extend this enum when onboarding additional runtimes; doing so does not loosen the per-runtime isolation rule."
47+
},
48+
"subject_key": {
49+
"type": "string",
50+
"pattern": "^[a-z0-9_-]+(::[a-z0-9_-]+)+$",
51+
"maxLength": 200,
52+
"description": "Stable, deterministic identity string for this subject. Same runtime + same config MUST produce the same subject_key. Construction rules: (1) all lowercase; (2) components separated by '::'; (3) no spaces — use hyphens within a component; (4) include only components stable across sessions for this subject_type; (5) maximum 200 characters. Patterns by subject_type — agent: {runtime}::agent::{agent_name}::{workspace}::{repo}; subagent: {runtime}::subagent::{parent_agent_id}::{task_class}::{workspace}::{repo}::{session_id}; role_profile: codex::{role}::{workspace}::{repo}::{task_type}::{risk_lane}::{sandbox_mode}::{skill_set}; session: {runtime}::session::{workspace}::{task_type}::{playbook_or_config}; graph_node: langgraph::{graph_id}::{node_name}::{workspace}; human_runtime: {runtime}::human::{human_actor_id}::{workspace}::{task_type}; task: {runtime}::task::{workspace}::{task_class}::{work_item_id}. Unique per (workspace_id, runtime_provider, subject_key)."
53+
},
54+
"workspace_id": {
55+
"type": "string",
56+
"format": "uuid",
57+
"description": "Workspace this subject belongs to. Trust is workspace-isolated: history accumulated in workspace A does not count toward workspace B, even for the same subject_key string."
58+
},
59+
"repo": {
60+
"type": ["string", "null"],
61+
"description": "Repository scope for this subject. Required for agent and role_profile subject_types when the workspace contains multiple repos — trust must not bleed across repos. Null for subject_types where repo is not part of the key (session, graph_node, task)."
62+
},
63+
"task_type": {
64+
"type": ["string", "null"],
65+
"description": "Task classification this subject is scoped to (e.g. frontend-bugfix, auth-change, database-migration). Part of the subject_key for role_profile, session, and human_runtime types. A subject trusted for one task_type starts PROVISIONAL for a new task_type — see cross-runtime trust rule 4 in DESIGN-02."
66+
},
67+
"risk_lane": {
68+
"type": ["string", "null"],
69+
"description": "Risk lane this subject operates in (e.g. low-risk, medium-risk, high-risk, restricted). Part of the subject_key for role_profile so that the same role at different risk lanes has separate trust history."
70+
},
71+
"sandbox_mode": {
72+
"type": ["string", "null"],
73+
"description": "Sandbox/permission mode the subject runs under (e.g. read-only, workspace-write, full-access). Part of the trust identity for role_profile — a workspace-write role and a read-only role are different subjects even with otherwise identical configuration."
74+
},
75+
"skill_set": {
76+
"type": ["array", "null"],
77+
"items": { "type": "string" },
78+
"description": "Skill bundle composition for this subject (e.g. ['frontend-skill'], ['awf-risk-plan']). Part of the subject_key for role_profile. Changes to skill_set composition are a material configuration change and trigger config_hash recomputation."
79+
},
80+
"human_actor_id": {
81+
"type": ["string", "null"],
82+
"format": "uuid",
83+
"description": "Required and non-null when subject_type is 'human_runtime' — identifies the human driving the IDE-assisted session. Null for all other subject_types. Trust for human_runtime subjects tracks human+runtime productivity patterns and is used for analytics, not autonomy gating."
84+
},
85+
"config_hash": {
86+
"type": ["string", "null"],
87+
"description": "Hash of the underlying configuration (agent instruction file, role TOML, Devin playbook content, skill_set composition) captured at subject creation. Recomputed by the adapter at each session start and compared. When it changes: trust_subject_id remains stable, confidence_band resets to LOW unless the change is verified cosmetic (whitespace, comments, formatting), and a new entry is logged in subject metadata."
88+
},
89+
"subject_version": {
90+
"type": ["string", "null"],
91+
"description": "Human-readable version label for the subject configuration. Bumped for cosmetic changes that keep config_hash unchanged, and also recorded alongside config_hash changes for audit readability."
92+
},
93+
"archived_at": {
94+
"type": ["string", "null"],
95+
"format": "date-time",
96+
"description": "ISO 8601 timestamp when this subject was retired. Subjects are never deleted — archiving preserves history and keeps existing failure records and capability profiles intact. Null while the subject is active."
97+
},
98+
"created_at": {
99+
"type": "string",
100+
"format": "date-time",
101+
"description": "ISO 8601 timestamp when the subject row was created."
102+
}
103+
},
104+
"additionalProperties": false,
105+
"$defs": {
106+
"trustLevel": {
107+
"type": "string",
108+
"enum": ["PROVISIONAL", "RESTRICTED", "STANDARD", "HIGH", "PROBATION"],
109+
"description": "Autonomy tier derived from total D1-D4 score across recent sessions, attached to the trust subject (not to a session). PROVISIONAL (<60): read-only analysis, every task needs human approval — new subjects always start here. RESTRICTED (60-74): draft plans and draft PRs only, human reviews before merge, 3+ sessions to exit. STANDARD (75-89): PR creation allowed after CI, no high-risk files without approval, 5+ sessions at STANDARD to reach HIGH. HIGH (90-100): low-risk task lane, human merge approval still required (Invariant 5 — never waived). PROBATION (any session <40): immediate demotion regardless of prior tier, 3 consecutive clean sessions required to exit. Lives on trust_capability_profiles, not on the trust_subject row itself — defined here for cross-schema reuse."
110+
},
111+
"evidenceStrength": {
112+
"type": "string",
113+
"enum": ["E0", "E1", "E2", "E3"],
114+
"description": "Strength of evidence backing a trust assessment. E0: post-hoc / session-outcome only (Devin, Multica when AWF runs above it). E1: session-outcome plus surfaced telemetry. E2: per-decision evidence from runtime hooks. E3: full per-action evidence including pre-tool and post-tool hook coverage. Lives on trust_capability_profiles — defined here for cross-schema reuse."
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)