hadara 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +49 -34
  2. package/dist/cli/context.js +110 -0
  3. package/dist/cli/help.js +6 -7
  4. package/dist/cli/init.js +56 -58
  5. package/dist/cli/main.js +12 -0
  6. package/dist/cli/session.js +37 -0
  7. package/dist/cli/task.js +52 -0
  8. package/dist/context/code-graph-extractor.js +123 -0
  9. package/dist/context/code-index.js +1154 -0
  10. package/dist/context/context-cache-store.js +925 -0
  11. package/dist/context/context-graph-builder.js +341 -0
  12. package/dist/context/context-graph.js +42 -0
  13. package/dist/context/context-pack.js +457 -0
  14. package/dist/context/context-slice-boundary.js +37 -0
  15. package/dist/context/context-slice.js +487 -0
  16. package/dist/context/document-extractors.js +343 -0
  17. package/dist/context/evidence-extractors.js +179 -0
  18. package/dist/context/extractor-contract.js +166 -0
  19. package/dist/context/registry-extractors.js +177 -0
  20. package/dist/context/release-extractors.js +175 -0
  21. package/dist/context/session-start.js +297 -0
  22. package/dist/context/source-manifest.js +566 -0
  23. package/dist/context/state-projection.js +209 -0
  24. package/dist/context/task-extractors.js +168 -0
  25. package/dist/core/schema.js +26 -0
  26. package/dist/harness/validate.js +7 -8
  27. package/dist/schemas/code-index.schema.json +173 -0
  28. package/dist/schemas/context-cache-record.schema.json +56 -0
  29. package/dist/schemas/context-cache-status.schema.json +167 -0
  30. package/dist/schemas/context-cache-warm.schema.json +222 -0
  31. package/dist/schemas/context-graph.schema.json +286 -0
  32. package/dist/schemas/context-pack.schema.json +246 -0
  33. package/dist/schemas/context-slice.schema.json +94 -0
  34. package/dist/schemas/context-source-manifest.schema.json +147 -0
  35. package/dist/schemas/schema-index.json +91 -0
  36. package/dist/schemas/session-start.schema.json +158 -0
  37. package/dist/schemas/task-close-repair-plan.schema.json +67 -0
  38. package/dist/schemas/task-context.schema.json +125 -0
  39. package/dist/schemas/task-finalize.schema.json +98 -0
  40. package/dist/schemas/task-lifecycle.schema.json +84 -0
  41. package/dist/services/capability-registry.js +266 -9
  42. package/dist/services/lifecycle-guide.js +23 -29
  43. package/dist/services/protocol-consistency.js +6 -8
  44. package/dist/services/workbench-next-actions.js +2 -0
  45. package/dist/task/acceptance.js +171 -0
  46. package/dist/task/task-close-repair-plan.js +190 -0
  47. package/dist/task/task-close.js +34 -35
  48. package/dist/task/task-finalize.js +377 -0
  49. package/dist/task/task-lifecycle.js +210 -0
  50. package/dist/task/task-next.js +10 -1
  51. package/dist/task/task-ready.js +4 -0
  52. package/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "hadara.task.finalize.v1",
