Skip to content

feat(cua): define first-class lifecycle contract - #7776

Closed
jyaunches wants to merge 3 commits into
mainfrom
codex/cua-contract-7750
Closed

feat(cua): define first-class lifecycle contract#7776
jyaunches wants to merge 3 commits into
mainfrom
codex/cua-contract-7750

Conversation

@jyaunches

@jyaunches jyaunches commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Define the checked-in first-class CUA v1 product and architecture contract accepted in #7750. The contract is host-agnostic, keeps qualification scaffolding outside the supported lifecycle, and leaves exact runtime and target artifact identities as completion gates for their implementation and qualification issues.

Related Issue

Fixes #7750

Product scope decision: #7750 (comment)

Changes

  • Define the standalone CUA topology, component ownership, lifecycle operations, state classes, compatibility policy, failure families, and qualification boundary.
  • Add a versioned JSON Schema and TypeScript semantic checks for secret-free readiness, target attachment, task results, evidence references, and failures.
  • Prove with a synthetic fixture that the existing terminal manifest supports CUA discovery, version, interactive, headless, and smoke commands without a new runtime kind.
  • Add negative tests for schema compatibility, required capabilities and operations, cardinality, authority-bearing fields, immutable identities, evidence references, and terminal result consistency.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: this PR adds an internal contract and schema; user documentation belongs with the later command and runtime implementation issues.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: src/lib/cua/contract.md; no user-facing command or runtime is implemented in this PR.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — npm exec -- vitest run --project cli src/lib/cua/contract.test.ts (11 passed) and npm run typecheck:cli
  • Applicable broad gate passed — not applicable to this scoped contract/schema change; targeted tests and normal hooks cover the changed behavior.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Julie Yaunches jyaunches@nvidia.com

Summary by CodeRabbit

  • New Features
    • Added a versioned public CUA lifecycle contract (v1) with lifecycle record types covering runtime readiness, target attachment, task results, and failures.
    • Introduced strict JSON schema validation plus semantic validation for operations/capabilities, schema compatibility, evidence/receipt integrity, and task-result status coherence.
    • Enforced public-record security boundaries to reject sensitive/credential-like fields.
  • Documentation
    • Documented the “First-class CUA v1” boundary, lifecycle semantics, and failure families.
  • Tests
    • Added contract tests validating supported record shapes, semantic rules, and security-boundary rejections (including version compatibility).

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
@jyaunches jyaunches added area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery CUA Computer-use agent integration and qualification labels Jul 29, 2026
@jyaunches jyaunches self-assigned this Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dea118ea-d252-40e3-a608-82297957c409

📥 Commits

Reviewing files that changed from the base of the PR and between 44d2b3f and cc50c57.

📒 Files selected for processing (2)
  • schemas/cua-lifecycle.schema.json
  • src/lib/cua/contract.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • schemas/cua-lifecycle.schema.json
  • src/lib/cua/contract.test.ts

📝 Walkthrough

Walkthrough

Adds a first-class CUA v1 contract covering topology, lifecycle records, compatibility, evidence, failures, schema validation, semantic invariants, and automated contract tests.

Changes

CUA lifecycle contract

Layer / File(s) Summary
Contract boundary and lifecycle rules
src/lib/cua/contract.md
Documents supported topology, ownership, lifecycle operations, compatibility identities, state handling, secret and evidence boundaries, failure families, and qualification requirements.
Lifecycle record schema and types
schemas/cua-lifecycle.schema.json, src/lib/cua/contract.ts
Defines four lifecycle record shapes, shared identity and capability structures, supported operations and failures, and exported TypeScript contract types.
Schema compatibility and semantic validation
src/lib/cua/contract.ts
Adds schema-version checks and cross-field validation for operations, capabilities, target projections, authority-bearing fields, evidence, receipts, and task-result status consistency.
Contract and integration validation
src/lib/cua/contract.test.ts
Tests valid records, manifest wiring, unsupported versions, capability health, detached targets, authority boundaries, evidence references, status rules, limits, and failure families.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CUARecord
  participant JSONSchema
  participant SemanticChecks
  participant ContractTests
  CUARecord->>JSONSchema: Validate lifecycle record shape
  JSONSchema->>SemanticChecks: Provide structurally valid record
  SemanticChecks->>ContractTests: Report invariant results
  ContractTests->>CUARecord: Assert accepted and rejected cases
