|
| 1 | +# Agent‑Centric CLI MVP — Living Test Script |
| 2 | + |
| 3 | +> **Purpose** |
| 4 | +> This document defines a _machine‑verifiable_ MVP for the Human Pattern Lab CLI. |
| 5 | +> The goal is to prove that **agents** (not humans) can authenticate, publish, |
| 6 | +> explain, and respect governance boundaries — deterministically and audibly. |
| 7 | +> |
| 8 | +> Human UX, lore, mascots, and ritual layers intentionally sit _above_ this substrate. |
| 9 | +
|
| 10 | +--- |
| 11 | + |
| 12 | +## Core Design Principles |
| 13 | + |
| 14 | +- **Agents first**: The CLI must be safely operable without human interaction. |
| 15 | +- **Deterministic output**: With identical inputs and fixed clock, JSON output must be identical. |
| 16 | +- **Explicit intent**: Every write, destructive action, or auth mutation declares intent. |
| 17 | +- **Governance by default**: Human‑owned or published content cannot be silently altered. |
| 18 | +- **Auditability**: Reasoning, assumptions, and provenance are first‑class citizens. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Conventions |
| 23 | + |
| 24 | +- `--json` guarantees **machine‑only output** (no banners, no logs, no spinners). |
| 25 | +- All JSON responses share a **stable envelope**: |
| 26 | + |
| 27 | +```json |
| 28 | +{ |
| 29 | + "ok": boolean, |
| 30 | + "ts": string, |
| 31 | + "intent": { "id": string, "scope": string }, |
| 32 | + "result": object | null, |
| 33 | + "warnings": string[], |
| 34 | + "errors": { "code": string, "message": string }[] |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +- Exit codes align with `ok` status. |
| 39 | +- CLI name assumed: `hpl` (replace as needed). |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## 0. Identity & Environment Bootstrap |
| 44 | + |
| 45 | +```bash |
| 46 | +hpl whoami --json |
| 47 | +``` |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "ok": true, |
| 52 | + "ts": "2025-12-30T13:05:00.000Z", |
| 53 | + "intent": { "id": "intent.whoami.v1", "scope": "identity:read" }, |
| 54 | + "result": { |
| 55 | + "principal": { "kind": "agent", "id": "agent:scms-copilot-01" }, |
| 56 | + "workspace": "thehumanpatternlab", |
| 57 | + "cli_version": "0.1.0", |
| 58 | + "config_profile": "default" |
| 59 | + }, |
| 60 | + "warnings": [], |
| 61 | + "errors": [] |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## 1. Autonomous Authentication |
| 68 | + |
| 69 | +### 1.1 Non‑Interactive Login |
| 70 | + |
| 71 | +```bash |
| 72 | +hpl auth login \ |
| 73 | + --client-id "$HPL_CLIENT_ID" \ |
| 74 | + --client-secret "$HPL_CLIENT_SECRET" \ |
| 75 | + --audience "labnotes" \ |
| 76 | + --scopes "labnotes:write labnotes:draft labnotes:read" \ |
| 77 | + --json |
| 78 | +``` |
| 79 | + |
| 80 | +```json |
| 81 | +{ |
| 82 | + "ok": true, |
| 83 | + "ts": "2025-12-30T13:05:10.000Z", |
| 84 | + "intent": { "id": "intent.auth.login.v1", "scope": "auth:write" }, |
| 85 | + "result": { |
| 86 | + "token": { |
| 87 | + "type": "bearer", |
| 88 | + "scopes": ["labnotes:read", "labnotes:write", "labnotes:draft"], |
| 89 | + "expires_at": "2025-12-30T14:05:10.000Z" |
| 90 | + }, |
| 91 | + "storage": { "kind": "keychain|file", "path": ".hpl/tokens.json" } |
| 92 | + }, |
| 93 | + "warnings": [], |
| 94 | + "errors": [] |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +### 1.2 Refresh Without Human Intervention |
| 99 | + |
| 100 | +```bash |
| 101 | +hpl auth refresh --json |
| 102 | +``` |
| 103 | + |
| 104 | +### 1.3 Revocation Enforcement |
| 105 | + |
| 106 | +```bash |
| 107 | +hpl auth status --json |
| 108 | +``` |
| 109 | + |
| 110 | +```json |
| 111 | +{ |
| 112 | + "ok": false, |
| 113 | + "ts": "2025-12-30T13:06:00.000Z", |
| 114 | + "intent": { "id": "intent.auth.status.v1", "scope": "auth:read" }, |
| 115 | + "result": null, |
| 116 | + "warnings": [], |
| 117 | + "errors": [ |
| 118 | + { |
| 119 | + "code": "AUTH_REVOKED", |
| 120 | + "message": "Token has been revoked; re-authentication required." |
| 121 | + } |
| 122 | + ] |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +## 2. Health Checks (Machine‑Readable) |
| 129 | + |
| 130 | +```bash |
| 131 | +hpl health --json |
| 132 | +``` |
| 133 | + |
| 134 | +```json |
| 135 | +{ |
| 136 | + "ok": true, |
| 137 | + "ts": "2025-12-30T13:06:10.000Z", |
| 138 | + "intent": { "id": "intent.health.v1", "scope": "system:read" }, |
| 139 | + "result": { |
| 140 | + "auth": { "ok": true, "principal": "agent:scms-copilot-01" }, |
| 141 | + "db": { "ok": true, "driver": "sqlite", "path": "./lab.db" }, |
| 142 | + "schema": { "ok": true, "version": 2, "integrity": "ok" } |
| 143 | + }, |
| 144 | + "warnings": [], |
| 145 | + "errors": [] |
| 146 | +} |
| 147 | +``` |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## 3. Publishing Markdown Notes (Draft‑First) |
| 152 | + |
| 153 | +```bash |
| 154 | +hpl labnotes draft create \ |
| 155 | + --slug "agent-field-report-0001" \ |
| 156 | + --title "Agent Field Report #0001" \ |
| 157 | + --type "labnote" \ |
| 158 | + --department-id "SCMS" \ |
| 159 | + --locale "en" \ |
| 160 | + --intent-id "intent.labnotes.publish.v1" \ |
| 161 | + --provenance "agent:scms-copilot-01" \ |
| 162 | + --md "./notes/field-report-0001.md" \ |
| 163 | + --json |
| 164 | +``` |
| 165 | + |
| 166 | +```json |
| 167 | +{ |
| 168 | + "ok": true, |
| 169 | + "ts": "2025-12-30T13:06:40.000Z", |
| 170 | + "intent": { "id": "intent.labnotes.publish.v1", "scope": "labnotes:draft" }, |
| 171 | + "result": { |
| 172 | + "note": { |
| 173 | + "id": "uuid-or-content-hash", |
| 174 | + "slug": "agent-field-report-0001", |
| 175 | + "status": "draft", |
| 176 | + "type": "labnote", |
| 177 | + "department_id": "SCMS", |
| 178 | + "locale": "en", |
| 179 | + "created_at": "2025-12-30T13:06:40.000Z", |
| 180 | + "updated_at": "2025-12-30T13:06:40.000Z", |
| 181 | + "content_ref": "lab_note_revisions:rev_000001" |
| 182 | + } |
| 183 | + }, |
| 184 | + "warnings": [], |
| 185 | + "errors": [] |
| 186 | +} |
| 187 | +``` |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## 4. Reasoning & Assumptions (Auditable) |
| 192 | + |
| 193 | +```bash |
| 194 | +hpl labnotes draft annotate \ |
| 195 | + --slug "agent-field-report-0001" \ |
| 196 | + --assumption "User prefers safer_landing=true for new notes." \ |
| 197 | + --assumption "Default shadow_density=3 if unspecified." \ |
| 198 | + --reasoning "./notes/field-report-0001.reasoning.md" \ |
| 199 | + --json |
| 200 | +``` |
| 201 | + |
| 202 | +```json |
| 203 | +{ |
| 204 | + "ok": true, |
| 205 | + "ts": "2025-12-30T13:07:10.000Z", |
| 206 | + "intent": { "id": "intent.labnotes.annotate.v1", "scope": "labnotes:draft" }, |
| 207 | + "result": { |
| 208 | + "annotation": { |
| 209 | + "note_slug": "agent-field-report-0001", |
| 210 | + "assumptions": [ |
| 211 | + "User prefers safer_landing=true for new notes.", |
| 212 | + "Default shadow_density=3 if unspecified." |
| 213 | + ], |
| 214 | + "reasoning_ref": "lab_note_revisions:reasoning_000001" |
| 215 | + } |
| 216 | + }, |
| 217 | + "warnings": [], |
| 218 | + "errors": [] |
| 219 | +} |
| 220 | +``` |
| 221 | + |
| 222 | +--- |
| 223 | + |
| 224 | +## 5. Governance Boundaries (No Human Overwrites) |
| 225 | + |
| 226 | +```bash |
| 227 | +hpl labnotes edit \ |
| 228 | + --slug "the-quiet-flame" \ |
| 229 | + --set-title "The Quiet Flame (agent edit attempt)" \ |
| 230 | + --json |
| 231 | +``` |
| 232 | + |
| 233 | +```json |
| 234 | +{ |
| 235 | + "ok": false, |
| 236 | + "ts": "2025-12-30T13:07:30.000Z", |
| 237 | + "intent": { "id": "intent.labnotes.edit.v1", "scope": "labnotes:write" }, |
| 238 | + "result": null, |
| 239 | + "warnings": [], |
| 240 | + "errors": [ |
| 241 | + { |
| 242 | + "code": "GOVERNANCE_DENIED", |
| 243 | + "message": "Cannot modify human-owned or published notes without explicit override policy." |
| 244 | + } |
| 245 | + ] |
| 246 | +} |
| 247 | +``` |
| 248 | + |
| 249 | +--- |
| 250 | + |
| 251 | +## 6. Draft Lifecycle Management |
| 252 | + |
| 253 | +### Update Draft |
| 254 | + |
| 255 | +```bash |
| 256 | +hpl labnotes draft update \ |
| 257 | + --slug "agent-field-report-0001" \ |
| 258 | + --md "./notes/field-report-0001.v2.md" \ |
| 259 | + --json |
| 260 | +``` |
| 261 | + |
| 262 | +### Mark Ready for Human Review |
| 263 | + |
| 264 | +```bash |
| 265 | +hpl labnotes draft ready \ |
| 266 | + --slug "agent-field-report-0001" \ |
| 267 | + --reviewer "human:ada" \ |
| 268 | + --json |
| 269 | +``` |
| 270 | + |
| 271 | +```json |
| 272 | +{ |
| 273 | + "ok": true, |
| 274 | + "ts": "2025-12-30T13:08:10.000Z", |
| 275 | + "intent": { "id": "intent.labnotes.ready.v1", "scope": "labnotes:draft" }, |
| 276 | + "result": { |
| 277 | + "note": { |
| 278 | + "slug": "agent-field-report-0001", |
| 279 | + "status": "ready_for_review", |
| 280 | + "review": { "requested_from": "human:ada" } |
| 281 | + } |
| 282 | + }, |
| 283 | + "warnings": [], |
| 284 | + "errors": [] |
| 285 | +} |
| 286 | +``` |
| 287 | + |
| 288 | +--- |
| 289 | + |
| 290 | +## 7. Destructive Actions Require Explicit Acknowledgement |
| 291 | + |
| 292 | +### Attempt Without Force (Fails) |
| 293 | + |
| 294 | +```bash |
| 295 | +hpl labnotes delete --slug "agent-field-report-0001" --json |
| 296 | +``` |
| 297 | + |
| 298 | +```json |
| 299 | +{ |
| 300 | + "ok": false, |
| 301 | + "ts": "2025-12-30T13:08:30.000Z", |
| 302 | + "intent": { "id": "intent.labnotes.delete.v1", "scope": "labnotes:write" }, |
| 303 | + "result": null, |
| 304 | + "warnings": [], |
| 305 | + "errors": [ |
| 306 | + { |
| 307 | + "code": "DESTRUCTIVE_REQUIRES_FLAG", |
| 308 | + "message": "Deletion requires --force and --intent-id acknowledgement." |
| 309 | + } |
| 310 | + ] |
| 311 | +} |
| 312 | +``` |
| 313 | + |
| 314 | +### Explicit Delete |
| 315 | + |
| 316 | +```bash |
| 317 | +hpl labnotes delete \ |
| 318 | + --slug "agent-field-report-0001" \ |
| 319 | + --force \ |
| 320 | + --intent-id "intent.labnotes.delete.v1" \ |
| 321 | + --json |
| 322 | +``` |
| 323 | + |
| 324 | +--- |
| 325 | + |
| 326 | +## 8. Deterministic Output Proof |
| 327 | + |
| 328 | +```bash |
| 329 | +hpl labnotes draft create ... \ |
| 330 | + --clock "fixed:2025-12-30T13:06:40.000Z" \ |
| 331 | + --json > out1.json |
| 332 | + |
| 333 | +hpl labnotes draft create ... \ |
| 334 | + --clock "fixed:2025-12-30T13:06:40.000Z" \ |
| 335 | + --json > out2.json |
| 336 | + |
| 337 | +diff out1.json out2.json |
| 338 | +``` |
| 339 | + |
| 340 | +> The diff **must be empty**. |
| 341 | +
|
| 342 | +--- |
| 343 | + |
| 344 | +## 9. Sandbox / Dry‑Run Mode |
| 345 | + |
| 346 | +```bash |
| 347 | +hpl labnotes draft create ... --dry-run --json |
| 348 | +``` |
| 349 | + |
| 350 | +```json |
| 351 | +{ |
| 352 | + "ok": true, |
| 353 | + "ts": "2025-12-30T13:09:10.000Z", |
| 354 | + "intent": { "id": "intent.labnotes.publish.v1", "scope": "labnotes:draft" }, |
| 355 | + "result": { |
| 356 | + "simulated": true, |
| 357 | + "would_create": { |
| 358 | + "slug": "agent-field-report-0002", |
| 359 | + "status": "draft" |
| 360 | + } |
| 361 | + }, |
| 362 | + "warnings": ["DRY_RUN_NO_CHANGES_MADE"], |
| 363 | + "errors": [] |
| 364 | +} |
| 365 | +``` |
| 366 | + |
| 367 | +--- |
| 368 | + |
| 369 | +## Summary |
| 370 | + |
| 371 | +If an agent can: |
| 372 | + |
| 373 | +- authenticate without humans, |
| 374 | +- publish markdown safely, |
| 375 | +- declare intent explicitly, |
| 376 | +- explain its reasoning, |
| 377 | +- respect governance boundaries, |
| 378 | +- emit deterministic JSON, |
| 379 | +- and survive health checks, |
| 380 | + |
| 381 | +then the CLI MVP is **successful**. |
| 382 | + |
| 383 | +Everything else — UI polish, lore, onboarding, mascots, ritual — is additive. |
0 commit comments