4
+ "x-hadara-schema-id": "hadara.task.finalize.v1",
5
+ "type": "object",
6
+ "additionalProperties": true,
7
+ "required": ["schemaVersion", "command", "ok", "readOnly", "mode", "taskId", "generatedAt", "actor", "summary", "steps", "nextActions", "issues"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "hadara.task.finalize.v1" },
10
+ "command": { "const": "task.finalize" },
11
+ "ok": { "type": "boolean" },
12
+ "readOnly": { "type": "boolean" },
13
+ "mode": { "enum": ["dry-run", "execute", "execute-refused"] },
14
+ "taskId": { "type": "string" },
15
+ "generatedAt": { "type": "string" },
16
+ "actor": { "type": "object", "additionalProperties": true },
17
+ "planHash": { "type": "string" },
18
+ "summary": {
19
+ "type": "object",
20
+ "additionalProperties": true,
21
+ "required": ["steps", "required", "blocked", "satisfied", "executeSupported"],
22
+ "properties": {
23
+ "steps": { "type": "number" },
24
+ "required": { "type": "number" },
25
+ "blocked": { "type": "number" },
26
+ "satisfied": { "type": "number" },
27
+ "executeSupported": { "type": "boolean" },
28
+ "evaluatedReports": { "type": "array", "items": { "type": "string" } },
29
+ "skippedReports": { "type": "array", "items": { "type": "string" } }
30
+ }
31
+ },
32
+ "steps": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "object",
36
+ "additionalProperties": true,
37
+ "required": ["id", "status", "summary", "command", "mode", "writeBoundary", "expectedWritePaths", "alreadySatisfied", "sourceReport"],
38
+ "properties": {
39
+ "id": { "enum": ["finish", "ready", "close", "audit-close"] },
40
+ "status": { "enum": ["satisfied", "required", "blocked", "pending", "unknown"] },
41
+ "summary": { "type": "string" },
42
+ "command": { "type": "string" },
43
+ "mode": { "enum": ["dry-run", "execute", "read-only"] },
44
+ "writeBoundary": { "enum": ["read-only", "task-local", "evidence-append"] },
45
+ "expectedWritePaths": { "type": "array", "items": { "type": "string" } },
46
+ "alreadySatisfied": { "type": "boolean" },
47
+ "sourceReport": { "type": "string" }
48
+ }
49
+ }
50
+ },
51
+ "execution": {
52
+ "type": "object",
53
+ "additionalProperties": true,
54
+ "required": ["planHashMatched", "executedSteps"],
55
+ "properties": {
56
+ "requestedPlanHash": { "type": "string" },
57
+ "currentPlanHash": { "type": "string" },
58
+ "planHashMatched": { "type": "boolean" },
59
+ "stoppedAt": { "enum": ["finish", "ready", "close", "audit-close"] },
60
+ "executedSteps": {
61
+ "type": "array",
62
+ "items": {
63
+ "type": "object",
64
+ "additionalProperties": true,
65
+ "required": ["id", "status", "command", "ok", "reportHash", "summary", "writeBoundary"],
66
+ "properties": {
67
+ "id": { "enum": ["finish", "ready", "close", "audit-close"] },
68
+ "status": { "enum": ["executed", "satisfied", "blocked", "skipped"] },
69
+ "command": { "type": "string" },
70
+ "ok": { "type": "boolean" },
71
+ "reportHash": { "type": "string" },
72
+ "summary": { "type": "string" },
73
+ "writeBoundary": { "enum": ["read-only", "task-local", "evidence-append"] }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ },
79
+ "primaryNextAction": { "type": "object", "additionalProperties": true },
80
+ "nextActions": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
81
+ "issues": {
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "additionalProperties": true,
86
+ "required": ["severity", "code", "message"],
87
+ "properties": {
88
+ "severity": { "enum": ["error", "warning", "info"] },
89
+ "code": { "type": "string" },
90
+ "message": { "type": "string" },
91
+ "path": { "type": "string" },
92
+ "fixHint": { "type": "string" },
93
+ "example": { "type": "string" }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,84 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "hadara.task.lifecycle.v1",
4
+ "x-hadara-schema-id": "hadara.task.lifecycle.v1",
5
+ "type": "object",
6
+ "additionalProperties": true,
7
+ "required": ["schemaVersion", "command", "ok", "readOnly", "taskId", "generatedAt", "actor", "phase", "checks", "satisfied", "blockers", "nextActions", "issues"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "hadara.task.lifecycle.v1" },
10
+ "command": { "const": "task.lifecycle" },
11
+ "ok": { "type": "boolean" },
12
+ "readOnly": { "const": true },
13
+ "taskId": { "type": "string" },
14
+ "generatedAt": { "type": "string" },
15
+ "actor": {
16
+ "type": "object",
17
+ "additionalProperties": true,
18
+ "required": ["agentId", "runId", "role", "parentRunId"],
19
+ "properties": {
20
+ "agentId": { "type": "string" },
21
+ "runId": { "type": "string" },
22
+ "role": { "enum": ["operator", "coordinator", "worker", "reviewer", "unknown"] },
23
+ "parentRunId": { "type": ["string", "null"] }
24
+ }
25
+ },
26
+ "phase": {
27
+ "enum": ["draft", "in-progress", "finish-required", "ready-required", "close-required", "audit-required", "closed-valid", "repair-required", "blocked", "unknown"]
28
+ },
29
+ "checks": {
30
+ "type": "object",
31
+ "additionalProperties": true,
32
+ "required": ["finish", "sharedDocs", "ready", "close", "audit"],
33
+ "properties": {
34
+ "finish": { "$ref": "#/$defs/check" },
35
+ "sharedDocs": { "$ref": "#/$defs/check" },
36
+ "ready": { "$ref": "#/$defs/check" },
37
+ "close": { "$ref": "#/$defs/check" },
38
+ "audit": { "$ref": "#/$defs/check" }
39
+ }
40
+ },
41
+ "satisfied": { "type": "array", "items": { "type": "string" } },
42
+ "blockers": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "object",
46
+ "additionalProperties": true,
47
+ "required": ["code", "severity", "summary"],
48
+ "properties": {
49
+ "code": { "type": "string" },
50
+ "severity": { "enum": ["error", "warning"] },
51
+ "summary": { "type": "string" },
52
+ "command": { "type": "string" }
53
+ }
54
+ }
55
+ },
56
+ "repair": {
57
+ "type": "object",
58
+ "additionalProperties": true,
59
+ "required": ["classification", "summary", "sourceReport"],
60
+ "properties": {
61
+ "classification": { "enum": ["not-closed", "closed-stale", "closed-invalid", "duplicate-close-proof", "closed-valid", "unknown"] },
62
+ "summary": { "type": "string" },
63
+ "nextCommand": { "type": "string" },
64
+ "sourceReport": { "const": "hadara.task.audit_close.v1" }
65
+ }
66
+ },
67
+ "primaryNextAction": { "type": "object", "additionalProperties": true },
68
+ "nextActions": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
69
+ "issues": { "type": "array", "items": { "type": "object", "additionalProperties": true } }
70
+ },
71
+ "$defs": {
72
+ "check": {
73
+ "type": "object",
74
+ "additionalProperties": true,
75
+ "required": ["status", "summary", "sourceReport"],
76
+ "properties": {
77
+ "status": { "enum": ["satisfied", "required", "blocked", "warning", "pending", "unknown"] },
78
+ "summary": { "type": "string" },
79
+ "sourceReport": { "type": "string" },
80
+ "command": { "type": "string" }
81
+ }
82
+ }
83
+ }
84
+ }
@@ -338,18 +338,93 @@ exports.HADARA_COMMAND_REGISTRY = [
338
338
  examples: [example('Show completion guide', 'hadara task complete --task T-0001 --json', 'When debugging the task close loop.')],
339
339
  related: ['task.finish', 'task.ready', 'task.close', 'task.audit-close'],
340
340
  conflictsWith: [],
341
- notes: 'Primary lifecycle help should show the explicit finish/ready/close/audit sequence.'
341
+ notes: 'Legacy read-only workflow compressor. Primary lifecycle help should show the 0.3.3 finalize-first path.'
342
+ },
343
+ {
344
+ id: 'task.finalize',
345
+ command: 'hadara task finalize --task <task-id> [--execute --plan-hash <hash>] [--json]',
346
+ summary: 'Create a reviewed finalize plan or execute the matching plan through the guarded lifecycle sequence.',
347
+ canonical: true,
348
+ appearsInDefaultHelp: true,
349
+ family: 'capsule-lifecycle',
350
+ scope: 'capsule',
351
+ lifecycleStage: 'finalize',
352
+ requiredness: 'primary',
353
+ writeBoundary: 'task-status-bookkeeping',
354
+ readOnly: false,
355
+ risk: 'medium',
356
+ actor: 'agent-worker',
357
+ status: 'stable',
358
+ schemaVersion: 'hadara.task.finalize.v1',
359
+ docs: TASK_DOCS,
360
+ implementationFiles: ['src/cli/task.ts', 'src/task/task-finalize.ts'],
361
+ testFiles: ['tests/unit/task-finalize.test.ts'],
362
+ examples: [
363
+ example('Review finalize plan', 'hadara task finalize --task T-0001 --json', 'When an agent wants one reviewed finish/ready/close/audit plan before executing the default close path.'),
364
+ example('Execute reviewed finalize plan', 'hadara task finalize --task T-0001 --execute --plan-hash sha256:... --json', 'After reviewing a current dry-run plan hash.')
365
+ ],
366
+ related: ['task.lifecycle', 'task.finish', 'task.ready', 'task.close', 'task.audit-close'],
367
+ conflictsWith: [],
368
+ notes: 'Default mode is read-only. Execute requires a matching current dry-run plan hash, runs phases serially, preserves the underlying finish/close write boundaries, and stops on the first blocker.'
369
+ },
370
+ {
371
+ id: 'task.lifecycle',
372
+ command: 'hadara task lifecycle --task <task-id> [--json]',
373
+ summary: 'Read normalized lifecycle phase, checks, satisfied state, blockers, and next action for one task.',
374
+ canonical: true,
375
+ appearsInDefaultHelp: true,
376
+ family: 'capsule-lifecycle',
377
+ scope: 'capsule',
378
+ lifecycleStage: 'phase-check',
379
+ requiredness: 'primary',
380
+ writeBoundary: 'read-only',
381
+ readOnly: true,
382
+ risk: 'low',
383
+ actor: 'agent-worker',
384
+ status: 'stable',
385
+ schemaVersion: 'hadara.task.lifecycle.v1',
386
+ docs: TASK_DOCS,
387
+ implementationFiles: ['src/cli/task.ts', 'src/task/task-lifecycle.ts'],
388
+ testFiles: ['tests/unit/task-lifecycle.test.ts'],
389
+ examples: [example('Inspect lifecycle phase', 'hadara task lifecycle --task T-0001 --json', 'When an agent needs one read-only phase report before deciding the next lifecycle command.')],
390
+ related: ['task.status', 'task.finish', 'task.ready', 'task.close', 'task.audit-close'],
391
+ conflictsWith: [],
392
+ notes: 'Default 0.3.3 agent-facing phase report. Low-level finish/ready/close/audit-close proof commands remain available for debugging and recovery.'
393
+ },
394
+ {
395
+ id: 'task.close-repair-plan',
396
+ command: 'hadara task close-repair-plan --task <task-id> [--json]',
397
+ summary: 'Classify close proof repair state and return exact repair next actions.',
398
+ canonical: true,
399
+ appearsInDefaultHelp: false,
400
+ family: 'capsule-lifecycle',
401
+ scope: 'capsule',
402
+ lifecycleStage: 'inspect',
403
+ requiredness: 'conditional',
404
+ writeBoundary: 'read-only',
405
+ readOnly: true,
406
+ risk: 'low',
407
+ actor: 'agent-worker',
408
+ status: 'stable',
409
+ schemaVersion: 'hadara.task.closeRepairPlan.v1',
410
+ docs: TASK_DOCS,
411
+ implementationFiles: ['src/cli/task.ts', 'src/task/task-close-repair-plan.ts'],
412
+ testFiles: ['tests/unit/task-close-repair-plan.test.ts'],
413
+ examples: [example('Plan close repair', 'hadara task close-repair-plan --task T-0001 --json', 'When audit-close reports missing, stale, invalid, or duplicate close proof state.')],
414
+ related: ['task.lifecycle', 'task.close', 'task.audit-close'],
415
+ conflictsWith: [],
416
+ notes: 'This command is read-only and does not append replacement close evidence.'
342
417
  },
343
418
  {
344
419
  id: 'task.finish',
345
420
  command: 'hadara task finish --task <task-id> [--execute] [--json]',
346
421
  summary: 'Preview or apply bounded Task Capsule status and close-source documentation updates.',
347
422
  canonical: true,
348
- appearsInDefaultHelp: true,
423
+ appearsInDefaultHelp: false,
349
424
  family: 'capsule-lifecycle',
350
425
  scope: 'capsule',
351
426
  lifecycleStage: 'finish',
352
- requiredness: 'primary',
427
+ requiredness: 'advanced',
353
428
  writeBoundary: 'task-status-bookkeeping',
354
429
  readOnly: false,
355
430
  risk: 'medium',
@@ -389,11 +464,11 @@ exports.HADARA_COMMAND_REGISTRY = [
389
464
  command: 'hadara task ready --task <task-id> [--level done] [--json]',
390
465
  summary: 'Run read-only readiness checks before close evidence is appended.',
391
466
  canonical: true,
392
- appearsInDefaultHelp: true,
467
+ appearsInDefaultHelp: false,
393
468
  family: 'capsule-lifecycle',
394
469
  scope: 'capsule',
395
470
  lifecycleStage: 'ready',
396
- requiredness: 'primary',
471
+ requiredness: 'advanced',
397
472
  writeBoundary: 'read-only',
398
473
  readOnly: true,
399
474
  risk: 'low',
@@ -410,11 +485,11 @@ exports.HADARA_COMMAND_REGISTRY = [
410
485
  command: 'hadara task close --task <task-id> [--execute] [--json]',
411
486
  summary: 'Preview or append close proof after readiness passes.',
412
487
  canonical: true,
413
- appearsInDefaultHelp: true,
488
+ appearsInDefaultHelp: false,
414
489
  family: 'capsule-lifecycle',
415
490
  scope: 'capsule',
416
491
  lifecycleStage: 'close',
417
- requiredness: 'primary',
492
+ requiredness: 'advanced',
418
493
  writeBoundary: 'close-evidence-append',
419
494
  readOnly: false,
420
495
  risk: 'medium',
@@ -422,6 +497,8 @@ exports.HADARA_COMMAND_REGISTRY = [
422
497
  status: 'stable',
423
498
  schemaVersion: 'hadara.task.close.v1',
424
499
  docs: TASK_DOCS,
500
+ implementationFiles: ['src/cli/task.ts', 'src/task/task-close.ts'],
501
+ testFiles: ['tests/unit/task-close.test.ts'],
425
502
  examples: [
426
503
  example('Preview close', 'hadara task close --task T-0001 --json', 'After task ready passes.'),
427
504
  example('Append close proof', 'hadara task close --task T-0001 --execute --json', 'After reviewing the dry-run report.')
@@ -434,11 +511,11 @@ exports.HADARA_COMMAND_REGISTRY = [
434
511
  command: 'hadara task audit-close --task <task-id> [--json]',
435
512
  summary: 'Audit appended close proof and detect post-close drift.',
436
513
  canonical: true,
437
- appearsInDefaultHelp: true,
514
+ appearsInDefaultHelp: false,
438
515
  family: 'capsule-lifecycle',
439
516
  scope: 'capsule',
440
517
  lifecycleStage: 'audit',
441
- requiredness: 'primary',
518
+ requiredness: 'advanced',
442
519
  writeBoundary: 'read-only',
443
520
  readOnly: true,
444
521
  risk: 'low',
@@ -514,6 +591,8 @@ exports.HADARA_COMMAND_REGISTRY = [
514
591
  status: 'stable',
515
592
  schemaVersion: 'hadara.evidence.list.v1',
516
593
  docs: ['docs/IMPLEMENTATION_SOP.md'],
594
+ implementationFiles: ['src/cli/evidence.ts', 'src/services/evidence-list.ts'],
595
+ testFiles: ['tests/unit/evidence-list.test.ts', 'tests/unit/evidence-json.test.ts'],
517
596
  examples: [example('List evidence ids', 'hadara evidence list --task T-0001', 'Before copying a durable ev: id into --resolves or --supersedes.')],
518
597
  related: ['evidence.add-command', 'evidence.lint'],
519
598
  conflictsWith: []
@@ -642,6 +721,180 @@ exports.HADARA_COMMAND_REGISTRY = [
642
721
  related: ['status', 'protocol.doctor', 'ci.gate'],
643
722
  conflictsWith: []
644
723
  },
724
+ commandEntry({
725
+ id: 'context.graph',
726
+ command: 'hadara context graph [--task <task-id>] [--include-code] --json',
727
+ summary: 'Emit the read-only project context graph, optional task context report, and opt-in code graph extension.',
728
+ canonical: true,
729
+ appearsInDefaultHelp: false,
730
+ family: 'project-health',
731
+ scope: 'project',
732
+ lifecycleStage: 'inspect',
733
+ requiredness: 'diagnostic',
734
+ writeBoundary: 'read-only',
735
+ readOnly: true,
736
+ risk: 'low',
737
+ actor: 'agent-worker',
738
+ status: 'experimental',
739
+ schemaVersion: 'hadara.contextGraph.v1',
740
+ since: '0.3.3',
741
+ docs: ['docs/CLI_JSON_CONTRACT.md', 'docs/COMMAND_SURFACE.md', 'docs/SCHEMAS.md'],
742
+ implementationFiles: ['src/cli/context.ts', 'src/context/context-graph-builder.ts', 'src/context/code-graph-extractor.ts'],
743
+ testFiles: ['tests/unit/context-graph-cli.test.ts', 'tests/unit/context-graph-builder.test.ts'],
744
+ examples: [
745
+ example('Read full context graph', 'hadara context graph --json', 'When a worker needs project context routing signals.'),
746
+ example('Read task context graph', 'hadara context graph --task T-0001 --json', 'When a worker needs task-scoped docs, evidence, commands, and known problems.'),
747
+ example('Read code-aware context graph', 'hadara context graph --include-code --json', 'When a worker needs source, test, symbol, and code relation candidates.')
748
+ ],
749
+ related: ['state.verify', 'docs.required-reading', 'task.status'],
750
+ conflictsWith: [],
751
+ notes: 'Read-only projection; persistent cache support is not implemented yet.'
752
+ }),
753
+ commandEntry({
754
+ id: 'context.pack',
755
+ command: 'hadara context pack --task <task-id> [--include-code] [--budget <tokens>] [--max-items <count>] [--max-read-first <count>] --json',
756
+ summary: 'Emit the bounded task-scoped context pack read plan from the current context graph.',
757
+ canonical: true,
758
+ appearsInDefaultHelp: false,
759
+ family: 'project-health',
760
+ scope: 'task',
761
+ lifecycleStage: 'inspect',
762
+ requiredness: 'diagnostic',
763
+ writeBoundary: 'read-only',
764
+ readOnly: true,
765
+ risk: 'low',
766
+ actor: 'agent-worker',
767
+ status: 'experimental',
768
+ schemaVersion: 'hadara.contextPack.v1',
769
+ since: '0.3.3',
770
+ docs: ['docs/CLI_JSON_CONTRACT.md', 'docs/COMMAND_SURFACE.md', 'docs/SCHEMAS.md'],
771
+ implementationFiles: ['src/cli/context.ts', 'src/context/context-pack.ts', 'src/context/context-graph-builder.ts'],
772
+ testFiles: ['tests/unit/context-graph-cli.test.ts', 'tests/unit/context-pack.test.ts'],
773
+ examples: [
774
+ example('Read task context pack', 'hadara context pack --task T-0001 --json', 'When a worker needs the bounded first-read plan for a task.'),
775
+ example('Read code-aware context pack', 'hadara context pack --task T-0001 --include-code --json', 'When source, test, and symbol candidates should be included.'),
776
+ example('Read smaller context pack', 'hadara context pack --task T-0001 --max-read-first 3 --max-items 12 --json', 'When a worker needs a tighter bounded read plan.')
777
+ ],
778
+ related: ['context.graph', 'state.verify', 'docs.required-reading', 'task.status'],
779
+ conflictsWith: [],
780
+ notes: 'Read-only C3 projection; C4 slicing and persistent C6 cache writes are not implemented by this command.'
781
+ }),
782
+ commandEntry({
783
+ id: 'context.slice',
784
+ command: 'hadara context slice (--path <path> (--from <line> --to <line>|--symbol <name>|--keyword <text> [--window <lines>]|--tail <lines>|--managed-section <section-id>)|--task <task-id> --candidate <candidate-id> [--include-code]) --json',
785
+ summary: 'Emit deterministic read-only raw context slices from one explicit project file or context-pack candidate.',
786
+ canonical: true,
787
+ appearsInDefaultHelp: false,
788
+ family: 'project-health',
789
+ scope: 'project',
790
+ lifecycleStage: 'inspect',
791
+ requiredness: 'diagnostic',
792
+ writeBoundary: 'read-only',
793
+ readOnly: true,
794
+ risk: 'low',
795
+ actor: 'agent-worker',
796
+ status: 'experimental',
797
+ schemaVersion: 'hadara.contextSlice.v1',
798
+ since: '0.3.3',
799
+ docs: ['docs/CLI_JSON_CONTRACT.md', 'docs/COMMAND_SURFACE.md', 'docs/SCHEMAS.md'],
800
+ implementationFiles: ['src/cli/context.ts', 'src/context/context-slice.ts'],
801
+ testFiles: ['tests/unit/context-slice.test.ts', 'tests/unit/context-graph-cli.test.ts'],
802
+ examples: [
803
+ example('Read an explicit range', 'hadara context slice --path docs/AGENT_HANDOFF.md --from 1 --to 80 --json', 'When a worker needs exact source text from a known range.'),
804
+ example('Read a symbol neighborhood', 'hadara context slice --path src/cli/context.ts --symbol handleContextCommand --json', 'When a worker needs bounded source around one exported symbol.'),
805
+ example('Read keyword windows', 'hadara context slice --path docs/TASK_BOARD.md --keyword T-0001 --window 20 --json', 'When a worker needs bounded context around known text.'),
806
+ example('Read a managed section', 'hadara context slice --path docs/TASK_BOARD.md --managed-section task-board --json', 'When a worker needs marker-bounded managed content.'),
807
+ example('Read a context-pack candidate', 'hadara context slice --task T-0001 --candidate slice-candidate:1:doc:docs/IMPLEMENTATION_SOP.md --json', 'When a worker wants exact text for a C3 slice candidate.')
808
+ ],
809
+ related: ['context.pack', 'context.graph', 'docs.managed.list'],
810
+ conflictsWith: [],
811
+ notes: 'C4 implementation reads exact source text through bounded strategies. Candidate slicing resolves against the current C3 context pack and remains read-only.'
812
+ }),
813
+ commandEntry({
814
+ id: 'session.start',
815
+ command: 'hadara session start [--task <task-id>] [--include-code] [--budget <tokens>] [--max-items <count>] [--max-read-first <count>] [--live] --json',
816
+ summary: 'Emit a bounded read-only session-start packet composed from context pack, state projection, lifecycle guidance, and cache metadata.',
817
+ canonical: true,
818
+ appearsInDefaultHelp: false,
819
+ family: 'project-health',
820
+ scope: 'project',
821
+ lifecycleStage: 'inspect',
822
+ requiredness: 'diagnostic',
823
+ writeBoundary: 'read-only',
824
+ readOnly: true,
825
+ risk: 'low',
826
+ actor: 'agent-worker',
827
+ status: 'experimental',
828
+ schemaVersion: 'hadara.sessionStart.v1',
829
+ since: '0.3.3',
830
+ docs: ['docs/CLI_JSON_CONTRACT.md', 'docs/COMMAND_SURFACE.md', 'docs/SCHEMAS.md'],
831
+ implementationFiles: ['src/cli/session.ts', 'src/context/session-start.ts', 'src/context/context-pack.ts'],
832
+ testFiles: ['tests/unit/session-start.test.ts', 'tests/unit/context-graph-cli.test.ts'],
833
+ examples: [
834
+ example('Start a bounded session', 'hadara session start --json', 'When a worker needs the default first-read packet for the current project state.'),
835
+ example('Start a task-scoped session', 'hadara session start --task T-0001 --json', 'When a worker needs bounded context and lifecycle commands for one task.'),
836
+ example('Start a smaller session packet', 'hadara session start --task T-0001 --max-read-first 3 --max-items 10 --json', 'When a worker needs a tighter packet for limited context windows.'),
837
+ example('Start a full live session packet', 'hadara session start --task T-0001 --live --json', 'When a worker explicitly accepts live context-pack graph discovery.')
838
+ ],
839
+ related: ['context.pack', 'context.graph', 'context.cache.status', 'task.next', 'task.status'],
840
+ conflictsWith: [],
841
+ notes: 'C5 MVP is read-only. The default path returns a bounded no-live packet; --live explicitly permits the underlying context-pack graph read.'
842
+ }),
843
+ commandEntry({
844
+ id: 'context.cache.status',
845
+ command: 'hadara context cache status --json',
846
+ summary: 'Inspect read-only C6 context cache freshness, source-manifest staleness, and extractor invalidation keys.',
847
+ canonical: true,
848
+ appearsInDefaultHelp: false,
849
+ family: 'project-health',
850
+ scope: 'local-state',
851
+ lifecycleStage: 'inspect',
852
+ requiredness: 'diagnostic',
853
+ writeBoundary: 'read-only',
854
+ readOnly: true,
855
+ risk: 'low',
856
+ actor: 'agent-worker',
857
+ status: 'experimental',
858
+ schemaVersion: 'hadara.context.cacheStatus.v1',
859
+ since: '0.3.3',
860
+ docs: ['docs/CLI_JSON_CONTRACT.md', 'docs/COMMAND_SURFACE.md', 'docs/SCHEMAS.md'],
861
+ implementationFiles: ['src/cli/context.ts', 'src/context/context-cache-store.ts', 'src/context/source-manifest.ts'],
862
+ testFiles: ['tests/unit/context-cache-store.test.ts', 'tests/unit/context-graph-cli.test.ts'],
863
+ examples: [
864
+ example('Read context cache status', 'hadara context cache status --json', 'Before relying on C6 cache-backed context routing performance.')
865
+ ],
866
+ related: ['context.graph', 'context.pack', 'state.verify'],
867
+ conflictsWith: [],
868
+ notes: 'Read-only status command; it does not create or update cache files. Use context.cache.warm for explicit source-manifest cache writes.'
869
+ }),
870
+ commandEntry({
871
+ id: 'context.cache.warm',
872
+ command: 'hadara context cache warm [--execute] --json',
873
+ summary: 'Dry-run or execute C6 source-manifest cache warm phase 1 under the ignored local context cache.',
874
+ canonical: true,
875
+ appearsInDefaultHelp: false,
876
+ family: 'project-health',
877
+ scope: 'local-state',
878
+ lifecycleStage: 'work',
879
+ requiredness: 'diagnostic',
880
+ writeBoundary: 'local-cache',
881
+ readOnly: false,
882
+ risk: 'low',
883
+ actor: 'agent-worker',
884
+ status: 'experimental',
885
+ schemaVersion: 'hadara.context.cacheWarm.v1',
886
+ since: '0.3.3',
887
+ docs: ['docs/CLI_JSON_CONTRACT.md', 'docs/COMMAND_SURFACE.md', 'docs/SCHEMAS.md'],
888
+ implementationFiles: ['src/cli/context.ts', 'src/context/context-cache-store.ts', 'src/context/source-manifest.ts'],
889
+ testFiles: ['tests/unit/context-cache-store.test.ts', 'tests/unit/context-graph-cli.test.ts'],
890
+ examples: [
891
+ example('Preview context cache warm', 'hadara context cache warm --json', 'Before writing the local source-manifest cache.'),
892
+ example('Execute context cache warm', 'hadara context cache warm --execute --json', 'After reviewing the warm plan and accepting the ignored local cache write.')
893
+ ],
894
+ related: ['context.cache.status', 'context.graph', 'context.pack'],
895
+ conflictsWith: [],
896
+ notes: 'Phase 1 warm command writes only source-manifest cache. It does not warm graph, code-index, context-pack, or slice caches.'
897
+ }),
645
898
  commandEntry({
646
899
  id: 'debt.list',
647
900
  command: 'hadara debt list [--json]',
@@ -1405,6 +1658,8 @@ exports.HADARA_COMMAND_REGISTRY = [
1405
1658
  status: 'stable',
1406
1659
  schemaVersion: 'hadara.releaseDryRun.v1',
1407
1660
  docs: ['docs/RELEASE_READINESS.md'],
1661
+ implementationFiles: ['src/cli/release-dry-run.ts', 'src/services/release-dry-run.ts'],
1662
+ testFiles: ['tests/unit/release-dry-run.test.ts'],
1408
1663
  examples: [example('Run release dry-run', 'hadara release dry-run --json', 'Before publish/deploy readiness checks.')],
1409
1664
  related: ['release.gate', 'release.publish', 'release.artifact'],
1410
1665
  conflictsWith: []
@@ -1617,6 +1872,8 @@ function cloneCommandRegistryEntry(entry) {
1617
1872
  return {
1618
1873
  ...entry,
1619
1874
  aliases: entry.aliases ? [...entry.aliases] : undefined,
1875
+ implementationFiles: entry.implementationFiles ? [...entry.implementationFiles] : undefined,
1876
+ testFiles: entry.testFiles ? [...entry.testFiles] : undefined,
1620
1877
  docs: [...entry.docs],
1621
1878
  examples: entry.examples.map((item) => ({ ...item })),
1622
1879
  related: [...entry.related],
@@ -4,16 +4,14 @@ exports.PORTFOLIO_AUDIT_DECISIONS = exports.PRIMARY_LIFECYCLE_ORDER = void 0;
4
4
  exports.createLifecycleGuideReport = createLifecycleGuideReport;
5
5
  exports.createCommandPortfolioAuditReport = createCommandPortfolioAuditReport;
6
6
  const capability_registry_1 = require("./capability-registry");
7
- exports.PRIMARY_LIFECYCLE_ORDER = ['discover', 'create', 'inspect', 'evidence', 'finish', 'ready', 'close', 'audit', 'handoff'];
7
+ exports.PRIMARY_LIFECYCLE_ORDER = ['discover', 'create', 'inspect', 'evidence', 'phase-check', 'finalize', 'handoff'];
8
8
  const PRIMARY_WHEN = {
9
9
  'task.next': 'At session start or after completing a task.',
10
10
  'task.create': 'When no suitable Task Capsule exists.',
11
11
  'task.status': 'Before editing, validating, or closing a capsule.',
12
12
  'evidence.add-command': 'After running project validation or recording relevant work proof.',
13
- 'task.finish': 'After implementation and evidence are ready, before readiness checks.',
14
- 'task.ready': 'Before executing task close.',
15
- 'task.close': 'After task ready passes and the close plan is reviewed.',
16
- 'task.audit-close': 'Immediately after close evidence is appended.',
13
+ 'task.lifecycle': 'When the agent needs a compact phase report and next action.',
14
+ 'task.finalize': 'After implementation, evidence, capsule docs, and tracked state docs are ready.',
17
15
  'handoff.update': 'Before stopping after meaningful task progress or completion.'
18
16
  };
19
17
  const DIAGNOSTIC_USE_WHEN = {
@@ -22,7 +20,7 @@ const DIAGNOSTIC_USE_WHEN = {
22
20
  'proof.explain': 'Proof status is stale, weak, or confusing.',
23
21
  'ci.gate': 'You need an aggregated advisory or strict project/task gate.',
24
22
  'protocol.doctor': 'Protocol docs, task board rows, or profile state may be inconsistent.',
25
- 'harness.validate': 'task ready reports format or done-level blockers.'
23
+ 'harness.validate': 'task finalize or low-level task ready reports format or done-level blockers.'
26
24
  };
27
25
  const ADVANCED_FAMILY_USE_WHEN = [
28
26
  { family: 'release-package', useWhen: 'Release/package capsules only.' },
@@ -35,27 +33,27 @@ const ADVANCED_FAMILY_USE_WHEN = [
35
33
  ];
36
34
  exports.PORTFOLIO_AUDIT_DECISIONS = [
37
35
  {
38
- decision: 'Task inspection is separate from readiness.',
39
- commands: ['task.status', 'task.ready', 'harness.validate'],
40
- rule: '`task status` report generation success is not readiness; readiness lives in readiness/proof fields and `task ready`.',
41
- evidence: 'Phase 7.2 non-overlap rules.'
36
+ decision: 'Task inspection is separate from lifecycle phase and readiness.',
37
+ commands: ['task.status', 'task.lifecycle', 'task.finalize', 'task.ready', 'harness.validate'],
38
+ rule: '`task status` report generation success is not readiness; 0.3.3 agents use `task lifecycle` for phase and `task finalize` for guarded close execution, while low-level readiness remains in `task ready`.',
39
+ evidence: '0.3.3 finalize-first lifecycle default.'
42
40
  },
43
41
  {
44
- decision: 'Completion guidance is read-only, finish is bookkeeping.',
45
- commands: ['task.complete', 'task.finish'],
46
- rule: '`task complete` is a read-only workflow compressor; `task finish` may update only bounded task status bookkeeping.',
47
- evidence: 'Phase 7.2 confusable command audit.'
42
+ decision: 'Finalize is the default agent close path; finish is low-level bookkeeping.',
43
+ commands: ['task.finalize', 'task.complete', 'task.finish'],
44
+ rule: '`task finalize` is the default reviewed close path. `task complete` is a legacy read-only workflow compressor; low-level `task finish` may update only bounded task status bookkeeping.',
45
+ evidence: '0.3.3 lifecycle convenience contract.'
48
46
  },
49
47
  {
50
- decision: 'Close appends proof, audit verifies proof.',
51
- commands: ['task.close', 'task.audit-close'],
52
- rule: '`task close --execute` appends close evidence only; `task audit-close` is read-only post-close verification.',
53
- evidence: 'Phase 7.2 non-overlap rules.'
48
+ decision: 'Close appends proof, audit verifies proof, finalize composes both.',
49
+ commands: ['task.finalize', 'task.close', 'task.audit-close'],
50
+ rule: '`task finalize --execute --plan-hash <hash>` preserves the underlying boundaries: low-level `task close --execute` appends close evidence only and `task audit-close` is read-only post-close verification.',
51
+ evidence: '0.3.3 finalize-first lifecycle default.'
54
52
  },
55
53
  {
56
54
  decision: 'Proof and CI gates diagnose, they do not replace close.',
57
- commands: ['proof.status', 'proof.explain', 'ci.gate', 'task.close'],
58
- rule: 'Proof and CI reports explain readiness; they do not append close proof or substitute for audit.',
55
+ commands: ['proof.status', 'proof.explain', 'ci.gate', 'task.finalize', 'task.close'],
56
+ rule: 'Proof and CI reports explain readiness; they do not append close proof or substitute for finalize/audit.',
59
57
  evidence: 'Phase 7.2 non-overlap rules.'
60
58
  },
61
59
  {
@@ -66,7 +64,7 @@ exports.PORTFOLIO_AUDIT_DECISIONS = [
66
64
  },
67
65
  {
68
66
  decision: 'Release and dev validation are not ordinary capsule lifecycle steps.',
69
- commands: ['release.gate', 'task.ready', 'dev.docker-check'],
67
+ commands: ['release.gate', 'task.finalize', 'task.ready', 'dev.docker-check'],
70
68
  rule: 'Release/dev commands are operator or HADARA-dev validation surfaces and stay hidden from primary lifecycle help.',
71
69
  evidence: 'Phase 7.2 advanced family boundary.'
72
70
  }
@@ -169,14 +167,10 @@ function primaryCommandForEntry(entry) {
169
167
  return 'hadara task status --task T-XXXX --json';
170
168
  case 'evidence.add-command':
171
169
  return 'hadara evidence add-command --task T-XXXX --summary "..." --result passed --json';
172
- case 'task.finish':
173
- return 'hadara task finish --task T-XXXX --json';
174
- case 'task.ready':
175
- return 'hadara task ready --task T-XXXX --level done --json';
176
- case 'task.close':
177
- return 'hadara task close --task T-XXXX --json';
178
- case 'task.audit-close':
179
- return 'hadara task audit-close --task T-XXXX --json';
170
+ case 'task.lifecycle':
171
+ return 'hadara task lifecycle --task T-XXXX --json';
172
+ case 'task.finalize':
173
+ return 'hadara task finalize --task T-XXXX --json';
180
174
  case 'handoff.update':
181
175
  return 'hadara handoff update --task T-XXXX --json';
182
176
  default: