Skip to content

feat: add receipted Linear writes and bounded campaigns - #29

Merged
samtay32 merged 2 commits into
mainfrom
codex/linear-receipted-writes
Jul 29, 2026
Merged

feat: add receipted Linear writes and bounded campaigns#29
samtay32 merged 2 commits into
mainfrom
codex/linear-receipted-writes

Conversation

@samtay32

@samtay32 samtay32 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • add narrowly scoped Linear issue_create and evidence_comment operations
  • require explicit confirmation, coordinator ownership, recorded authority, separate least-privilege credentials, and idempotency
  • write bounded repository receipts and reconcile ambiguous provider outcomes before retrying
  • add a provider-neutral campaign loop that selects at most one ready work item per invocation and stops at a hard iteration limit
  • keep repository work/evidence contracts authoritative and Linear writes disabled by default

Verification

  • focused Linear/agent/maintenance/eval tests: 104 passed
  • full npm run release:check: 129 tests plus behavioral contracts, dry pack, and packed smoke
  • Node 22: 129 tests
  • markdownlint: 58 files
  • git diff --check: passed

Authority boundaries

No Linear write is automatic. Each enabled operation uses a separate credential, explicit human confirmation, the active Project Steward token, an authority source, deterministic idempotency, and a repository receipt. Native Linear Agent sessions and Agent Auth remain deferred.

Summary by CodeRabbit

  • New Features

    • Added optional, explicitly authorized Linear issue creation and evidence comments with validated local receipts.
    • Added campaign controls for bounded, one-item-at-a-time delivery with clear stopping states.
    • Added receipt validation and Linear entity lookup commands.
    • Added schemas and project-template support for campaign state and provider receipts.
  • Documentation

    • Clarified read-only defaults, approval requirements, least-privilege access, authority checks, fallbacks, and campaign boundaries across onboarding and operating guidance.
  • Bug Fixes

    • Improved validation, idempotency, failure handling, and safeguards against unsupported or destructive provider operations.

@samtay32

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5dd9705e-32e4-4e07-ad05-6f2b612e822e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds optional receipted Linear issue/comment writes, bounded campaign state and commands, strict schemas and authority checks, read-only Linear resolvers, packaging updates, documentation, and expanded tests and evaluation scenarios.

Changes

Linear writes and campaign delivery

