feat(workspace): post a sanitized session attach report when the outcome settles - #1310
Draft
ralphstodomingo wants to merge 1 commit into
Draft
feat(workspace): post a sanitized session attach report when the outcome settles#1310ralphstodomingo wants to merge 1 commit into
ralphstodomingo wants to merge 1 commit into
Conversation
…ome settles When an attach settles — attached, engine missing, engine too old, or the engine failed to start — the CLI posts what the session received to the backend: binding identity (the same remote or path the server row holds), CLI and engine versions, bridge state, declared and delivered keys, and the engine's unfulfilled report. Once per distinct report, fire-and-forget, never on the turn's path. Engine detail strings never leave the machine: each is reduced to a code plus, for spawn failures, the command's basename. Closes #1309 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GHBUvb843k1R7UAGi8Ya9b
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Draft
6 tasks
Contributor
Author
|
More live runs on the same local chain (real CLI attach path → 0.7.2 RC engine → local backend), all in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #1309
Type of change
What does this PR do?
Stacked on the client half of the unfulfilled-keys work (base branch
feat/unfulfilled-keys-meta); merge that first, then retarget this tomain.When a workspace attach settles, the CLI is the only place that knows what the session actually received. This PR posts that as a session attach report to the backend's
POST /datamates/{id}/attach-reports(a new endpoint, not yet deployed anywhere — see verification), so the workspace page can show "your last session received …" and whether a linked project is ready.attach-report.ts(new): the report shape,buildAttachReport(one report per settled outcome:attached,engine-missing,engine-too-old,connect-failed; nothing fordisabled/unbound),attachReportSignature, andpostAttachReport(throughAltimateApi.postAttachReport, guarded: a failure logs once at debug and never throws).detailstrings are raw error text and can name paths and hosts. They never leave the machine:sanitizeDetailreduces each to{code}(ENOENT,EACCES,ETIMEDOUT,ECONNREFUSED,invalid-url, elseother) plus, for spawn failures only, the basename of the spawned command (spawn /Users/x/bin/docker ENOENT→{code: "ENOENT", command: "docker"}). The binding is identified by the git remote or project path the server binding row already holds.engine-overlay.ts: the probed engine version now rides on the overlay state;reportOutcomebuilds and posts the report at the four terminal sites, once per distinct report per session (signature excludes the timestamp), fire-and-forget — never awaited by the turn.bridge_connectedis true when a live IDE bridge served extension keys.engine-seams.ts:reportAttachseam so tests capture posts;api/client.ts:postAttachReport.Claims
detailis{code, command?}; unit tests feed representative engine strings with paths, Windows paths and hosts and assert only the code and a basename survive; the E2E asserts the stored row contains nospawntext.engine-too-oldcarriesfound;engine-missingcarries null) (tests).voided; a sink that throws leaves the outcome and the toast untouched (test).bindingKeynull → no report; unbound → no report (test); production path checksAltimateApi.isConfigured().Residuals
connect-failedposts the outcome but not an error code: the backend row has no field for it yet.How did you verify your code works?
bun run typecheckclean; prettier clean; Marker Guard: no upstream-shared files touched.test/altimate/workspace/attach-report.test.ts(11) and six new attach-report cases inengine-overlay.test.ts;test/altimate/workspace— 81 pass.altimate-backendbranch, so per the ticket every E2E runs against that local stack:uvicornon:5001with the new migration applied, SuperTokens local, a demo workspace declaring six integrations chosen to produce every reason (an in-house integration served, Jira and a GitHub MCP without connections, an extension integration with no VS Code, an integration removed from the catalog, and a custom MCP pointing at a missing binary). The probe drives the CLI's production attach path (bootstrap+beforeTurn) with the 0.7.2 release-candidate engine on PATH, then reads the row back throughGET …/attach-reports/latest. 14/14 checks, 8063 ms:2 of 7 declared integration tools available. Declared but not available — no usable connection: jira_get_issue, jira_create_issue, create_branch; no longer in the catalog: retired_tool; server failed to start (spawn altimate-demo-missing-mcp ENOENT): demo_tool.attached, engine0.7.2, delivered['altimate_analyze_snowflake_query', 'altimate_analyze_snowflake_table'], unfulfilled 7 entries incl.demo_tool→spawn-failedwith detail{"code": "ENOENT", "command": "altimate-demo-missing-mcp"}and no raw text; one row per binding.64e5bb4) and the client parser accepts a number (82531540con the base branch).Screenshots / recordings
Not a UI change; the toast text and the stored row are asserted above.
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01GHBUvb843k1R7UAGi8Ya9b
Appendix — complexity delta (altimate-code: attach report post)
82531540c7→2cd250d2fe· only functions this diff touches · advisory, not a gate.overlayL213packages/opencode/src/altimate/workspace/engine-overlay.tsbuildAttachReportL91packages/opencode/src/altimate/workspace/attach-report.tsreconcileL516packages/opencode/src/altimate/workspace/engine-overlay.tsSummary: 5 touched · 2 rose · 0 improved · 10 new (max cognitive 4) · net cognitive Δ +16
ℹ️ How to read these numbers
Cognitive (Sonar spec) counts breaks in linear reading flow — each
if/loop/catch/ternary/boolean-operator switch adds 1, and nesting makes every further break cost more. It approximates how much you must hold in your head to follow the function: 0–5 trivial · 6–10 easy · 11–15 moderate (15 = Sonar's recommended per-function cap) · 16–25 hard to follow · >25 needs decomposition.CCN (cyclomatic) counts independent paths — also the minimum number of test cases for full branch coverage of the function.
Only functions this diff touches are measured, as deltas — pre-existing complexity is not counted against this change. Rising numbers aren't automatically wrong; they're where review attention should go. Test files excluded.
Summary by cubic
Posts a sanitized session attach report when a workspace attach settles, so the workspace page can show what the session received and whether a linked project is ready. The CLI was the only place that knew this; it now posts once per distinct report to the backend's new
POST /datamates/{id}/attach-reportsendpoint. Closes #1309.detailstrings never leave the machine; each becomes an error code plus, for spawn failures, the spawned command's basename.attached,engine-missing,engine-too-old, andconnect-failed; none fordisabledorunbound.Rollout
feat/unfulfilled-keys-meta; merge that first, then retarget tomain.Written for commit ceb212e. Summary will update on new commits.