Skip to content

Verify published guarded-file examples and response contracts - #1045

Merged
sidneyswift merged 5 commits into
mainfrom
codex/guarded-git-doc-fixtures
Oct 19, 2026
Merged

sidneyswift merged 5 commits into
mainfrom
codex/guarded-git-doc-fixtures

Conversation

@sswiftdrtv

@sswiftdrtv sswiftdrtv commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Developers need examples that describe the optional file-version check added by #1044. Freeze the corrected read/upload examples and response schemas, and add eight tests against the real GET export, upload validator, upload response builder and repository-rejection mapper under mocked service boundaries.

The tests explicitly require the documented expected_sha, sha/encoding, errors/conflicts and uploaded receipt fields. This catches an omission that ordinary JSON Schema validation permits. Mutation verification removed declarations: five cases failed after the repair; the fixture was restored. Two synthetic 404/422 repository failures verify the documented ordinary 500 upload response, without claiming a hosted file-deletion outcome.

API behavior is unchanged. At current head c3e2a88, all 44 contract tests across eight files, scoped lint, response-contract TypeScript, formatting and diff checks pass. Earlier full-repository lint passed before the small test additions. Authentication, account/repository lookup and file reads are mocked; no hosted save, access or sandbox concurrency claim is made. Final-head remote checks/review remain separately recorded.

The generated fixture remains one coordinated artifact with source-file hashes, alongside the existing error-envelope export. File-length suggestions are treated as nonblocking maintainability advice: the maintained API configuration limits functions/classes, not JSON files, and the fixture already exceeded 100 lines. No reviewer agreement with this disposition is implied.

Release first, then refresh Marketing #182 to the actual API merge and Docs #378 to actual merged Marketing. Coordinator owns conditional merges and publication verification. Tracks mono #361.

@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api Ready Ready Preview Oct 19, 2026 7:54pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T19:33:17.176344Z d49c493 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: recoupable/api/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b20378c0-c9f9-44ba-9f75-8cbca5fb12fe

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: recoupable/api/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c12ec745-ad39-43c9-a0b8-df658e887936
📥 Commits

Reviewing files that changed from the base of the PR and between 8bd65c3 and d49c493.

⛔ Files ignored due to path filters: 1
  • lib/contracts/__tests__/publishedSandboxFiles.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing: 2
  • lib/contracts/README.md
  • lib/contracts/fixtures/published-docs.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The coordinated published-docs fixture adds guarded Git file examples and schemas for revision-aware reads and upload outcomes. The README describes the related test coverage, mocked dependencies, and stated coverage limits.

Changes: Guarded File Contracts

Layer / File(s) Summary
Fixture schemas and test coverage documentation
lib/contracts/fixtures/published-docs.json, lib/contracts/README.md
The fixture adds a revision-aware file-read example, an upload example with an expected SHA, and HTTP 200, 409, and 500 response schemas. The README describes the related test checks, mocks, and coverage limits.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: sidneyswift

Merge Risk: ⚪ Minimal · up to d49c4

No concrete issue blocks merging based on the available evidence; complete the coordinated source-pin updates before release.

Pre-merge checks: Passed 2 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Solid & Clean Code Warning The new test duplicates the same four-line guardedGitFiles existence assertion in publishedContract and in both the GET and upload tests (publishedSandboxFiles.test.ts:33-36, 50-53, and 74-77). This v… Extract a single helper, such as getGuardedGitFilesFixture(), that asserts the coordinated fixture exists and returns it. Use that helper in publishedContract and both tests, removing the repeated assertions.
Passed Passed checks: 2 passed
Check name Status Explanation
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.
Full details: Solid & Clean Code

Explanation

The new test duplicates the same four-line guardedGitFiles existence assertion in publishedContract and in both the GET and upload tests (publishedSandboxFiles.test.ts:33-36, 50-53, and 74-77). This violates the stated DRY requirement because one fixture-access helper can provide the shared assertion and value.

Resolution

Extract a single helper, such as getGuardedGitFilesFixture(), that asserts the coordinated fixture exists and returns it. Use that helper in publishedContract and both tests, removing the repeated assertions.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A file read brings its revision in view
An upload records each saved SHA
Conflicts name files whose versions differ
Error shapes mark the responses
The fixture keeps each contract in view

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d49c4932f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files

Architecture diagram
sequenceDiagram
    participant Test as Contract Tests
    participant Fixture as published-docs.json
    participant GETRoute as GET /api/sandboxes/file
    participant Auth as validateAuthContext
    participant Repo as resolveSubmodulePath
    participant GH as getVersionedFileContent
    participant POSTRoute as POST /api/sandboxes/files
    participant Validator as validatePostSandboxesFilesRequest
    participant Response as buildFileUploadResponse
    participant Ajv as Ajv Validator

    Note over Test,Fixture: Contract Test Flow (6 new cases)

    Note over Test,GH: GET versioned-read contract
    Test->>GETRoute: GET /api/sandboxes/file?path=drafts/notes.txt&include_revision=true
    GETRoute->>Auth: Validate auth context
    Auth-->>GETRoute: fixture-account (mocked)
    GETRoute->>Repo: Resolve submodule path
    Repo-->>GETRoute: params (mocked passthrough)
    GETRoute->>GH: getVersionedFileContent(path, includeRevision)
    GH-->>GETRoute: { content, sha, encoding? }
    GETRoute-->>Test: 200 { status, content, sha, encoding? }
    
    Test->>Ajv: Validate against guardedGitFiles.responses GET 200 schema
    Ajv-->>Test: valid

    Note over Test,Validator: POST copyable upload example
    Test->>Validator: validatePostSandboxesFilesRequest(upload body)
    Validator-->>Test: { files: [{ expected_sha: 40-hex }] }

    Note over Test,Response: Upload response contract matrix
    Test->>Response: buildFileUploadResponse([], errors, conflicts)
    Response-->>Test: 409 { status, error, conflicts }

    Test->>Response: buildFileUploadResponse([], errors, conflicts)
    Response-->>Test: 500 { status, error, conflicts? }

    Test->>Response: buildFileUploadResponse(uploaded, errors, conflicts)
    Response-->>Test: 200 { status, uploaded, errors, conflicts }

    Test->>Ajv: Validate each against minted schemas
    Ajv-->>Test: valid for all status codes

    Note over Fixture: Fixture content (guardedGitFiles block)
    Fixture-->>Test: readQuery, upload, responses schemas
Loading

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread lib/contracts/README.md Resolved

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Adds guarded-file response contracts to the documentation fixture and contract tests validating the actual route, validator, and upload builder. No runtime behavior changes; bounded to docs and tests.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Auto-approved: Adds guarded-file examples and response contracts to the shared docs fixture, with contract tests validating the actual GET, POST, and upload response paths; no runtime behavior changes.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 2 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Auto-approved: Adds guarded-file API examples and response schemas to the docs fixture, with contract tests against mocked service boundaries; no runtime behavior changes.

View guided diff | Turn on auto-fix | Re-trigger cubic

@sidneyswift
sidneyswift merged commit 6c2fa42 into main Oct 19, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview — c3e2a882 Deployed Oct 19, 2026 by vercel[bot]
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.

2 participants