Layer / File(s) Summary
Contracts, configuration, and governance
.codex-plugin/plugin.json, README.md, STARTER_PROMPT.md, assets/project-template/..., docs/..., skills/..., bin/ultimate-agent-stack.mjs
Adds strict campaign and provider-receipt schemas, configurable receipted Linear operations, approval and credential rules, bounded campaign guidance, and updated architecture and operating documentation.
Linear read and write adapters
scripts/linear-readonly.mjs, scripts/linear-write.mjs, bin/ultimate-agent-stack.mjs
Adds validated team, issue, and comment lookups plus bounded issue-create and evidence-comment GraphQL operations with credential separation and deterministic identifiers.
Receipt and campaign CLI
bin/ultimate-agent-stack.mjs
Adds receipt validation and persistence, campaign lifecycle commands, campaign/work-contract checks, readiness reporting, and CLI dispatch and exports.
Distribution and validation
package.json, scripts/packed-smoke.mjs, test/*, evals/scenarios.json
Ships the write helper and new schemas, validates packed artifacts and schema version 6, and expands tests for writes, receipts, campaigns, packaging, and evaluation scenarios.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProjectSteward
  participant CLI
  participant Linear
  participant ReceiptStore
  ProjectSteward->>CLI: approve bounded write
  CLI->>Linear: issue-create or evidence-comment
  Linear-->>CLI: provider result
  CLI->>ReceiptStore: validate and persist receipt
  CLI-->>ProjectSteward: write outcome
Loading
🚥 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 accurately summarizes the main change: receipted Linear writes plus bounded campaign behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/linear-receipted-writes

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

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samtay32

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. Your recent PR review activity is in the 95th percentile or higher among CodeRabbit users, so adaptive limits apply. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 3 seconds.

@samtay32

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 12

🤖 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 `@assets/project-template/.agent-stack/contracts/campaign-state.schema.json`:
- Around line 37-51: Add the missing cross-field conditionals to the schema’s
allOf so active_work_item is only non-null when status is "active"; document
that iterations_completed must not exceed max_iterations in the
iterations_completed property description, since JSON Schema cannot enforce that
comparison. Keep the existing numeric bounds and identifier definition
unchanged.

In `@bin/ultimate-agent-stack.mjs`:
- Around line 5893-5902: Preserve the existing Linear idempotency namespace
across provider changes and writes being disabled/re-enabled by storing it
outside the nullable writes configuration. Update the namespace initialization
around existingIdempotencyNamespace and the related reconfiguration flow so
returning to Linear reuses the persisted valid namespace instead of generating a
new one; document the rotation consequence in docs/OPERATING_MANUAL.md if
persistence is not implemented.
- Around line 5299-5304: Update the comment preflight failure handling in
commandLinearCommentCreate to record a validated failed receipt before throwing
StackError, matching the equivalent commandLinearIssueCreate lookup-preflight
path and preserving the documented audit trail for every attempt. Apply the same
receipt behavior to the related failure branch around the comment preflight
handling at lines 5266-5275, reusing the existing receipt construction and
persistence symbols.
- Around line 4433-4457: Update the resolve-comment validation branch to require
typeof value.provider_id === "string" before PROVIDER_UUID.test, and require
typeof value.issue_id === "string" before validating it with PROVIDER_UUID.test.
Keep the existing found handling and returned objects unchanged.
- Around line 4022-4042: Extract the repeated operation-to-credential
environment ternary into a shared linearOperationCredentialEnv(operation)
helper. Replace all four mappings in the writes capability construction and the
corresponding mapping logic in linearWriteReadiness with calls to this helper,
preserving the existing issue_create and comment operation behavior.

In `@scripts/linear-readonly.mjs`:
- Around line 457-479: Update both issue and comment resolver flows to recognize
Linear responses where data.issue or data.comment is null alongside GraphQL
errors indicating the entity is missing. Return the existing found:false result
with the appropriate provider identifier before the generic errors.length
failure guard, while preserving hard-failure handling for other GraphQL errors
and non-OK responses.

In `@scripts/linear-write.mjs`:
- Around line 299-310: Update the isEntryPoint execution flow around
performLinearWrite’s result so responses with ok: false set process.exitCode to
a nonzero failure code, while successful results retain exit code 0. Preserve
the existing catch handling for thrown errors and continue emitting the JSON
response in both cases.
- Around line 279-291: Update main and performLinearWrite so operationRequest is
evaluated only once and validation failures follow the existing structured
result contract. Prefer passing the resolved request or credential into
performLinearWrite, or move credential resolution entirely into
performLinearWrite, while preserving the normalized {provider, operation, error}
output and avoiding validation throws from main.

In `@test/agent-stack.test.mjs`:
- Around line 2026-2034: Update the receipt assertions in the readdirSync loop
to verify serialized receipts contain neither LINEAR_CREATE_API_KEY nor the
comment credential’s environment name, covering receipts generated through the
evidence_comment path while preserving the existing validation.

In `@test/linear-readonly.test.mjs`:
- Around line 256-258: Replace the individual undefined-field assertions in the
issue resolver tests with deepEqual assertions that require the complete
expected object containing only found, provider_identifier, and title. Apply the
same exact-object validation to the related assertions around the additional
referenced range, preserving the expected values for each case.

In `@test/maintenance.test.mjs`:
- Line 599: Extend the campaignStateSchema assertion near the existing
max_iterations maximum check to also assert its minimum is 1. Keep the
validation contract aligned with the 1..25 bounds enforced by
commandCampaignStart and validateCampaignState.
- Around line 579-582: Update the assertion for linearReceiptedWrites in the
maintenance test to stop matching the brittle “repository ledger is still”
prose; replace it with a regex targeting the durable contract or concept
expressed by that text, while preserving the existing “disabled by default” and
environment-variable assertions.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: 36969035-c0ab-4bcb-a878-54103015e944

📥 Commits

Reviewing files that changed from the base of the PR and between 32c20d8 and 11234ab.

📒 Files selected for processing (27)
  • .codex-plugin/plugin.json
  • README.md
  • STARTER_PROMPT.md
  • assets/project-template/.agent-stack/contracts/campaign-state.schema.json
  • assets/project-template/.agent-stack/contracts/provider-receipt.schema.json
  • assets/project-template/.agent-stack/provider-receipts/.gitkeep
  • assets/project-template/AGENTS.md
  • bin/ultimate-agent-stack.mjs
  • docs/ADAPTERS.md
  • docs/ARCHITECTURE.md
  • docs/OPERATING_MANUAL.md
  • docs/TRUST.md
  • evals/scenarios.json
  • package.json
  • scripts/linear-readonly.mjs
  • scripts/linear-write.mjs
  • scripts/packed-smoke.mjs
  • skills/manage-project-work/SKILL.md
  • skills/manage-project-work/references/linear-receipted-writes.md
  • skills/manage-project-work/references/work-evidence-contract.md
  • skills/run-autonomous-delivery/SKILL.md
  • skills/setup-autonomous-project/SKILL.md
  • test/agent-stack.test.mjs
  • test/linear-readonly.test.mjs
  • test/linear-write.test.mjs
  • test/maintenance.test.mjs
  • test/skill-eval.test.mjs

Comment thread bin/ultimate-agent-stack.mjs
Comment thread bin/ultimate-agent-stack.mjs
Comment thread bin/ultimate-agent-stack.mjs
Comment thread bin/ultimate-agent-stack.mjs
Comment thread scripts/linear-write.mjs
Comment thread test/agent-stack.test.mjs
Comment thread test/linear-readonly.test.mjs Outdated
Comment thread test/maintenance.test.mjs
Comment thread test/maintenance.test.mjs
@samtay32

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samtay32
samtay32 marked this pull request as ready for review July 29, 2026 05:17
@samtay32
samtay32 merged commit 95d4a75 into main Jul 29, 2026
58 checks passed
@samtay32
samtay32 deleted the codex/linear-receipted-writes branch July 29, 2026 05:18
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