Skip to content

feat(cli): introduce CNC Agent Protocol v1 - #1483

Draft
yyyyaaa wants to merge 20 commits into
mainfrom
yyyyaaa/agentic-cnc-cli-audit
Draft

feat(cli): introduce CNC Agent Protocol v1#1483
yyyyaaa wants to merge 20 commits into
mainfrom
yyyyaaa/agentic-cnc-cli-audit

Conversation

@yyyyaaa

@yyyyaaa yyyyaaa commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Important

This remains a draft while CI validates the port-forwarded release boundary. The previous 30-path conflict set is resolved: this branch is now based directly on origin/main at f9611d3a1.

Summary

This PR introduces CNC Agent Protocol v1 (constructive.dev/cli/v1) and moves the current CNC command surface onto a Constructive-owned, registry-backed runtime:

  • contexts and authentication
  • raw GraphQL execution
  • transactional code generation
  • GraphQL server and explorer lifecycle operations
  • deterministic discovery, schemas, docs, Skills, and completions

The protocol provides validated JSON/JSONL output, stable exits (0, 1, 2, 70, 130), cancellation, recursive redaction, explicit execution context, and noninteractive agent behavior. Structured stdout contains protocol data only and structured stderr remains empty.

Port-forward decisions

The branch was rebased and reconciled onto current main instead of resolving the old merge mechanically.

  • Current-main architecture wins where the old branch diverged.
  • The old jobs/functions changes were dropped because those packages no longer exist in this monorepo and current job ownership has moved to constructive-db; this PR does not revive deleted code or publish a false jobs up capability.
  • The packed acceptance suite now verifies that jobs up is unavailable through the registry.
  • GraphQL server changes remain infrastructure-only: explicit runtime environment, cache ownership, and lifecycle boundaries. No durable product workflow was added to graphql/server.
  • Codegen was adapted to current routing schema and package APIs while preserving plan-first, ownership-aware, transactional, concurrency-safe behavior.
  • Legacy published CNC handlers were removed so supported command families cannot bypass registry safety gates.
  • No Incur dependency was added.

Protocol and safety guarantees

  • JSON emits one terminal envelope.
  • JSONL emits operation.started, validated domain events, and exactly one terminal event.
  • Operations do not prompt, print, open browsers, call process.exit/process.chdir, or read ambient state.
  • Agent remote operations require explicit context.
  • Secrets are recursively redacted from results, errors, events, debug details, artifacts, and recovery actions.
  • Dry-run commands perform zero writes.
  • Long-running services expose readiness and awaited cleanup.
  • GraphQL execution is typed, cancellable, timeout-aware, and mutation-gated.
  • State writes and codegen publication are atomic and lock-owned.

Thermonuclear maintainability review

The post-port review covered every new agentic CNC surface and led to concrete decomposition before this update:

  • split the 978-line runtime registry into registry and command-validation modules;
  • split the 956-line execution module into orchestration and execution-support modules;
  • split the 911-line config manager into storage, validation, and error modules;
  • centralized HTTP endpoint policy and operation output suppression;
  • removed duplicate multi-target codegen result projection;
  • tightened loose key conversion types and made lock cleanup preserve primary failures.

No reviewed new production file remains above 700 lines, and targeted ESLint is clean.

Compatibility and release boundary

  • @constructive-io/cli-runtime@0.1.0
  • @constructive-io/cli@8.16.3
  • @constructive-io/graphql-codegen@5.18.3
  • Node 18.17+ remains supported for the core CLI surface.
  • Optional codegen/service packages remain lazy and return CAPABILITY_UNAVAILABLE when absent.
  • Two optional release-set dependencies remain on lru-cache v10 because v11 requires Node 20 and would violate the CLI's declared Node 18.17 floor.

Verification

  • frozen lockfile install and workspace policy check
  • test-batch coverage: 108 packages with tests, all assigned
  • full topological monorepo build: 124 packages
  • CLI runtime: 30 tests
  • Constructive CLI: 95 tests and 4 snapshots
  • GraphQL codegen: 413 tests and 123 snapshots
  • pg-cache: 23 tests
  • Graphile cache: 3 tests
  • GraphQL explorer: 5 tests
  • PGPM logger: 1 test
  • GraphQL server ownership/environment boundary: 3 tests
  • presigned URL plugin unit surface: 54 tests
  • packed core acceptance: Node 18.17.0, 20.20.2, and 22.23.2
  • packed full acceptance: Node 22.19.0
  • affected CommonJS and ESM package builds
  • git diff --check, targeted ESLint, and signed-commit verification

The MinIO-backed presigned integration suite could not run locally because no MinIO service was listening; its 54 service-independent tests pass. GitHub's main CI jobs are draft-gated and were skipped, so the PR remains draft pending review and the decision to trigger the full remote matrix.

Review order

  1. packages/cli-runtime/src: protocol contracts, validation, execution, redaction, and discovery.
  2. packages/cli/src/runtime and packages/cli/src/config: registry adapters, state/auth boundaries, and services.
  3. graphql/codegen/src/core: planning, ownership, locking, transaction, and rollback.
  4. GraphQL/Graphile support packages: instance-owned environment, caches, and lifecycle glue.
  5. .github/workflows/run-tests.yaml and packed acceptance scripts.

Explicit non-goals

  • PGPM composition under CNC
  • generated csdk migration
  • MCP
  • semantic app graph
  • full-stack change sets or plan/apply
  • durable resume/rollback
  • preview deployment
  • opaque natural-language commands
  • TOON or YAML machine output

yyyyaaa added 20 commits August 20, 2026 16:06
Introduce registry-backed command contracts, schema validation, bindings, redaction, structured rendering, discovery, documentation projections, cancellation, and stable execution outcomes for reusable CLI operations.
Give embedded cache, schema, bucket, and presigned-upload services explicit instance ownership so concurrent CLI operations do not share or evict one another's state. Add ownership and configuration coverage for the new factories.
Thread explicit environment, cache, diagnostic, and lifecycle ownership through embedded GraphQL and Graphile services. Scope logger suppression to the current async operation and keep public-key signature authentication fail-closed.
Make source resolution cancellable and explicit, enforce declarative config safety, plan generated ownership before writes, preserve sensitive-value boundaries, and return structured artifacts suitable for registry-backed CLI execution.
Route context, authentication, GraphQL execution, codegen, server, explorer, and jobs through typed operations. Add deterministic discovery, strict agent-mode bindings, atomic state handling, service adapters, structured output, and compatibility-preserving human rendering.
Describe the command registry as the implementation authority, publish the structured invocation contract, and update human and agent guidance for discovery, state, GraphQL, codegen, and service operations.
Pack the complete CNC release set once and exercise engine-strict installations, CJS and ESM exports, both binaries, structured output, exit semantics, cancellation, lifecycle events, and signal cleanup across supported Node versions.
@yyyyaaa
yyyyaaa force-pushed the yyyyaaa/agentic-cnc-cli-audit branch from 17c29bb to b2b298a Compare August 20, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant