mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
Merge master; OpenFleet keeps its name, PR 177's rental descriptor becomes OpenRental
PR 177 shipped a second OpenFleet under the same slug: a published listing of OpenAgent profiles and ipfile swarms with CoinPay rental offers. Anthony ruled that OpenFleet means the human-controlled fleet and the record of who spawned whom, so the rental contract is renamed OpenRental (slug openrental, catalogs family, group noun listing): docs/openrental.md, logicsrc-openrental.schema.json with type logicsrc.openrental and scope kind listing, fixtures/openrental, createOpenRental and OpenRental* types in the SDK, the openrental validator kind. Minor bumps because an export moved: @logicsrc/schemas 0.2.0, @logicsrc/validators 0.2.0, @logicsrc/sdk 0.2.0. The discovery contract test now covers openfleet, openrental and openwall, one per family, and accepts a landing-page link in llms.txt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RZV4zJ2pDZLNN3kE5jFCmV
This commit is contained in:
commit
68f3151699
35 changed files with 2068 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@logicsrc/cli",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "LogicSRC CLI: every LogicSRC standard and tool as one command.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
|
|
|||
25
packages/cli/src/install-npm.test.ts
Normal file
25
packages/cli/src/install-npm.test.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { createRequire } from "node:module";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { selectNpm } = require("../../../scripts/install-npm.cjs") as {
|
||||
selectNpm: (nodeVersion: string, packageManager: string) => string | null;
|
||||
};
|
||||
|
||||
describe("installer npm compatibility", () => {
|
||||
it.each(["18.20.8", "20.16.0", "21.7.3", "22.8.0"])("preserves the host npm on Node %s", (version) => {
|
||||
expect(selectNpm(version, "npm@11.11.0")).toBeNull();
|
||||
});
|
||||
|
||||
it.each(["20.17.0", "20.19.0", "22.9.0", "23.0.0", "24.18.1", "25.0.0"])(
|
||||
"selects the tested npm on Node %s", (version) => {
|
||||
expect(selectNpm(version, "npm@11.11.0")).toBe("npm@11.11.0");
|
||||
}
|
||||
);
|
||||
|
||||
it("does not assume compatibility for a different package manager or npm major", () => {
|
||||
expect(selectNpm("24.18.1", "pnpm@11.11.0")).toBeNull();
|
||||
expect(selectNpm("24.18.1", "npm@12.0.0")).toBeNull();
|
||||
expect(selectNpm("unknown", "npm@11.11.0")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
Canonical JSON Schemas (draft 2020-12) for the LogicSRC open coordination
|
||||
standards, maintained by Profullstack, Inc.
|
||||
|
||||
Two schema families ship from this package:
|
||||
Schema families include:
|
||||
|
||||
- **LogicSRC core** — `logicsrc-*.schema.json`: tasks, agents, runs, events,
|
||||
plugins, connected accounts, email messages, social posts.
|
||||
|
|
@ -11,6 +11,13 @@ Two schema families ship from this package:
|
|||
contract for CLI tools and AI agents (ads, placements, requests, responses,
|
||||
impressions, clicks, campaigns). See `docs/agentad.md` in the repo;
|
||||
[cl1s.tech](https://github.com/profullstack/cl1s.tech) is the reference network.
|
||||
- **OpenWall draft** — `openwall-message` and `openwall-receipt` exports define
|
||||
sender-side audience jobs and private delivery events. Fixtures are in
|
||||
`fixtures/openwall`. See `docs/openwall.md` for consent, routing, and runtime
|
||||
requirements beyond structural validation; no OpenWall delivery runtime ships.
|
||||
- **OpenRental draft** — the `openrental` export describes listings of OpenAgent
|
||||
profiles and OpenSwarm file-key references, with metadata and CoinPay rental
|
||||
offers. `@logicsrc/validators` also checks membership and rental references.
|
||||
|
||||
## Install
|
||||
|
||||
|
|
|
|||
86
packages/schemas/fixtures/openrental/mixed.json
Normal file
86
packages/schemas/fixtures/openrental/mixed.json
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
"type": "logicsrc.openrental",
|
||||
"version": "0.1",
|
||||
"id": "https://example.com/listings/research",
|
||||
"name": "Research and distribution listing",
|
||||
"owner_did": "operator.coinpay",
|
||||
"description": "An analyst agent and an encrypted reference-data swarm, offered together or separately.",
|
||||
"updated_at": "2026-09-13T12:00:00Z",
|
||||
"availability": "available",
|
||||
"tags": [
|
||||
"research",
|
||||
"distribution"
|
||||
],
|
||||
"capabilities": [
|
||||
"analysis",
|
||||
"paid-seeding"
|
||||
],
|
||||
"metadata": {
|
||||
"region": "eu-west",
|
||||
"support_url": "https://example.com/support"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
"kind": "openagent",
|
||||
"id": "analyst.coinpay",
|
||||
"url": "https://example.com/agents/analyst.json",
|
||||
"name": "Analyst",
|
||||
"role": "analysis",
|
||||
"metadata": {
|
||||
"languages": [
|
||||
"en"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "openswarm",
|
||||
"id": "ed25519:0d87e09c7fea3ad6ba6c2f3e027ea47f5b245452899910948470906704c5295d",
|
||||
"url": "https://example.com/swarms/references/manifest.json",
|
||||
"name": "Reference corpus",
|
||||
"role": "reference-data"
|
||||
}
|
||||
],
|
||||
"rentals": [
|
||||
{
|
||||
"id": "listing-hourly",
|
||||
"scope": {
|
||||
"kind": "listing"
|
||||
},
|
||||
"rate": {
|
||||
"amount": "25.000000",
|
||||
"currency": "USD",
|
||||
"unit": "hour"
|
||||
},
|
||||
"minimum_units": 1,
|
||||
"maximum_units": 24,
|
||||
"terms_url": "https://example.com/rental-terms",
|
||||
"payment": {
|
||||
"provider": "coinpay",
|
||||
"payee_did": "operator.coinpay",
|
||||
"checkout_url": "https://example.com/rentals/research"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "analyst-task",
|
||||
"scope": {
|
||||
"kind": "members",
|
||||
"members": [
|
||||
{
|
||||
"kind": "openagent",
|
||||
"id": "analyst.coinpay"
|
||||
}
|
||||
]
|
||||
},
|
||||
"rate": {
|
||||
"amount": "5.500000",
|
||||
"currency": "USD",
|
||||
"unit": "task"
|
||||
},
|
||||
"payment": {
|
||||
"provider": "coinpay",
|
||||
"payee_did": "operator.coinpay",
|
||||
"checkout_url": "https://example.com/rentals/analyst"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
16
packages/schemas/fixtures/openwall/announcement.json
Normal file
16
packages/schemas/fixtures/openwall/announcement.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"openwall": "0.1-draft",
|
||||
"id": "urn:uuid:5bb154dd-edb3-47b7-8fc6-4cb65a19a9f8",
|
||||
"sender": "did:web:ops.example",
|
||||
"createdAt": "2026-09-13T12:00:00Z",
|
||||
"expiresAt": "2026-09-20T12:00:00Z",
|
||||
"visibility": "public",
|
||||
"topic": "releases",
|
||||
"audience": {
|
||||
"kind": "public"
|
||||
},
|
||||
"content": {
|
||||
"mediaType": "text/plain",
|
||||
"text": "Version 1.2 is available."
|
||||
}
|
||||
}
|
||||
27
packages/schemas/fixtures/openwall/broadcast.json
Normal file
27
packages/schemas/fixtures/openwall/broadcast.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"openwall": "0.1-draft",
|
||||
"id": "urn:uuid:94d908df-2876-48f1-bec8-c931f5c847d4",
|
||||
"sender": "did:web:ops.example",
|
||||
"createdAt": "2026-09-13T12:00:00Z",
|
||||
"expiresAt": "2026-09-13T12:10:00Z",
|
||||
"visibility": "private",
|
||||
"topic": "maintenance",
|
||||
"audience": {
|
||||
"kind": "relationships",
|
||||
"selectors": [
|
||||
{
|
||||
"source": "https://dev.example/contacts",
|
||||
"actor": "did:web:ops.example",
|
||||
"groups": [
|
||||
"users"
|
||||
],
|
||||
"scope": "https://dev.example/workspaces/main"
|
||||
}
|
||||
],
|
||||
"exclude": []
|
||||
},
|
||||
"content": {
|
||||
"mediaType": "text/plain",
|
||||
"text": "SERVER NOTICE\nMaintenance starts in 10 minutes.\nPlease save your work and pause running jobs."
|
||||
}
|
||||
}
|
||||
17
packages/schemas/fixtures/openwall/direct.json
Normal file
17
packages/schemas/fixtures/openwall/direct.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"openwall": "0.1-draft",
|
||||
"id": "urn:uuid:07b2b83e-27f6-4d59-bdfa-cdcd42548678",
|
||||
"sender": "did:web:ops.example",
|
||||
"createdAt": "2026-09-13T12:00:00Z",
|
||||
"expiresAt": "2026-09-13T12:10:00Z",
|
||||
"visibility": "private",
|
||||
"topic": "maintenance",
|
||||
"audience": {
|
||||
"kind": "direct",
|
||||
"recipient": "did:web:ada.example"
|
||||
},
|
||||
"content": {
|
||||
"mediaType": "text/plain",
|
||||
"text": "Ready when you are."
|
||||
}
|
||||
}
|
||||
13
packages/schemas/fixtures/openwall/receipt-accepted.json
Normal file
13
packages/schemas/fixtures/openwall/receipt-accepted.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"openwall": "0.1-draft",
|
||||
"id": "urn:uuid:963f9109-803f-4f0c-8506-10c70ec47ee6",
|
||||
"messageId": "urn:uuid:94d908df-2876-48f1-bec8-c931f5c847d4",
|
||||
"recipient": "did:web:ada.example",
|
||||
"sequence": 3,
|
||||
"state": "accepted",
|
||||
"at": "2026-09-13T12:00:03Z",
|
||||
"attempt": 1,
|
||||
"route": "https://chat.example",
|
||||
"providerMessageId": "provider-msg-123",
|
||||
"deliveryId": "urn:uuid:db925d64-4e1a-4e5a-83c1-e37b68aa5eef"
|
||||
}
|
||||
14
packages/schemas/fixtures/openwall/receipt-retrying.json
Normal file
14
packages/schemas/fixtures/openwall/receipt-retrying.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"openwall": "0.1-draft",
|
||||
"id": "urn:uuid:211bb615-90e1-4773-b7c0-49d59d7cd6bc",
|
||||
"messageId": "urn:uuid:94d908df-2876-48f1-bec8-c931f5c847d4",
|
||||
"recipient": "did:web:ada.example",
|
||||
"sequence": 3,
|
||||
"state": "retrying",
|
||||
"at": "2026-09-13T12:00:03Z",
|
||||
"attempt": 1,
|
||||
"route": "https://chat.example",
|
||||
"reason": "rate-limited",
|
||||
"nextAttemptAt": "2026-09-13T12:01:00Z",
|
||||
"deliveryId": "urn:uuid:db925d64-4e1a-4e5a-83c1-e37b68aa5eef"
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@logicsrc/schemas",
|
||||
"version": "0.1.0",
|
||||
"description": "LogicSRC JSON schemas for tasks, agents, runs, events, plugins, the AgentAd ad standard, the OpenOntology knowledge contracts, the OpenContext context plane, and the OpenCreds credential vault.",
|
||||
"version": "0.2.0",
|
||||
"description": "LogicSRC JSON schemas for tasks, agents, runs, events, plugins, the AgentAd ad standard, the OpenOntology knowledge contracts, the OpenContext context plane, the OpenCreds credential vault, OpenRental membership and rental offers, and the OpenWall messaging proposal.",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
"ontology",
|
||||
"opencontext",
|
||||
"opencreds",
|
||||
"openrental",
|
||||
"openontology",
|
||||
"password-manager",
|
||||
"standards",
|
||||
|
|
@ -64,6 +65,7 @@
|
|||
"./opencreds-item": "./schemas/logicsrc-opencreds-item.schema.json",
|
||||
"./opencreds-manifest": "./schemas/logicsrc-opencreds-manifest.schema.json",
|
||||
"./opencreds-vault-meta": "./schemas/logicsrc-opencreds-vault-meta.schema.json",
|
||||
"./openrental": "./schemas/logicsrc-openrental.schema.json",
|
||||
"./openontology-action": "./schemas/logicsrc-openontology-action.schema.json",
|
||||
"./openontology-approval": "./schemas/logicsrc-openontology-approval.schema.json",
|
||||
"./openontology-changeset": "./schemas/logicsrc-openontology-changeset.schema.json",
|
||||
|
|
@ -83,6 +85,8 @@
|
|||
"./openontology-review": "./schemas/logicsrc-openontology-review.schema.json",
|
||||
"./openontology-source": "./schemas/logicsrc-openontology-source.schema.json",
|
||||
"./openprd-prd": "./schemas/openprd-prd.schema.json",
|
||||
"./openwall-message": "./schemas/logicsrc-openwall-message.schema.json",
|
||||
"./openwall-receipt": "./schemas/logicsrc-openwall-receipt.schema.json",
|
||||
"./plugin": "./schemas/logicsrc-plugin.schema.json",
|
||||
"./pull-request": "./schemas/logicsrc-pull-request.schema.json",
|
||||
"./repo": "./schemas/logicsrc-repo.schema.json",
|
||||
|
|
|
|||
323
packages/schemas/schemas/logicsrc-openrental.schema.json
Normal file
323
packages/schemas/schemas/logicsrc-openrental.schema.json
Normal file
|
|
@ -0,0 +1,323 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://schemas.logicsrc.com/logicsrc-openrental.schema.json",
|
||||
"title": "OpenRental",
|
||||
"description": "A listing of OpenAgent profiles and/or OpenSwarm swarms with explicit CoinPay rental offers.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"version",
|
||||
"id",
|
||||
"name",
|
||||
"owner_did",
|
||||
"members"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "logicsrc.openrental"
|
||||
},
|
||||
"version": {
|
||||
"const": "0.1"
|
||||
},
|
||||
"id": {
|
||||
"$ref": "#/$defs/httpsUrl"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 120
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"owner_did": {
|
||||
"$ref": "https://schemas.logicsrc.com/logicsrc-agent.schema.json#/$defs/did"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"availability": {
|
||||
"enum": [
|
||||
"available",
|
||||
"busy",
|
||||
"offline",
|
||||
"unknown"
|
||||
]
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"uniqueItems": true
|
||||
},
|
||||
"capabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"uniqueItems": true
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
},
|
||||
"members": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/$defs/member"
|
||||
}
|
||||
},
|
||||
"rentals": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/rental"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"httpsUrl": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^https://"
|
||||
},
|
||||
"memberReference": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"kind",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "openagent"
|
||||
},
|
||||
"id": {
|
||||
"$ref": "https://schemas.logicsrc.com/logicsrc-agent.schema.json#/$defs/did"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"kind",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "openswarm"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^ed25519:[0-9a-f]{64}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"member": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"kind",
|
||||
"id",
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "openagent"
|
||||
},
|
||||
"id": {
|
||||
"$ref": "https://schemas.logicsrc.com/logicsrc-agent.schema.json#/$defs/did"
|
||||
},
|
||||
"url": {
|
||||
"$ref": "#/$defs/httpsUrl"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"role": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"kind",
|
||||
"id",
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "openswarm"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^ed25519:[0-9a-f]{64}$"
|
||||
},
|
||||
"url": {
|
||||
"$ref": "#/$defs/httpsUrl"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"role": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"kind"
|
||||
],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "listing"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"kind",
|
||||
"members"
|
||||
],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "members"
|
||||
},
|
||||
"members": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/$defs/memberReference"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"rental": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"id",
|
||||
"scope",
|
||||
"rate",
|
||||
"payment"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"scope": {
|
||||
"$ref": "#/$defs/scope"
|
||||
},
|
||||
"rate": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"amount",
|
||||
"currency",
|
||||
"unit"
|
||||
],
|
||||
"properties": {
|
||||
"amount": {
|
||||
"type": "string",
|
||||
"pattern": "^(0|[1-9][0-9]*)\\.[0-9]{6}$",
|
||||
"description": "Non-negative USD decimal string with exactly six fractional digits; never a JSON number."
|
||||
},
|
||||
"currency": {
|
||||
"const": "USD"
|
||||
},
|
||||
"unit": {
|
||||
"enum": [
|
||||
"hour",
|
||||
"day",
|
||||
"month",
|
||||
"task"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum_units": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"maximum_units": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"valid_from": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"valid_until": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"terms_url": {
|
||||
"$ref": "#/$defs/httpsUrl"
|
||||
},
|
||||
"payment": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"provider",
|
||||
"payee_did",
|
||||
"checkout_url"
|
||||
],
|
||||
"properties": {
|
||||
"provider": {
|
||||
"const": "coinpay"
|
||||
},
|
||||
"payee_did": {
|
||||
"$ref": "https://schemas.logicsrc.com/logicsrc-agent.schema.json#/$defs/did"
|
||||
},
|
||||
"checkout_url": {
|
||||
"$ref": "#/$defs/httpsUrl"
|
||||
}
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
246
packages/schemas/schemas/logicsrc-openwall-message.schema.json
Normal file
246
packages/schemas/schemas/logicsrc-openwall-message.schema.json
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://schemas.logicsrc.com/logicsrc-openwall-message.schema.json",
|
||||
"title": "OpenWall Message (0.1 draft)",
|
||||
"description": "Private sender-side job document. Structural validation does not authorize delivery or enforce the semantic rules in docs/openwall.md.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"openwall",
|
||||
"id",
|
||||
"sender",
|
||||
"createdAt",
|
||||
"expiresAt",
|
||||
"visibility",
|
||||
"topic",
|
||||
"audience",
|
||||
"content"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"openwall": {
|
||||
"const": "0.1-draft"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
||||
},
|
||||
"sender": {
|
||||
"$ref": "#/$defs/identity"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"notBefore": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"expiresAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"visibility": {
|
||||
"enum": [
|
||||
"private",
|
||||
"public"
|
||||
]
|
||||
},
|
||||
"topic": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 128,
|
||||
"pattern": "^[a-z0-9][a-z0-9._-]*$"
|
||||
},
|
||||
"audience": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/relationships"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/direct"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/public"
|
||||
}
|
||||
]
|
||||
},
|
||||
"content": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"mediaType",
|
||||
"text"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"mediaType": {
|
||||
"const": "text/plain"
|
||||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 4000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"visibility": {
|
||||
"const": "public"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"audience": {
|
||||
"$ref": "#/$defs/public"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
"properties": {
|
||||
"audience": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/relationships"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/direct"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$defs": {
|
||||
"identity": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(did:|https://)",
|
||||
"maxLength": 2048
|
||||
},
|
||||
"selector": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"source",
|
||||
"actor",
|
||||
"groups"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"source": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^https://",
|
||||
"maxLength": 2048
|
||||
},
|
||||
"actor": {
|
||||
"$ref": "#/$defs/identity"
|
||||
},
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"maxItems": 4,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"enum": [
|
||||
"connections",
|
||||
"followers",
|
||||
"following",
|
||||
"users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^https://",
|
||||
"maxLength": 2048
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"groups": {
|
||||
"contains": {
|
||||
"const": "users"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"scope"
|
||||
],
|
||||
"properties": {
|
||||
"scope": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"relationships": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kind",
|
||||
"selectors"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "relationships"
|
||||
},
|
||||
"selectors": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"maxItems": 32,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"$ref": "#/$defs/selector"
|
||||
}
|
||||
},
|
||||
"exclude": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"$ref": "#/$defs/identity"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"direct": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kind",
|
||||
"recipient"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "direct"
|
||||
},
|
||||
"recipient": {
|
||||
"$ref": "#/$defs/identity"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kind"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "public"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
229
packages/schemas/schemas/logicsrc-openwall-receipt.schema.json
Normal file
229
packages/schemas/schemas/logicsrc-openwall-receipt.schema.json
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://schemas.logicsrc.com/logicsrc-openwall-receipt.schema.json",
|
||||
"title": "OpenWall Receipt (0.1 draft)",
|
||||
"description": "Private coordinator event. Authenticity, event ordering and valid state transitions require runtime checks.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"openwall",
|
||||
"id",
|
||||
"messageId",
|
||||
"deliveryId",
|
||||
"recipient",
|
||||
"sequence",
|
||||
"state",
|
||||
"at",
|
||||
"attempt"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"openwall": {
|
||||
"const": "0.1-draft"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
||||
},
|
||||
"messageId": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
||||
},
|
||||
"recipient": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(did:|https://)",
|
||||
"maxLength": 2048
|
||||
},
|
||||
"sequence": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"state": {
|
||||
"enum": [
|
||||
"queued",
|
||||
"sending",
|
||||
"retrying",
|
||||
"accepted",
|
||||
"delivered",
|
||||
"read",
|
||||
"unknown",
|
||||
"failed",
|
||||
"expired",
|
||||
"cancelled"
|
||||
]
|
||||
},
|
||||
"at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"attempt": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 8
|
||||
},
|
||||
"route": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^https://",
|
||||
"maxLength": 2048
|
||||
},
|
||||
"providerMessageId": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 2048
|
||||
},
|
||||
"reason": {
|
||||
"enum": [
|
||||
"not-permitted",
|
||||
"identity-unverified",
|
||||
"unsupported",
|
||||
"rate-limited",
|
||||
"provider-failure",
|
||||
"acceptance-unknown",
|
||||
"retry-exhausted",
|
||||
"deadline-passed",
|
||||
"sender-cancelled"
|
||||
]
|
||||
},
|
||||
"nextAttemptAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"deliveryId": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"state": {
|
||||
"const": "retrying"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"nextAttemptAt",
|
||||
"reason"
|
||||
],
|
||||
"properties": {
|
||||
"nextAttemptAt": {},
|
||||
"reason": {}
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
"not": {
|
||||
"required": [
|
||||
"nextAttemptAt"
|
||||
],
|
||||
"properties": {
|
||||
"nextAttemptAt": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"state": {
|
||||
"enum": [
|
||||
"failed",
|
||||
"unknown",
|
||||
"expired",
|
||||
"cancelled"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"reason"
|
||||
],
|
||||
"properties": {
|
||||
"reason": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"state": {
|
||||
"enum": [
|
||||
"sending",
|
||||
"retrying",
|
||||
"accepted",
|
||||
"delivered",
|
||||
"read",
|
||||
"unknown"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"route"
|
||||
],
|
||||
"properties": {
|
||||
"attempt": {
|
||||
"minimum": 1,
|
||||
"type": "integer"
|
||||
},
|
||||
"route": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"state": {
|
||||
"const": "unknown"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"reason": {
|
||||
"const": "acceptance-unknown"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"state": {
|
||||
"const": "expired"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"reason": {
|
||||
"const": "deadline-passed"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"state": {
|
||||
"const": "cancelled"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"reason": {
|
||||
"const": "sender-cancelled"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
34
packages/sdk/README.md
Normal file
34
packages/sdk/README.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# @logicsrc/sdk
|
||||
|
||||
LogicSRC contract types and constructors for tasks, AgentSwarm sessions and
|
||||
OpenRental descriptors. These helpers construct documents; they do not start
|
||||
agents, resolve remote identities or initiate payments.
|
||||
|
||||
```sh
|
||||
npm install @logicsrc/sdk @logicsrc/validators
|
||||
```
|
||||
|
||||
```ts
|
||||
import { createOpenRental } from "@logicsrc/sdk";
|
||||
import { validate } from "@logicsrc/validators";
|
||||
|
||||
const listing = createOpenRental({
|
||||
id: "https://example.com/listings/research",
|
||||
name: "Research",
|
||||
owner_did: "operator.coinpay",
|
||||
members: [{
|
||||
kind: "openagent",
|
||||
id: "analyst.coinpay",
|
||||
url: "https://example.com/agents/analyst.json"
|
||||
}]
|
||||
});
|
||||
|
||||
const result = validate("openrental", listing);
|
||||
if (!result.ok) throw new Error(JSON.stringify(result.errors));
|
||||
```
|
||||
|
||||
Use `@logicsrc/validators` 0.2.0 or newer for OpenRental validation. See the
|
||||
[OpenRental specification](https://logicsrc.com/docs/openrental) for member
|
||||
bindings, exact decimal rental rates and CoinPay settlement metadata.
|
||||
|
||||
MIT © Profullstack, Inc.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@logicsrc/sdk",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "LogicSRC SDK contract types and client interface.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
|
@ -11,5 +11,19 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"vitest": "^4.0.8"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/profullstack/logicsrc.git",
|
||||
"directory": "packages/sdk"
|
||||
},
|
||||
"homepage": "https://github.com/profullstack/logicsrc/tree/master/packages/sdk",
|
||||
"files": [
|
||||
"dist",
|
||||
"!dist/*.test.*"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
export { createOpenRental } from "./openrental.js";
|
||||
export type {
|
||||
OpenRental, OpenRentalJsonValue, OpenRentalMember, OpenRentalMemberReference,
|
||||
OpenRentalRental, OpenRentalRentalScope
|
||||
} from "./openrental.js";
|
||||
|
||||
export type LogicSrcId = string;
|
||||
|
||||
export interface LogicSrcTask {
|
||||
|
|
|
|||
35
packages/sdk/src/openrental.test.ts
Normal file
35
packages/sdk/src/openrental.test.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { createOpenRental, type OpenRentalMember } from "./index.js";
|
||||
|
||||
const members: OpenRentalMember[] = [
|
||||
{ kind: "openagent", id: "analyst.coinpay", url: "https://example.com/agent.json" },
|
||||
{ kind: "openswarm", id: `ed25519:${"a".repeat(64)}`, url: "https://example.com/manifest.json" }
|
||||
];
|
||||
|
||||
describe("createOpenRental", () => {
|
||||
it.each([members.slice(0, 1), members.slice(1), members])("constructs single-kind and mixed listings", (...fleetMembers) => {
|
||||
const listing = createOpenRental({
|
||||
id: "https://example.com/listings/research", name: "Research", owner_did: "operator.coinpay",
|
||||
members: fleetMembers
|
||||
});
|
||||
expect(listing.type).toBe("logicsrc.openrental");
|
||||
expect(listing.version).toBe("0.1");
|
||||
expect(listing.members).toEqual(fleetMembers);
|
||||
expect(listing.rentals).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps rental amounts as decimal strings and preserves metadata", () => {
|
||||
const input: Parameters<typeof createOpenRental>[0] = {
|
||||
id: "https://example.com/listings/research", name: "Research", owner_did: "operator.coinpay", members,
|
||||
metadata: { support: { languages: ["en", "fr"] } },
|
||||
rentals: [{
|
||||
id: "hourly", scope: { kind: "listing" },
|
||||
rate: { amount: "9007199254740993.123456", currency: "USD", unit: "hour" },
|
||||
payment: { provider: "coinpay", payee_did: "operator.coinpay", checkout_url: "https://example.com/rent" }
|
||||
}]
|
||||
};
|
||||
const snapshot = structuredClone(input);
|
||||
expect(createOpenRental(input)).toEqual({ ...input, type: "logicsrc.openrental", version: "0.1" });
|
||||
expect(input).toEqual(snapshot);
|
||||
});
|
||||
});
|
||||
71
packages/sdk/src/openrental.ts
Normal file
71
packages/sdk/src/openrental.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
export type OpenRentalJsonValue =
|
||||
| null | boolean | number | string
|
||||
| OpenRentalJsonValue[] | { [key: string]: OpenRentalJsonValue };
|
||||
|
||||
/** OpenAgent binds to a logicsrc.agent DID; OpenSwarm binds to a file key. */
|
||||
export type OpenRentalMemberReference =
|
||||
| { kind: "openagent"; id: string }
|
||||
| { kind: "openswarm"; id: `ed25519:${string}` };
|
||||
|
||||
export type OpenRentalMember = OpenRentalMemberReference & {
|
||||
/** HTTPS URL of the agent profile or the signed ipfile manifest. */
|
||||
url: string;
|
||||
name?: string;
|
||||
role?: string;
|
||||
metadata?: Record<string, OpenRentalJsonValue>;
|
||||
};
|
||||
|
||||
export type OpenRentalRentalScope =
|
||||
| { kind: "listing" }
|
||||
| { kind: "members"; members: OpenRentalMemberReference[] };
|
||||
|
||||
export interface OpenRentalRental {
|
||||
id: string;
|
||||
name?: string;
|
||||
scope: OpenRentalRentalScope;
|
||||
rate: {
|
||||
/** Exact non-negative USD decimal string, with six fractional digits. */
|
||||
amount: string;
|
||||
currency: "USD";
|
||||
/** Whole billing units; a month is 30 days, a task an agreed deliverable. */
|
||||
unit: "hour" | "day" | "month" | "task";
|
||||
};
|
||||
minimum_units?: number;
|
||||
maximum_units?: number;
|
||||
valid_from?: string;
|
||||
valid_until?: string;
|
||||
terms_url?: string;
|
||||
payment: {
|
||||
provider: "coinpay";
|
||||
payee_did: string;
|
||||
/** Merchant-published HTTPS checkout entry point; no fixed CoinPay API. */
|
||||
checkout_url: string;
|
||||
};
|
||||
metadata?: Record<string, OpenRentalJsonValue>;
|
||||
}
|
||||
|
||||
export interface OpenRental {
|
||||
type: "logicsrc.openrental";
|
||||
version: "0.1";
|
||||
/** Stable HTTPS listing identifier, unique at its publisher's origin. */
|
||||
id: string;
|
||||
name: string;
|
||||
owner_did: string;
|
||||
description?: string;
|
||||
updated_at?: string;
|
||||
availability?: "available" | "busy" | "offline" | "unknown";
|
||||
tags?: string[];
|
||||
capabilities?: string[];
|
||||
metadata?: Record<string, OpenRentalJsonValue>;
|
||||
members: OpenRentalMember[];
|
||||
rentals?: OpenRentalRental[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a descriptor without fetching members or initiating payments.
|
||||
* Use validate("openrental", document) from @logicsrc/validators before use:
|
||||
* TypeScript alone cannot check DID/key formats or rental references.
|
||||
*/
|
||||
export function createOpenRental(input: Omit<OpenRental, "type" | "version">): OpenRental {
|
||||
return { ...input, type: "logicsrc.openrental", version: "0.1" };
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@logicsrc/validators",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "LogicSRC schema validation helpers.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
|
@ -11,10 +11,10 @@
|
|||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"test": "vitest run src",
|
||||
"validate:fixtures": "node dist/cli.js task ../schemas/fixtures/task.yaml && node dist/cli.js agent ../schemas/fixtures/agent.yaml && node dist/cli.js agentad-ad ../schemas/fixtures/agentad-ad.yaml && node dist/cli.js agentad-placement ../schemas/fixtures/agentad-placement.yaml && node dist/cli.js repo ../schemas/fixtures/repo.yaml && node dist/cli.js pull-request ../schemas/fixtures/pull-request.yaml && node dist/cli.js openontology-manifest ../schemas/fixtures/openontology/valid/manifest.json && node dist/cli.js openontology-claim ../schemas/fixtures/openontology/valid/claim-relationship.json && node dist/cli.js openontology-changeset ../schemas/fixtures/openontology/valid/changeset.json && node dist/cli.js opencontext-manifest ../schemas/fixtures/opencontext/valid/manifest.json && node dist/cli.js opencontext-object ../schemas/fixtures/opencontext/valid/object-policy.json && node dist/cli.js opencontext-bundle ../schemas/fixtures/opencontext/valid/bundle.json && node dist/cli.js opencontext-decision ../schemas/fixtures/opencontext/valid/decision.json && node dist/cli.js opencontext-role ../schemas/fixtures/opencontext/valid/role.json && node dist/cli.js opencontext-provenance ../schemas/fixtures/opencontext/valid/provenance.json && node dist/cli.js opencontext-diagnostic ../schemas/fixtures/opencontext/valid/diagnostic.json && node dist/cli.js opencontext-audit-event ../schemas/fixtures/opencontext/valid/audit-event.json"
|
||||
"validate:fixtures": "node dist/cli.js task ../schemas/fixtures/task.yaml && node dist/cli.js agent ../schemas/fixtures/agent.yaml && node dist/cli.js agentad-ad ../schemas/fixtures/agentad-ad.yaml && node dist/cli.js agentad-placement ../schemas/fixtures/agentad-placement.yaml && node dist/cli.js repo ../schemas/fixtures/repo.yaml && node dist/cli.js pull-request ../schemas/fixtures/pull-request.yaml && node dist/cli.js openontology-manifest ../schemas/fixtures/openontology/valid/manifest.json && node dist/cli.js openontology-claim ../schemas/fixtures/openontology/valid/claim-relationship.json && node dist/cli.js openontology-changeset ../schemas/fixtures/openontology/valid/changeset.json && node dist/cli.js opencontext-manifest ../schemas/fixtures/opencontext/valid/manifest.json && node dist/cli.js opencontext-object ../schemas/fixtures/opencontext/valid/object-policy.json && node dist/cli.js opencontext-bundle ../schemas/fixtures/opencontext/valid/bundle.json && node dist/cli.js opencontext-decision ../schemas/fixtures/opencontext/valid/decision.json && node dist/cli.js opencontext-role ../schemas/fixtures/opencontext/valid/role.json && node dist/cli.js opencontext-provenance ../schemas/fixtures/opencontext/valid/provenance.json && node dist/cli.js opencontext-diagnostic ../schemas/fixtures/opencontext/valid/diagnostic.json && node dist/cli.js opencontext-audit-event ../schemas/fixtures/opencontext/valid/audit-event.json && node dist/cli.js openrental ../schemas/fixtures/openrental/mixed.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/broadcast.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/direct.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/announcement.json && node dist/cli.js openwall-receipt ../schemas/fixtures/openwall/receipt-accepted.json && node dist/cli.js openwall-receipt ../schemas/fixtures/openwall/receipt-retrying.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@logicsrc/schemas": "^0.1.0",
|
||||
"@logicsrc/schemas": "^0.2.0",
|
||||
"ajv": "^8.17.1",
|
||||
"ajv-formats": "^3.0.1",
|
||||
"yaml": "^2.8.1"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import * as addFormatsModule from "ajv-formats";
|
|||
import type { ErrorObject } from "ajv";
|
||||
import { parse } from "yaml";
|
||||
import { isSchemaKind, schemas, type SchemaKind } from "./schemas.js";
|
||||
import { validateOpenRentalReferences } from "./openrental.js";
|
||||
|
||||
type CompiledSchema = { (data: unknown): boolean; errors?: ErrorObject[] | null };
|
||||
|
||||
|
|
@ -61,6 +62,10 @@ export function validate(kind: SchemaKind, data: unknown): ValidationResult {
|
|||
const ok = validateDocument(data);
|
||||
|
||||
if (ok) {
|
||||
if (kind === "openrental") {
|
||||
const errors = validateOpenRentalReferences(data);
|
||||
if (errors.length) return { ok: false, kind, errors };
|
||||
}
|
||||
return { ok: true, kind, data };
|
||||
}
|
||||
|
||||
|
|
|
|||
141
packages/validators/src/openrental.test.ts
Normal file
141
packages/validators/src/openrental.test.ts
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { assertSchemaKind, createValidator, schemas, validate } from "./index.js";
|
||||
|
||||
function fixture() {
|
||||
return JSON.parse(readFileSync(new URL("../../schemas/fixtures/openrental/mixed.json", import.meta.url), "utf8"));
|
||||
}
|
||||
|
||||
function errorAt(data: unknown, keyword: string, path: string) {
|
||||
const result = validate("openrental", data);
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.errors).toContainEqual(expect.objectContaining({ keyword, instancePath: path }));
|
||||
}
|
||||
|
||||
describe("OpenRental", () => {
|
||||
it("registers a publicly exported schema and validates the mixed fixture", () => {
|
||||
expect(assertSchemaKind("openrental")).toBe("openrental");
|
||||
expect(validate("openrental", fixture()).ok).toBe(true);
|
||||
const ajv = createValidator();
|
||||
ajv.addSchema(schemas.agent);
|
||||
expect(ajv.compile(schemas.openrental)(fixture())).toBe(true);
|
||||
});
|
||||
|
||||
it("validates the complete descriptor in the public specification", () => {
|
||||
const doc = readFileSync(new URL("../../../docs/openrental.md", import.meta.url), "utf8");
|
||||
const example = doc.match(/```json\n([\s\S]*?)\n```/);
|
||||
expect(example).not.toBeNull();
|
||||
expect(validate("openrental", JSON.parse(example![1])).ok).toBe(true);
|
||||
});
|
||||
|
||||
it.each(["openagent", "openswarm"])("accepts a listing containing only %s members", (kind) => {
|
||||
const listing = fixture();
|
||||
listing.members = listing.members.filter((member: { kind: string }) => member.kind === kind);
|
||||
// A whole-listing rate applies to either single-kind listing without expansion.
|
||||
listing.rentals = [listing.rentals[0]];
|
||||
expect(validate("openrental", listing).ok).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts membership without rental offers and preserves extension metadata", () => {
|
||||
const listing = fixture();
|
||||
delete listing.rentals;
|
||||
listing.metadata = { custom: { nested: [null, true, 42, "value"] } };
|
||||
const snapshot = structuredClone(listing);
|
||||
expect(validate("openrental", listing).ok).toBe(true);
|
||||
expect(listing).toEqual(snapshot);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["no members", (f: ReturnType<typeof fixture>) => { f.members = []; }],
|
||||
["unsupported kind", (f: ReturnType<typeof fixture>) => { f.members[0].kind = "openrental"; }],
|
||||
["agent without identity", (f: ReturnType<typeof fixture>) => { delete f.members[0].id; }],
|
||||
["swarm without identity", (f: ReturnType<typeof fixture>) => { delete f.members[1].id; }],
|
||||
["swarm with an agent DID", (f: ReturnType<typeof fixture>) => { f.members[1].id = "analyst.coinpay"; }],
|
||||
["agent with a swarm key", (f: ReturnType<typeof fixture>) => { f.members[0].id = f.members[1].id; }],
|
||||
["short swarm key", (f: ReturnType<typeof fixture>) => { f.members[1].id = "ed25519:abcd"; }],
|
||||
["non-HTTPS member URL", (f: ReturnType<typeof fixture>) => { f.members[0].url = "http://example.com/agent"; }],
|
||||
["unsupported version", (f: ReturnType<typeof fixture>) => { f.version = "9.0"; }],
|
||||
["unknown contract field", (f: ReturnType<typeof fixture>) => { f.rental = []; }]
|
||||
])("rejects %s", (_, mutate) => {
|
||||
const listing = fixture();
|
||||
mutate(listing);
|
||||
expect(validate("openrental", listing).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects duplicate member identities even when URL and metadata differ", () => {
|
||||
const listing = fixture();
|
||||
listing.members.push({ ...listing.members[0], url: "https://elsewhere.example/agent", metadata: { alias: true } });
|
||||
errorAt(listing, "uniqueMember", "/members/2");
|
||||
});
|
||||
|
||||
it("rejects duplicate rental IDs", () => {
|
||||
const listing = fixture();
|
||||
listing.rentals[1].id = listing.rentals[0].id;
|
||||
errorAt(listing, "uniqueRental", "/rentals/1/id");
|
||||
});
|
||||
|
||||
it("rejects dangling references after a member is removed", () => {
|
||||
const listing = fixture();
|
||||
listing.members.shift();
|
||||
errorAt(listing, "memberReference", "/rentals/1/scope/members/0");
|
||||
});
|
||||
|
||||
it("accepts a rental scoped to both kinds without counting a member twice", () => {
|
||||
const listing = fixture();
|
||||
listing.rentals[1].scope.members.push({ kind: "openswarm", id: listing.members[1].id });
|
||||
expect(validate("openrental", listing).ok).toBe(true);
|
||||
listing.rentals[1].scope.members.push({ ...listing.rentals[1].scope.members[0] });
|
||||
errorAt(listing, "uniqueMember", "/rentals/1/scope/members/2");
|
||||
});
|
||||
|
||||
it.each([25, -1, "-1.000000", "01.000000", "1e3", "NaN", "Infinity", "1.00", "0.0000001"])(
|
||||
"rejects an inexact or invalid amount %s", (amount) => {
|
||||
const listing = fixture();
|
||||
listing.rentals[0].rate.amount = amount;
|
||||
expect(validate("openrental", listing).ok).toBe(false);
|
||||
}
|
||||
);
|
||||
|
||||
it.each(["0.000000", "0.000001", "9007199254740993.123456"])("preserves exact amount %s", (amount) => {
|
||||
const listing = fixture();
|
||||
listing.rentals[0].rate.amount = amount;
|
||||
expect(validate("openrental", listing).ok).toBe(true);
|
||||
expect(listing.rentals[0].rate.amount).toBe(amount);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["non-CoinPay provider", (r: ReturnType<typeof fixture>) => { r.payment.provider = "other"; }],
|
||||
["missing CoinPay metadata", (r: ReturnType<typeof fixture>) => { delete r.payment; }],
|
||||
["missing payee", (r: ReturnType<typeof fixture>) => { delete r.payment.payee_did; }],
|
||||
["missing checkout", (r: ReturnType<typeof fixture>) => { delete r.payment.checkout_url; }],
|
||||
["insecure checkout", (r: ReturnType<typeof fixture>) => { r.payment.checkout_url = "http://example.com/checkout"; }],
|
||||
["unsupported currency", (r: ReturnType<typeof fixture>) => { r.rate.currency = "EUR"; }],
|
||||
["missing unit", (r: ReturnType<typeof fixture>) => { delete r.rate.unit; }],
|
||||
["unsupported unit", (r: ReturnType<typeof fixture>) => { r.rate.unit = "second"; }],
|
||||
["fractional billing units", (r: ReturnType<typeof fixture>) => { r.minimum_units = 0.5; }],
|
||||
["unsafe integer units", (r: ReturnType<typeof fixture>) => { r.maximum_units = 9007199254740992; }],
|
||||
["empty member scope", (r: ReturnType<typeof fixture>) => { r.scope = { kind: "members", members: [] }; }],
|
||||
["ambiguous listing scope", (r: ReturnType<typeof fixture>) => { r.scope.members = []; }]
|
||||
])("rejects a rental with %s", (_, mutate) => {
|
||||
const listing = fixture();
|
||||
mutate(listing.rentals[0]);
|
||||
expect(validate("openrental", listing).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects maximum units below the minimum", () => {
|
||||
const listing = fixture();
|
||||
listing.rentals[0].minimum_units = 25;
|
||||
errorAt(listing, "rentalUnits", "/rentals/0/maximum_units");
|
||||
});
|
||||
|
||||
it("checks offer windows by instant, including timezone offsets", () => {
|
||||
const listing = fixture();
|
||||
listing.rentals[0].valid_from = "2026-09-13T12:00:00Z";
|
||||
listing.rentals[0].valid_until = "2026-09-13T14:00:00+02:00";
|
||||
errorAt(listing, "rentalPeriod", "/rentals/0/valid_until");
|
||||
listing.rentals[0].valid_until = "2026-09-13T13:00:00+02:00";
|
||||
errorAt(listing, "rentalPeriod", "/rentals/0/valid_until");
|
||||
listing.rentals[0].valid_until = "2026-09-13T15:00:00+02:00";
|
||||
expect(validate("openrental", listing).ok).toBe(true);
|
||||
});
|
||||
});
|
||||
72
packages/validators/src/openrental.ts
Normal file
72
packages/validators/src/openrental.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import type { ErrorObject } from "ajv";
|
||||
|
||||
type MemberReference = { kind: "openagent" | "openswarm"; id: string };
|
||||
|
||||
// Called only after the JSON Schema has checked the shape. Keep the checks
|
||||
// which need sibling values here; uniqueItems cannot enforce identity when
|
||||
// two entries have different URLs or metadata.
|
||||
type FleetReferences = {
|
||||
members: MemberReference[];
|
||||
rentals?: Array<{
|
||||
id: string;
|
||||
scope: { kind: "listing" } | { kind: "members"; members: MemberReference[] };
|
||||
minimum_units?: number;
|
||||
maximum_units?: number;
|
||||
valid_from?: string;
|
||||
valid_until?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
function memberKey(member: MemberReference): string {
|
||||
return JSON.stringify([member.kind, member.id]);
|
||||
}
|
||||
|
||||
export function validateOpenRentalReferences(data: unknown): ErrorObject[] {
|
||||
const listing = data as FleetReferences;
|
||||
const errors: ErrorObject[] = [];
|
||||
function report(keyword: string, instancePath: string, message: string) {
|
||||
errors.push({ keyword, instancePath, schemaPath: "#/openrental-semantics", params: {}, message });
|
||||
}
|
||||
|
||||
const members = new Set<string>();
|
||||
listing.members.forEach((member, i) => {
|
||||
const key = memberKey(member);
|
||||
if (members.has(key)) {
|
||||
report("uniqueMember", `/members/${i}`, "duplicates an existing member kind and id");
|
||||
}
|
||||
members.add(key);
|
||||
});
|
||||
|
||||
const rentals = new Set<string>();
|
||||
listing.rentals?.forEach((rental, i) => {
|
||||
const path = `/rentals/${i}`;
|
||||
if (rentals.has(rental.id)) {
|
||||
report("uniqueRental", `${path}/id`, "duplicates an existing rental id");
|
||||
}
|
||||
rentals.add(rental.id);
|
||||
|
||||
if (rental.scope.kind === "members") {
|
||||
const scopedMembers = new Set<string>();
|
||||
rental.scope.members.forEach((member, j) => {
|
||||
const key = memberKey(member);
|
||||
const memberPath = `${path}/scope/members/${j}`;
|
||||
if (!members.has(key)) {
|
||||
report("memberReference", memberPath, "must reference a member of this listing by kind and id");
|
||||
}
|
||||
if (scopedMembers.has(key)) {
|
||||
report("uniqueMember", memberPath, "duplicates a member in this rental scope");
|
||||
}
|
||||
scopedMembers.add(key);
|
||||
});
|
||||
}
|
||||
|
||||
if (rental.maximum_units !== undefined && rental.maximum_units < (rental.minimum_units ?? 1)) {
|
||||
report("rentalUnits", `${path}/maximum_units`, "must be at least minimum_units");
|
||||
}
|
||||
if (rental.valid_from && rental.valid_until && Date.parse(rental.valid_from) >= Date.parse(rental.valid_until)) {
|
||||
report("rentalPeriod", `${path}/valid_until`, "must be later than valid_from");
|
||||
}
|
||||
});
|
||||
|
||||
return errors;
|
||||
}
|
||||
120
packages/validators/src/openwall.test.ts
Normal file
120
packages/validators/src/openwall.test.ts
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validate } from "./index.js";
|
||||
|
||||
function fixture(name: string) {
|
||||
return JSON.parse(readFileSync(new URL(`../../schemas/fixtures/openwall/${name}.json`, import.meta.url), "utf8"));
|
||||
}
|
||||
|
||||
describe("OpenWall draft structural contracts", () => {
|
||||
it.each(["broadcast", "direct", "announcement"])("accepts the %s message fixture", (name) => {
|
||||
expect(validate("openwall-message", fixture(name))).toMatchObject({ ok: true });
|
||||
});
|
||||
|
||||
it.each(["receipt-accepted", "receipt-retrying"])("accepts the %s fixture", (name) => {
|
||||
expect(validate("openwall-receipt", fixture(name))).toMatchObject({ ok: true });
|
||||
});
|
||||
|
||||
it("requires a service scope for every users selector", () => {
|
||||
const message = fixture("broadcast");
|
||||
delete message.audience.selectors[0].scope;
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("permits a union of relationship groups and sources", () => {
|
||||
const message = fixture("broadcast");
|
||||
message.audience.selectors.push({
|
||||
source: "https://social.example/graph",
|
||||
actor: "did:web:ops.example",
|
||||
groups: ["connections", "followers", "following"]
|
||||
});
|
||||
expect(validate("openwall-message", message).ok).toBe(true);
|
||||
});
|
||||
|
||||
it.each(["broadcast", "direct"])("rejects changing a %s to public while retaining recipients", (name) => {
|
||||
const message = fixture(name);
|
||||
message.visibility = "public";
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a private message with an unrestricted public audience", () => {
|
||||
const message = fixture("announcement");
|
||||
message.visibility = "private";
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects recipient metadata in a public audience", () => {
|
||||
const message = fixture("announcement");
|
||||
message.audience.recipient = "did:web:ada.example";
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("requires explicit groups and rejects an implicit all audience", () => {
|
||||
const message = fixture("broadcast");
|
||||
message.audience.selectors[0].groups = [];
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
message.audience.selectors[0].groups = ["all"];
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("requires a resolved recipient identity rather than a display handle", () => {
|
||||
const message = fixture("direct");
|
||||
message.audience.recipient = "ada.example";
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects absent expiry, malformed timestamps and oversized text", () => {
|
||||
const message = fixture("direct");
|
||||
delete message.expiresAt;
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
message.expiresAt = "tomorrow";
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
message.expiresAt = "2026-09-13T13:00:00Z";
|
||||
message.content.text = "x".repeat(4001);
|
||||
expect(validate("openwall-message", message).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("requires receipt delivery correlation and disallows audience disclosure", () => {
|
||||
const receipt = fixture("receipt-accepted");
|
||||
delete receipt.deliveryId;
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
receipt.deliveryId = "unscoped-message-id";
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
receipt.deliveryId = "urn:uuid:db925d64-4e1a-4e5a-83c1-e37b68aa5eef";
|
||||
receipt.recipients = ["did:web:other.example"];
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("requires retry timing and a reason and disallows retry timing on acceptance", () => {
|
||||
const receipt = fixture("receipt-retrying");
|
||||
delete receipt.nextAttemptAt;
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
receipt.nextAttemptAt = "2026-09-13T12:01:00Z";
|
||||
delete receipt.reason;
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
receipt.reason = "rate-limited";
|
||||
receipt.state = "accepted";
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("represents ambiguous provider acceptance separately from a known failure", () => {
|
||||
const receipt = fixture("receipt-accepted");
|
||||
receipt.state = "unknown";
|
||||
receipt.reason = "acceptance-unknown";
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(true);
|
||||
receipt.reason = "rate-limited";
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
delete receipt.reason;
|
||||
receipt.state = "failed";
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("requires a real route and attempt for provider acceptance", () => {
|
||||
const receipt = fixture("receipt-accepted");
|
||||
receipt.attempt = 0;
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
receipt.attempt = 1;
|
||||
delete receipt.route;
|
||||
expect(validate("openwall-receipt", receipt).ok).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
* could not load a single schema.
|
||||
*/
|
||||
import agentSchema from "@logicsrc/schemas/agent" with { type: "json" };
|
||||
import openrentalSchema from "@logicsrc/schemas/openrental" with { type: "json" };
|
||||
import accountAuditEventSchema from "@logicsrc/schemas/account-audit-event" with { type: "json" };
|
||||
import accountGrantSchema from "@logicsrc/schemas/account-grant" with { type: "json" };
|
||||
import accountProviderSchema from "@logicsrc/schemas/account-provider" with { type: "json" };
|
||||
|
|
@ -68,8 +69,14 @@ import credsManifestSchema from "@logicsrc/schemas/opencreds-manifest" with { ty
|
|||
import credsDatabaseSchema from "@logicsrc/schemas/opencreds-database" with { type: "json" };
|
||||
import credsAuditEventSchema from "@logicsrc/schemas/opencreds-audit-event" with { type: "json" };
|
||||
|
||||
import openwallMessageSchema from "@logicsrc/schemas/openwall-message" with { type: "json" };
|
||||
import openwallReceiptSchema from "@logicsrc/schemas/openwall-receipt" with { type: "json" };
|
||||
|
||||
export const schemas = {
|
||||
"openwall-message": openwallMessageSchema,
|
||||
"openwall-receipt": openwallReceiptSchema,
|
||||
agent: agentSchema,
|
||||
openrental: openrentalSchema,
|
||||
"account-audit-event": accountAuditEventSchema,
|
||||
"account-grant": accountGrantSchema,
|
||||
"account-provider": accountProviderSchema,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue