Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ npm install @commandlayer/commons ajv
**Validate a request against a canonical verb schema**

```
npx cl-validate examples/v1.0.0/commons/summarize/request.json
npx cl-validate examples/v1.1.0/commons/summarize/json/valid/001-summarize.request.valid.json
# ✓ VALID — trace: bafybeieoynknza...
```
**Programmatic usage (Node.js/ESM)**
Expand Down Expand Up @@ -371,13 +371,26 @@ protocol-commons/
│ ├── trace.schema.json
│ └── receipt.base.schema.json
├── examples/
│ └── v1.0.0/
│ ├── v1.0.0/
│ │ └── commons/
│ │ └── <verb>/
│ │ ├── valid/
│ │ │ └── *.json
│ │ └── invalid/
│ │ └── *.json
│ └── v1.1.0/
│ └── commons/
│ └── <verb>/
│ ├── valid/
│ │ └── *.json
│ └── invalid/
│ └── *.json
│ ├── json/
│ │ ├── valid/
│ │ │ └── *.json
│ │ └── invalid/
│ │ └── *.json
│ └── ts/
│ ├── valid/
│ │ └── *.ts
│ └── invalid/
│ └── *.ts
├── checksums.txt
├── manifest.json
├── SPEC.md
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"verb": "summarize",
"version": "1.1.0",
"input": {
"text": "This should be a string."
},
"mode": "bullet-points"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"verb": "analyze",
"version": "1.1.0",
"status": "ok",
"timestamp": "not-a-date",
"request_hash": "sha256:xyz",
"signature": "short",
"error": "ok receipts should not rely on error only"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"verb": "analyze",
"version": "1.1.0",
"input": "Review this smart-contract audit summary and extract the core risk themes for launch readiness.",
"mode": "extract"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"verb": "analyze",
"version": "1.1.0",
"status": "ok",
"timestamp": "2026-03-18T12:00:00Z",
"agent": "analyzeagent.eth",
"request_hash": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"result_hash": "sha256:2222222222222222222222222222222222222222222222222222222222222222",
"result_cid": "bafybeianalyzereceiptokexample0001",
"summary": "Core risks center on signer key rotation gaps, unresolved indexer scaling assumptions, and an unstated rollback plan.",
"signature": "sigAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// INVALID analyze.receipt #1 — bad timestamp, malformed hash, short signature

