Skip to content

Add local relay CLI for citation-gated draft logging - #57

Merged
sdcarlson merged 4 commits into
mainfrom
cursor/relay-cli-phase-1-9ece
Sep 6, 2026
Merged

sdcarlson merged 4 commits into
mainfrom
cursor/relay-cli-phase-1-9ece

Conversation

@sykosyber

@sykosyber sykosyber commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Problem and result

#56 reopened feat/selection-and-outcomes against current main. That branch still contains the already-landed #26/#46/#49 application (profile, plan, track, migrations) plus two newer Claude commits. GitHub therefore reports conflicts on every hot file and does not give a clean “new work” signal.

Unique work after the old #46 head (0d3a006):

  1. Relay CLI, phase 1 (login, brief, log, draft, plan, status, outcome) — this PR.
  2. Employer-number citation exemption — not included. Current main already requires a citation for every digit, including I read your 2024 post on storage engines. Seth asked that exemption deleted on Land profile calibration and selection outcomes #49; restoring it would reopen the mixed-subject hole.

After this lands, an agent on pnpm dev can log drafts through the same citation gate as the browser API. Exit 3 means fix the input and write nothing. Exit 4 means retry. The CLI still cannot accept a draft, verify a fact, close a review, answer a preference pair, or submit an application. Terminal outcomes need --yes. Outcomes send the current job version so stale records 409 instead of writing.

draft --out writes only after the citation gate and a successful log. An existing file is left untouched unless --force is passed. HTTP 401 is classified as auth (exit 2) before the body is parsed. Non-JSON error bodies use exitFor(status): plaintext 400/403/404/409/413 are exit 3. A malformed 200 stays exit 4.

Do not merge #56. Close it as a conflicted duplicate once this replacement is the review target.

Evidence

Review

  • One issue owns this scope; unrelated changes are separate. This is the CLI transport only.

  • Tests exercise the changed behavior, including failure paths.

  • No credentials, personal applications, or private research are included.

  • Agent findings from 2400761 and 6bcdcfd are fixed. CodeQL threads are left for Seth to resolve with his stated rationale; Extra High does not dismiss them as a security-audit or production-auth approval.

  • A maintainer other than the author will approve the latest push. Extra High cannot self-approve.

  • Public capabilities, integration limits and lead-engineer credit match docs/public-copy.json; run pnpm public-copy:check and follow docs/PUBLIC-COPY.md when these change.

Do not restore unused UI-kit deps from #56. Do not wait on hosting #3. #22 stays a separate Wrangler flake.

Open in Web Open in Cursor 

The selection/outcomes application already landed on main. This brings
the unique follow-up from feat/selection-and-outcomes: login, brief,
log, draft, plan, status, and outcome over existing APIs.

Domain refusals stay exit 3 and write nothing. Outcomes send the job
version required by current main. Employer-year citation exemptions
are not restored.

Co-authored-by: sykosyber <sykosyber@users.noreply.github.com>
Comment thread integrations/cli.mjs Fixed
Comment thread integrations/client.mjs Resolved
@sykosyber
sykosyber marked this pull request as ready for review September 6, 2026 05:19
@sykosyber
sykosyber requested a review from sdcarlson as a code owner September 6, 2026 05:19

@sdcarlson sdcarlson 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.

Request changes on exact2400761191f77a45fd2455612e6911228edb8274. The focused replacement avoids replaying old application files and now supplies outcome versions, but two CLI defects remain:

  1. integrations/cli.mjs draft writes --out before precheck and the server's citation gate. Reproduced using the actual run() with fictional provider/local responses and a temporary existing output file: unsupported 'I led 999 engineers.' returns exit3 and prints 'refused — nothing was written', yet overwrites the existing file with that rejected draft. Validate before any output write; preserve existing output on refusal and make the no-write exit contract true. Add a regression for a rejected generated draft with an existing --out file. Avoid silently overwriting an existing reviewed artifact without an explicit overwrite choice.
  2. integrations/client.mjs still parses JSON before classifying401, retaining the #56 finding. A plaintext401 hits the JSON catch and returns EXIT.server4 rather than EXIT.auth2. Check authentication status before body parsing and exercise request() on actual plaintext401 as well as JSON401; a test of exitFor(401) alone does not cover this path.

The CodeQL network-to-file trace intersects the first real write-order defect. File-session-to-local-cookie flow is intentional authentication, but redirect/endpoint boundaries are still under independent review. Do not blanket-dismiss both threads. Reconcile latest main after #55 (1b6845b), preserve its bounded drain and all #49/#54 fixes, then freeze for final review. No live credentials, external requests, or user files were used in the reproductions.

draft --out now runs the citation gate before any file write, leaves
an existing reviewed file untouched unless --force is passed, and
classifies HTTP 401 as auth before parsing the body so a plaintext
challenge cannot look like a retryable server failure.

Co-authored-by: sykosyber <sykosyber@users.noreply.github.com>

@sykosyber sykosyber left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extra High follow-up on exact 6bcdcfdcea38a1bb94ec4b8c25f18f7d810f7c9a after Seth's REQUEST_CHANGES on 2400761. This is not an approval. Author is sykosyber; Extra High cannot self-approve.

Independently reproduced both defects on 2400761 with fictional run() / request() responses, then verified the fix:

  1. draft --out now calls precheck and POST /api/drafts before any file write. A generated I led 999 engineers. exits 3, prints refused — nothing was written, does not call the log API, and leaves an existing --out file unchanged even with --force. Without --force, an existing path is usage and Claude is not contacted. Default write uses wx.
  2. request() classifies HTTP 401 before json(). Plaintext 401 and JSON 401 both return EXIT.auth (2). exitFor(401) is no longer the only coverage.

Branch includes 1b6845b (#55). Unit gate 241/241 includes the #55 stalled-read / hung-cancel cases and the #54 private-page 401 expiry cases. numberIsAboutEmployer is still absent.

CodeQL threads were answered separately and were not blanket-dismissed. Freeze for @sdcarlson last-push review.

Comment thread integrations/cli.mjs Resolved
@sykosyber
sykosyber requested a review from sdcarlson September 6, 2026 05:35

@sdcarlson sdcarlson 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.

Follow-up on exact6bcdcfdcea38a1bb94ec4b8c25f18f7d810f7c9a: all15CLI unit tests pass independently. Rejected drafts now leave --out untouched, existing outputs require explicit --force, and plaintext401 is correctly auth2. Those reported cases are cleared.

The same error-classification issue remains for non-JSON refusals: actual request() with native Response('Forbidden',{status:403}) still throws code4, despite exitFor(403)=3. Apply the existing HTTP status mapping when error-body parsing fails instead of unconditionally EXIT.server; cover plaintext403 (and the other mapped refusal statuses) while keeping malformed successful responses retryable. This completes the existing stated exit-code contract, not a new feature.

The remaining network-to-file CodeQL trace is expected only after successful validation/logging to the caller-selected --out path, now exclusive by default. The local session-file-to-cookie trace is intended development authentication for the validated local endpoint; no independent credential-exfiltration defect was established in bounded review. I will resolve those code-review conversations with this rationale; this is not a blanket security-audit claim or production authentication approval. Final merge still requires the refusal classification correction, current main reconciliation, and exact-head checks/review.

A native 403 with a non-JSON body was classified as a retryable
server failure even though exitFor(403) is a domain refusal. Failed
error-body parses now use the existing status map; a malformed 200
stays exit 4.

Co-authored-by: sykosyber <sykosyber@users.noreply.github.com>

@sykosyber sykosyber left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extra High follow-up on exact 71ef3ca5a2401242a2869e69460a5ec3592ecc41 after Seth's REQUEST_CHANGES on 6bcdcfd. This is not an approval.

Independently reproduced request('/api/plan', undefined, { session: 'x=1', fetchImpl: () => new Response('Forbidden', { status: 403 }) }) on 6bcdcfd: RelayError code 4. On this head the same call is code 3. Native plaintext 400/404/409/413 are also 3. Native Response('not json', { status: 200 }) remains code 4.

Parse-failure path is now response.ok ? EXIT.server : exitFor(response.status). 401 is still classified before json(). Branch remains on 1b6845b. Local unit gate 243/243.

CodeQL conversations are left for Seth to resolve with the rationale he stated. Extra High does not treat that as a security-audit or production-authentication approval.

@sdcarlson sdcarlson 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.

Approve exact71ef3ca5a2401242a2869e69460a5ec3592ecc41. The focused CLI replacement preserves current main and addresses the reported integration defects: outcome requests carry the observed job version; rejected generated drafts do not write --out; existing output requires explicit --force and default writes are exclusive; plaintext401 is auth2 and other mapped plaintext refusals remain refusal3. Malformed successful JSON remains server4.

Reviewed the final two-file delta and independently ran the complete local unit gate:241passed,2platformskips,0failed (243total), plus TypeScript. New native-Response regressions exercise400/403/404/409/413 and malformed200. Earlier actual-run file-refusal regression passes. Required hosted checks are green, including the dedicated migrated CLI integration suite; all three CodeQL review conversations are resolved with specific intended-flow rationale. Current main is an ancestor. No remaining concrete finding from this bounded review.

Local-development authentication only; no live provider-generation or production-authentication validation is claimed. Issue22 remains separate. This approval applies only to this full SHA and does not authorize deployment.

@sdcarlson
sdcarlson merged commit c27cdba into main Sep 6, 2026
12 checks passed
@sdcarlson
sdcarlson deleted the cursor/relay-cli-phase-1-9ece branch September 6, 2026 06:12
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.

4 participants