Repository navigation
Add local relay CLI for citation-gated draft logging - #57
Conversation
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>
sdcarlson
left a comment
There was a problem hiding this comment.
Request changes on exact2400761191f77a45fd2455612e6911228edb8274. The focused replacement avoids replaying old application files and now supplies outcome versions, but two CLI defects remain:
- 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.
- 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
left a comment
There was a problem hiding this comment.
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:
draft --outnow callsprecheckandPOST /api/draftsbefore any file write. A generatedI led 999 engineers.exits 3, printsrefused — nothing was written, does not call the log API, and leaves an existing--outfile unchanged even with--force. Without--force, an existing path is usage and Claude is not contacted. Default write useswx.request()classifies HTTP 401 beforejson(). Plaintext 401 and JSON 401 both returnEXIT.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.
sdcarlson
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Problem and result
#56 reopened
feat/selection-and-outcomesagainst currentmain. 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):login,brief,log,draft,plan,status,outcome) — this PR.mainalready requires a citation for every digit, includingI 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 devcan 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 jobversionso stale records 409 instead of writing.draft --outwrites only after the citation gate and a successful log. An existing file is left untouched unless--forceis passed. HTTP 401 is classified as auth (exit 2) before the body is parsed. Non-JSON error bodies useexitFor(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
origin/main1b6845b(Drain untrusted-origin POST bodies before 403 #55). Bounded origin drain and Land profile calibration and selection outcomes #49/Clear private pages when their session expires #54 behavior are unchanged.6bcdcfd: nativeResponse('Forbidden', { status: 403 })threw code 4. Fixed on71ef3caby applyingexitForwhen error-body parse fails.71ef3ca:pnpm lintclean;pnpm typecheckclean;pnpm test243/243;pnpm public-copy:checkcurrent. CLI unit tests 17/17 including native plaintext 400/403/404/409/413 and malformed 200.71ef3ca: all 12 checks green, including CI / Integration (cli) and required CI / CI. Run: https://github.com/SyberLabs/relay/actions/runs/34015612819RELAY_URLmust be localhost). Session file is ignoredprivate-data/.sessionmode 600. Production identity is not supported.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
2400761and6bcdcfdare 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; runpnpm public-copy:checkand followdocs/PUBLIC-COPY.mdwhen these change.Do not restore unused UI-kit deps from #56. Do not wait on hosting #3. #22 stays a separate Wrangler flake.