Loading

Possibly related issues

  • Issue 6015 — The contract, schema, validation, lifecycle operations, evidence, and failure taxonomy implement the epic’s stated CUA lifecycle objectives.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: introducing a first-class CUA lifecycle contract.
Linked Issues check ✅ Passed The schema, contract, and tests cover the CUA lifecycle, target boundary, capabilities, failures, and evidence requirements from #7750.
Out of Scope Changes check ✅ Passed The changes stay focused on the CUA contract, schema, and tests, with no obvious unrelated additions.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cua-contract-7750

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit cc50c57 in the codex/cua-contract-7... branch remains at 96%, unchanged from commit 125ca30 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit cc50c57 in the codex/cua-contract-7... branch remains at 81%, unchanged from commit cf34b72 in the main branch.

Show a code coverage summary of the most impacted files.
File main cf34b72 codex/cua-contract-7... cc50c57 +/-
src/lib/onboard...etson-groups.ts 100% 96% -4%
src/lib/agent/dashboard-ui.ts 96% 96% 0%
src/lib/sandbox...rce-identity.ts 88% 88% 0%
src/lib/tunnel/services.ts 73% 73% 0%
src/lib/cua/contract.ts 0% 91% +91%

Updated July 29, 2026 02:38 UTC

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
schemas/cua-lifecycle.schema.json (1)

512-519: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add uniqueItems: true to taskResult.capabilities for parity with the other capability arrays.

runtimeReadiness.requiredCapabilities (line 275) and target.capabilities (line 376) both set uniqueItems: true; here a result can carry [browser, browser, computer] and still pass pure-schema validation. The TS semantic layer catches it, but external consumers validating only against the published schema would not.

♻️ Proposed change
         "capabilities": {
           "type": "array",
           "minItems": 3,
           "maxItems": 3,
+          "uniqueItems": true,
           "items": {
             "$ref": "`#/`$defs/capabilityIdentity"
           }
         },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@schemas/cua-lifecycle.schema.json` around lines 512 - 519, Update the
taskResult capabilities array schema to set uniqueItems: true, matching
runtimeReadiness.requiredCapabilities and target.capabilities, while preserving
its existing type, item count, and capabilityIdentity reference.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/cua/contract.test.ts`:
- Around line 94-97: Remove the attachedTarget helper and its runtime null
check; type the duplicate and unhealthy fixtures so their target properties are
non-null, then update all call sites to access duplicate.target or
unhealthy.target directly.
- Around line 30-31: Update the temporary fixture path near temporaryAgentName
and temporaryAgentDir to use a per-test temporary directory rather than
AGENTS_DIR, ensuring parallel suites remain isolated and cleanup does not leave
artifacts in the shared agents tree.

---

Nitpick comments:
In `@schemas/cua-lifecycle.schema.json`:
- Around line 512-519: Update the taskResult capabilities array schema to set
uniqueItems: true, matching runtimeReadiness.requiredCapabilities and
target.capabilities, while preserving its existing type, item count, and
capabilityIdentity reference.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0bf3c335-5452-4691-8494-0f40268d3ad7

📥 Commits

Reviewing files that changed from the base of the PR and between eeab81c and 8406901.

📒 Files selected for processing (4)
  • schemas/cua-lifecycle.schema.json
  • src/lib/cua/contract.md
  • src/lib/cua/contract.test.ts
  • src/lib/cua/contract.ts

Comment thread src/lib/cua/contract.test.ts
Comment thread src/lib/cua/contract.test.ts Outdated
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings match; normalized E2E selections match; severity counts match.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: None

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@jyaunches
jyaunches marked this pull request as draft July 31, 2026 01:31
@copy-pr-bot

copy-pr-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@jyaunches

Copy link
Copy Markdown
Contributor Author

Superseded by the one-commit consolidation in #8169 at bc98436. Closing this obsolete stack layer; its branch is retained.

@jyaunches jyaunches closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery CUA Computer-use agent integration and qualification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define the CUA architecture and trust boundaries

1 participant