export const analyzeReceiptInvalid1: any = {
"verb": "analyze",
"version": "1.1.0",
"status": "ok",
"timestamp": "not-a-date",
"request_hash": "sha256:xyz",
"signature": "short",
"error": "ok receipts should not rely on error only"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// INVALID analyze.receipt #2 — error status without required error field

export const analyzeReceiptInvalid2: any = {
"verb": "analyze",
"version": "1.1.0",
"status": "error",
"timestamp": "2026-03-18T12:05:00Z",
"request_hash": "sha256:4444444444444444444444444444444444444444444444444444444444444444",
"signature": "sigBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// INVALID analyze.request #1 — wrong verb + wrong input type + unsupported mode

export const analyzeRequestInvalid1: any = {
"verb": "summarize",
"version": "1.1.0",
"input": {
"text": "This should be a string."
},
"mode": "bullet-points"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// INVALID analyze.request #2 — missing required input and wrong version type

export const analyzeRequestInvalid2: any = {
"verb": "analyze",
"version": 110,
"mode": "extract"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// VALID analyze.receipt #1 — success receipt with signer identity and hashes

export interface AnalyzeReceipt {
verb: "analyze";
version: "1.1.0";
status: "ok" | "error";
timestamp: string;
agent?: string;
request_hash: `sha256:${string}`;
result_hash?: `sha256:${string}`;
result_cid?: string;
summary?: string;
signature: string;
error?: string;
}

export const analyzeReceiptValid1: AnalyzeReceipt = {
"verb": "analyze",
"version": "1.1.0",
"status": "ok",
"timestamp": "2026-03-18T12:00:00Z",
"agent": "analyzeagent.eth",
"request_hash": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"result_hash": "sha256:2222222222222222222222222222222222222222222222222222222222222222",
"result_cid": "bafybeianalyzereceiptokexample0001",
"summary": "Core risks center on signer key rotation gaps, unresolved indexer scaling assumptions, and an unstated rollback plan.",
"signature": "sigAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// VALID analyze.receipt #2 — error receipt variant required by the schema

import type { AnalyzeReceipt } from "./analyze.receipt.valid.1";

export const analyzeReceiptValid2: AnalyzeReceipt = {
"verb": "analyze",
"version": "1.1.0",
"status": "error",
"timestamp": "2026-03-18T12:05:00Z",
"agent": "analyzeagent.eth",
"request_hash": "sha256:3333333333333333333333333333333333333333333333333333333333333333",
"signature": "sigBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
"error": "analyze execution failed because the input could not be processed in the requested mode."
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// VALID analyze.request #1 — aligned with schemas/v1.1.0/commons/analyze/analyze.request.schema.json

export type AnalyzeMode = "classify" | "extract" | "score" | "summarize";

export interface AnalyzeRequest {
verb: "analyze";
version: "1.1.0";
input: string;
mode?: AnalyzeMode;
}

export const analyzeRequestValid1: AnalyzeRequest = {
"verb": "analyze",
"version": "1.1.0",
"input": "Review this smart-contract audit summary and extract the core risk themes for launch readiness.",
"mode": "extract"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// VALID analyze.request #2 — alternate minimal, schema-accurate example

import type { AnalyzeRequest, AnalyzeMode } from "./analyze.request.valid.1";

const mode: AnalyzeMode = "score";

export const analyzeRequestValid2: AnalyzeRequest = {
"verb": "analyze",
"version": "1.1.0",
"input": "Assess the following roadmap update and score operational risk based on stated blockers and dependencies.",
"mode": "score"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"verb": "summarize",
"version": "1.1.0",
"input": {
"text": "This should be a string."
},
"mode": "ordinal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"verb": "classify",
"version": "1.1.0",
"status": "ok",
"timestamp": "not-a-date",
"request_hash": "sha256:xyz",
"signature": "short",
"error": "ok receipts should not rely on error only"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"verb": "classify",
"version": "1.1.0",
"input": "Payment failed after signature verification because the buyer wallet had insufficient balance.",
"mode": "single"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"verb": "classify",
"version": "1.1.0",
"status": "ok",
"timestamp": "2026-03-18T12:00:00Z",
"agent": "classifyagent.eth",
"request_hash": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"result_hash": "sha256:2222222222222222222222222222222222222222222222222222222222222222",
"result_cid": "bafybeiclassifyreceiptokexample0001",
"summary": "billing_issue",
"signature": "sigAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// INVALID classify.receipt #1 — bad timestamp, malformed hash, short signature

export const classifyReceiptInvalid1: any = {
"verb": "classify",
"version": "1.1.0",
"status": "ok",
"timestamp": "not-a-date",
"request_hash": "sha256:xyz",
"signature": "short",
"error": "ok receipts should not rely on error only"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// INVALID classify.request #1 — wrong verb + wrong input type + unsupported mode

export const classifyRequestInvalid1: any = {
"verb": "summarize",
"version": "1.1.0",
"input": {
"text": "This should be a string."
},
"mode": "ordinal"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// VALID classify.receipt #1 — success receipt with signer identity and hashes

export interface ClassifyReceipt {
verb: "classify";
version: "1.1.0";
status: "ok" | "error";
timestamp: string;
agent?: string;
request_hash: `sha256:${string}`;
result_hash?: `sha256:${string}`;
result_cid?: string;
summary?: string;
signature: string;
error?: string;
}

export const classifyReceiptValid1: ClassifyReceipt = {
"verb": "classify",
"version": "1.1.0",
"status": "ok",
"timestamp": "2026-03-18T12:00:00Z",
"agent": "classifyagent.eth",
"request_hash": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"result_hash": "sha256:2222222222222222222222222222222222222222222222222222222222222222",
"result_cid": "bafybeiclassifyreceiptokexample0001",
"summary": "billing_issue",
"signature": "sigAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// VALID classify.request #1 — aligned with schemas/v1.1.0/commons/classify/classify.request.schema.json

export type ClassifyMode = "single" | "multi" | "hierarchical";

export interface ClassifyRequest {
verb: "classify";
version: "1.1.0";
input: string;
mode?: ClassifyMode;
}

export const classifyRequestValid1: ClassifyRequest = {
"verb": "classify",
"version": "1.1.0",
"input": "Payment failed after signature verification because the buyer wallet had insufficient balance.",
"mode": "single"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"verb": "summarize",
"version": "1.1.0",
"input": {
"text": "This should be a string."
},
"mode": "compress"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"verb": "clean",
"version": "1.1.0",
"status": "ok",
"timestamp": "not-a-date",
"request_hash": "sha256:xyz",
"signature": "short",
"error": "ok receipts should not rely on error only"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"verb": "clean",
"version": "1.1.0",
"input": " CommandLayer\tCommons v1.1.0\n",
"mode": "normalize"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"verb": "clean",
"version": "1.1.0",
"status": "ok",
"timestamp": "2026-03-18T12:00:00Z",
"agent": "cleanagent.eth",
"request_hash": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"result_hash": "sha256:2222222222222222222222222222222222222222222222222222222222222222",
"result_cid": "bafybeicleanreceiptokexample0001",
"summary": "Normalized whitespace and casing artifacts to yield a canonical single-line string.",
"signature": "sigAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// INVALID clean.receipt #1 — bad timestamp, malformed hash, short signature

export const cleanReceiptInvalid1: any = {
"verb": "clean",
"version": "1.1.0",
"status": "ok",
"timestamp": "not-a-date",
"request_hash": "sha256:xyz",
"signature": "short",
"error": "ok receipts should not rely on error only"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// INVALID clean.receipt #2 — error status without required error field

export const cleanReceiptInvalid2: any = {
"verb": "clean",
"version": "1.1.0",
"status": "error",
"timestamp": "2026-03-18T12:05:00Z",
"request_hash": "sha256:4444444444444444444444444444444444444444444444444444444444444444",
"signature": "sigBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// INVALID clean.request #1 — wrong verb + wrong input type + unsupported mode

export const cleanRequestInvalid1: any = {
"verb": "summarize",
"version": "1.1.0",
"input": {
"text": "This should be a string."
},
"mode": "compress"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// INVALID clean.request #2 — missing required input and wrong version type

export const cleanRequestInvalid2: any = {
"verb": "clean",
"version": 110,
"mode": "normalize"
};
Loading
Loading