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
37 changes: 37 additions & 0 deletions .ctg/policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: ctg/v1

policyId: agent-protocols-policy
description: Quality policy for agent-protocols repository

blocking:
severity:
critical: true
high: false
medium: false
low: false
category:
auth: false
payment: false
validation: false
data: false
config: false
maintainability: false
testing: false
compatibility: false
releaseRisk: false
security: false
rules:
count:
criticalMax: 0
highMax: 100
mediumMax: 100
lowMax: 100

readiness:
criticalFindingStatus: needs_review
requireLlm: false
allowSuppressed: true

suppression:
file: .ctg/suppressions.yaml
expiryWarningDays: 30
8 changes: 8 additions & 0 deletions .ctg/suppressions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: ctg/v1

suppressions:
# LARGE_MODULE suppression
- rule_id: LARGE_MODULE
path: src/validation/semantic-validator.ts
reason: "Semantic validator with 22 validation rules. Split into rule-specific validators when exceeds 30 rules."
expiry: 2027-05-02
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: agent-protocols-v2

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
protocol:
runs-on: ubuntu-latest
strategy:
matrix:
node: [24]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run generate:check
- run: npm run typecheck
- run: npm run lint
- run: npm test
- run: npm run build
- run: npm run test:package

migration:
runs-on: ubuntu-latest
needs: protocol
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm test -- --run tests/v2/protocol-v2.test.ts

shipyard-conformance:
runs-on: ubuntu-latest
needs: protocol
steps:
- uses: actions/checkout@v7
with:
path: agent-protocols
- uses: actions/checkout@v7
with:
repository: RNA4219/shipyard-cp
path: shipyard-cp
- uses: actions/setup-node@v6
with:
node-version: 24
- uses: pnpm/action-setup@v6
with:
version: 9.15.9
run_install: false
- name: Build beta package
working-directory: agent-protocols
run: npm ci && npm run build && npm pack --pack-destination ../shipyard-cp
- name: Install and typecheck Shipyard
working-directory: shipyard-cp
run: |
node -e "const fs = require('node:fs'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); pkg.dependencies['@rna4219/agent-protocols'] = 'file:./rna4219-agent-protocols-2.0.0-beta.1.tgz'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
pnpm install --no-frozen-lockfile
pnpm run build:packages
pnpm run check
146 changes: 38 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,56 @@
# agent-protocols
# @rna4219/agent-protocols

Contract-driven AI workflow protocol specifications.
AI workflow契約の唯一の正本です。v2は破壊的変更であり、Node.js 24以上、ESM、公開 npm scoped package
として配布します。

## Purpose
- package: `@rna4219/agent-protocols@2.0.0-beta.1`
- 正本Schema: [schemas/v2](./schemas/v2)
- v1入力Schema: [schemas](./schemas)(移行専用)
- 正本仕様: [docs/requirements.md](./docs/requirements.md)
- 参照runtime: [Agent_tools/shipyard-cp](../Agent_tools/shipyard-cp)

Defines 5 contract types for AI agent orchestration:
- `IntentContract` - Intent request with capability requirements
- `TaskSeed` - Executable work unit
- `Acceptance` - Execution verification result
- `PublishGate` - Approval gate for publish decisions
- `Evidence` - Immutable execution record
## 契約フロー

## File Structure
`IntentContract -> TaskSeed -> Acceptance -> PublishGate -> Evidence`

```
schemas/ # JSON Schema definitions
examples/ # Sample JSON files
src/validation/ # Semantic validator
tests/ # Test files
scripts/ # Utility scripts
docs/ # Documentation
```

## Contract Flow

```
IntentContract -> TaskSeed -> Acceptance -> PublishGate -> Evidence
IC-xxx -> TS-xxx -> AC-xxx -> PG-xxx -> EV-xxx
```
共通メタデータは `schemaVersion: "2.0.0"`、種別付きULID(例:
`Acceptance_01J...`)、`revision`、RFC 3339 UTC時刻、`lifecycle`を使います。
イベントはCloudEvents 1.0です。Evidenceはfinal/revision 1/不変です。

## ID Prefixes
## Public API

| Kind | Prefix | Pattern |
|---|---|---|
| IntentContract | IC | `^IC-[0-9]{3,}$` |
| TaskSeed | TS | `^TS-[0-9]{3,}$` |
| Acceptance | AC | `^AC-[0-9]{3,}$` |
| PublishGate | PG | `^PG-[0-9]{3,}$` |
| Evidence | EV | `^EV-[0-9]{3,}$` |
`src`から次を公開します。

## States
- `safeParseContract` / `parseContract`
- `safeParseEvent` / `parseEvent`
- `validateTransition` / `validateContractGraph`
- `deriveGenerationPolicy` / `assessPolicy`
- `createPublishGate` / `applyApproval` / `expireGate`
- `createContractId` / `createContractEvent`

`Draft -> Active -> Frozen -> Published -> Superseded -> Revoked -> Archived`
safe APIのエラーは `{ code, path, message, source }` です。未知のkind、capability、roleはfail-closedで拒否します。

## Approval Rules

| riskLevel | requiredApprovals | autoApproved |
|---|---|---|
| low | [] | true |
| medium | [] | true |
| high | [project_lead, security_reviewer] | false |
| critical | [project_lead, security_reviewer, release_manager] | false |

## Capabilities

```
read_repo, write_repo, install_deps, network_access, read_secrets, publish_release
```
## v1移行

## Generation Policy Derivation
移行CLIは新規の絶対出力先だけを受け付け、既存出力を上書きしません。

```powershell
agent-protocols migrate-v1 <絶対入力パス> --namespace <名前空間> --out <絶対出力ディレクトリ>
```
IF capabilities IN [read_repo] OR [read_repo, write_repo]:
auto_activate = true
requiredActivationApprovals = []
ELSE IF install_deps OR network_access OR read_secrets IN capabilities:
auto_activate = false
requiredActivationApprovals = [project_lead, security_reviewer]
ELSE IF publish_release IN capabilities:
auto_activate = false
requiredActivationApprovals = [project_lead, release_manager]
```

## Risk Level Derivation

```
IF productionDataAccess OR externalSecretTransmission OR legalConcern OR rollbackImpossible:
riskLevel = critical
ELSE IF install_deps OR network_access OR read_secrets OR publish_release IN capabilities:
riskLevel = high
ELSE IF write_repo IN capabilities:
riskLevel = medium
ELSE:
riskLevel = low
```
出力は `contracts.v2.jsonl`、`id-map.json`、`migration-report.json`です。

## Commands
## 開発

```bash
npm install # Install dependencies
npm test # Run all tests (83 tests)
npx tsx scripts/demo.ts # Run demo script
```powershell
npm install
npm test
npm run typecheck
npm run lint
npm run build
npm run generate:check
npm run test:package
```

## Human Documentation

- [README (Japanese)](docs/README-ja.md)
- [README (English)](docs/README-en.md)

## Source of Truth

[docs/requirements.md](docs/requirements.md) is the authoritative specification.

## Integrations

- [`workflow-cookbook`](../workflow-cookbook/README.md)
can emit `Evidence` records through its `StructuredLogger` plugin system.
- Reference plugin guide:
[`tools/protocols/README.md`](../workflow-cookbook/tools/protocols/README.md)
- Reference plugin config sample:
[`examples/inference_plugins.agent_protocol.sample.json`](../workflow-cookbook/examples/inference_plugins.agent_protocol.sample.json)
- Reference Evidence consumer sample:
[`examples/agent_protocol_evidence_consumer.sample.py`](../workflow-cookbook/examples/agent_protocol_evidence_consumer.sample.py)

## Key Files

| Path | Purpose |
|---|---|
| [schemas/](schemas/) | JSON Schema definitions |
| [src/validation/](src/validation/) | Semantic validation logic |
| [docs/requirements.md](docs/requirements.md) | Authoritative requirements |
| [docs/protocol.md](docs/protocol.md) | Protocol specification |
| [docs/operations.md](docs/operations.md) | Operations policy |
| [docs/RUNBOOK.md](docs/RUNBOOK.md) | Runbook |
| [docs/BLUEPRINT.md](docs/BLUEPRINT.md) | Blueprint |
契約Schema・型・検証・policy・生成規則は本repoが所有します。ShipyardはDB、イベント配送、retry/lock、scheduler、
worker実行、runtime adapterだけを所有し、契約判定を重複実装しません。
Loading