Skip to content

Say how to recover a broken connect.json, and keep reporting around it - #1053

Merged
robzolkos merged 8 commits into
mainfrom
connect-json-recovery
Nov 22, 2026
Merged

robzolkos merged 8 commits into
mainfrom
connect-json-recovery

Conversation

@robzolkos

@robzolkos robzolkos commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

A single typo in connect.json used to stop connect doctor, status, show and setup with one line, and the line gave no position. Nothing said how to recover: setup said to fix or remove the file, and the skill said never to edit it. People who don't know JSON will hit this once the connector reaches everyone at 37signals.

What changes:

  • Errors name the place. Syntax and type errors give the line and column. A misspelled key gives its line and the key it was probably meant to be: project 222: line 15, column 7: json: unknown field "watch_completion"; did you mean "watch_completions"?
  • connect doctor keeps going. The connect.json row fails with the recovery command. Every other check still runs: token, identity, stream ticket, feed, Pings and ledger. Which connector state belongs to the profile comes from its one state directory, or failing that from its credential. When those two disagree, doctor reads the state that's there and says so.
  • connect status keeps going. It still shows the ledger, --shadow included. It leads with the config problem and counts requests a running connector holds as config_unreadable. With no ledger to show, it leads with the file and how to fix it, not "run the connector".
  • connect setup --reset. It sets the profile up from that run's flags alone. The old file is moved aside as connect.json.broken-<time> only when the new one is written, and put back if that write fails. Hints that told people to remove the file now point here.
  • basecamp doctor gets one line per connector profile: whether it's set up, whether it's broken, and whether its connector is running.
  • The skill and the code comment agree. People may still edit the file by hand. The agent never does, and when the file no longer reads, the way out is --reset.

Basecamp card: A broken connect.json stops doctor, status and setup, and nothing says how to recover

Built by R2-D2 (Rob's agent) on Claude Opus 5.5.

Reviews. Six local adversarial Codex passes (gpt-6.1-sol, high) read the worktree: the first before any commit, each later one the fix commits since the pass before it. None found a way for a broken or copied file to authorize anything, or a trust bypass in --reset. What they did find was fixed, each fix with a test:

  • recovery that went wrong: shadow-only state, status leading with the wrong problem, doctor replacing the state's identity with the credential's, a ledger that opens but can't be read;
  • a reset hint that couldn't be followed: missing --serve, dropped flags, and -v replayed as --verbose 1;
  • error positions on the wrong key or object.

The sixth pass, over 90c36a7, found nothing new. Copilot reviewed every head, and every inline thread is answered with the commit that fixed it. Its review of c461faf, the head, has no open issues.

Left open: two diagnostic edge cases, neither of which changes whether a file is refused.

  • status --shadow on a broken file reads the profile's only shadow state directory, even if an earlier agent left it.
  • A mistyped project value followed by trailing data can be placed on the wrong line.

bin/ci (make check) is green locally on c461faf, and every PR check passes.

A typo in connect.json used to stop connect doctor, status, show and setup
at one line with no position, and nothing said how to get out of it: setup
said to fix or remove the file, the skill said never to edit it.

- Parse errors name the line and column, and an unknown key names the key
  it was probably meant to be ("did you mean watch_completions?").
- connect doctor fails its connect.json row with the recovery command, and
  still runs the token, identity, ticket, feed, Pings and ledger checks,
  finding the profile's connector state from its state directory or its
  credential.
- connect status still shows the ledger, leads with the problem, and counts
  requests held as config_unreadable.
- connect setup --reset sets the profile up from the run's flags alone; the
  old file is moved aside as connect.json.broken-<time> only when the new
  one is written, and put back if that write fails.
- basecamp doctor has a line per connector profile.
- Hints that said to remove the file point at --reset, and the skill says
  what a person or agent does when the file no longer reads.
@robzolkos
robzolkos requested a review from a team as a code owner November 22, 2026 20:19
Copilot AI balanced review requested due to automatic review settings November 22, 2026 20:19
@github-actions github-actions Bot added commands CLI command implementations tests Tests (unit and e2e) skills Agent skills labels Nov 22, 2026

Copilot AI 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.

🟡 Changes recommended

Unresolved findings show that diagnostics can point to the wrong field, status can falsely imply active retries, and the suggested recovery command cannot succeed as shown.

3 open issues
What changed in this PR

This PR adds recovery guidance for broken connect.json files and keeps connector diagnostics available when configuration cannot be read.

Changes:

  • Adds error positions and suggestions for misspelled configuration keys.
  • Keeps doctor and status reporting available, including ledger details and per-profile checks.
  • Adds connect setup --reset with backup and rollback, and updates recovery hints and agent guidance.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
skills/​basecamp-connect/​SKILL.md Documents reset recovery for agents.
internal/​connector/​setup/​report.go Reports the backup file path.
internal/​connector/​setup/​file.go Integrates diagnostics and backup naming.
internal/​connector/​setup/​diagnose.go Locates parse errors and suggests keys.
internal/​connector/​setup/​diagnose_test.go Tests error locations and suggestions.
internal/​commands/​doctor.go Adds connector profile checks.
internal/​commands/​connect.go Implements reset, rollback, and recovery hints.
internal/​commands/​connect_setup_test.go Updates identity-change recovery expectations.
internal/​commands/​connect_setup_guided.go Shares backup naming and recognizes reset.
internal/​commands/​connect_run.go Adds startup recovery guidance.
internal/​commands/​connect_recovery_test.go Tests recovery and degraded reporting.
internal/​commands/​connect_operator.go Preserves status reporting around broken configuration.
internal/​commands/​connect_doctor.go Continues independent checks and summarizes profiles.
internal/​commands/​connect_console.go Points console recovery guidance to reset.
.surface-skill-drift Records the skill’s reset flag reference.

Review effort: Balanced

Comment thread internal/commands/connect_operator.go Resolved
Comment thread internal/commands/connect_operator.go Resolved
Comment thread internal/connector/setup/diagnose.go Resolved
From the second adversarial pass and Copilot's review of 7381f55:

- A ledger that opens and then can't be read no longer hides a broken
  connect.json from status.
- Unknown keys are placed in the object that refused them, found by the
  schema's own types at each path, and only a key valid in that object is
  suggested. A key not spelled canonically and a duplicated key are placed
  too.
- The recovery hint names --serve, since a reset serves nothing unless told
  to, and a reset refused for serving nothing says to reset again with one.
- Status says requests are held because the file couldn't be read, without
  claiming a connector is retrying them.
- --reset alone at a terminal runs scripted setup, not guided: pinned.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 20:53

Copilot AI 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.

🟡 Changes recommended

Unresolved issues cause configuration diagnostics to identify incorrect key locations and omit connector running-state information when configuration files are corrupted.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Report connector running state when config is unreadable

internal/​commands/​connect_doctor.go:336

When connect.json is corrupted after a connector starts, this branch reports only the file error and skips the running-state check. The connector can still be alive and holding requests as config_unreadable, so this omits the running/not-running information promised for each profile in the PR description precisely during recovery. Recover the identity with connectStateIdentity and append its running state (or explicitly report it as unknown), while retaining the failed config check.

Medium severity Exclude map containers when detecting unknown fields

internal/​connector/​setup/​diagnose.go:94

Map entries are treated as unknown fields here because keysOf returns an empty set for map types. For example, with "projects": {"222": {}} followed by an invalid top-level "222": true, the diagnostic points to the valid project entry instead of the rejected top-level key. Exclude map containers from this unknown-field predicate so the recovery message identifies the offending location.

3 resolved since last review

Review effort: Balanced

Comment thread internal/connector/setup/diagnose.go Resolved
From the third adversarial pass and Copilot's review of 8014d38:

- A duplicate key is placed in the object that has it: objects are told
  apart by instance, so sibling objects in an array are two.
- An unknown key is never placed on a map's id: only a struct refuses a
  key.
- A reset refused for serving nothing hints with this run again, every
  flag it had, and --serve: following it works, and a test follows it.
- basecamp doctor's line for a broken profile says whether its connector
  is still running, from the profile's state directory.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 21:46

Copilot AI 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.

🔵 Needs a closer look

Doctor incorrectly reports a copied connect.json as “Set up” without checking that its profile matches the directory, masking a configuration mismatch that connect show and connect setup reject.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Reject connect configs whose profile does not match the directory

internal/​commands/​connect_doctor.go:327

A valid connect.json copied from another profile is reported as "Set up" here, even though connect show and connect setup reject it because its profile does not match the directory (connect.go:237 and :670). setup.Load only validates the profile name, not that association. Please check file.Profile == name before selecting a passing status, and route a mismatch through the failure/recovery branch so doctor exposes the configuration problem.

1 resolved since last review

Review effort: Balanced

…at runs

From the fourth adversarial pass over ec04243:

- The hint for a reset that serves nothing repeats setup's own flags and
  leaves inherited ones out: a count such as -v came back as "--verbose 1",
  which the CLI reads as a stray argument. A test runs it under a root with
  those flags and has a shell parse the hint back into its words.
- basecamp doctor's line for a broken profile names the agent whose
  connector state it read, since the credential may since be another's.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 21:56

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed because unpublished moderate findings identify gaps in profile validation and diagnostic locations for escaped keys.

No open issues 🎉

Review effort: Balanced

… used

Copilot, in the body of its review of ec04243: basecamp doctor called a
valid file naming another profile "set up", though connect show and setup
refuse it. One loader for doctor, status and the doctor line now refuses it,
so each reports it with the recovery hint.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 22:02

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed because an unpublished moderate-severity finding raises concerns about ambiguous state discovery and terminal controls reaching diagnostic output.

No open issues 🎉

Review effort: Balanced

…mands that stop a connector

The fifth adversarial pass over 2760c22: the connector itself takes a file
naming another profile, so refusing it in every operator command left a
running connector that connect stop and the worker commands could no longer
reach. Only doctor, status and the doctor line call it a problem now. The
doctor line no longer claims a running connector holds requests, which it
doesn't for a mismatch.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 22:11

Copilot AI 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.

🟡 Changes recommended

A valid file copied from another profile can override the profile’s state-directory identity, causing status to miss the existing ledger and doctor to skip it.

1 open issue

Review effort: Balanced

Comment thread internal/commands/connect_operator.go Resolved
…nother

Copilot on 90c36a7: a copied file names another profile's agent, and
following it, status found no ledger and doctor skipped the one that is
there. The profile's one state directory is preferred, as for a file that
can't be read; the copy's agent is the fallback.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 22:21

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed because a repair between file reads can discard agent metadata, causing doctor to report a passing connect.json but failed agent verification despite valid credentials.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot's review body on 9c431fe: the report read the file a second time
to build the refusal, and a repair in between left a profile with no
refusal and no policy, which doctor would have passed and then failed to
verify. The refusal is now made from the first read.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 22:34

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed because a mistyped project value combined with trailing data can bypass offset correction, causing diagnostics to point to an unrelated line.

No open issues 🎉

Review effort: Balanced

@robzolkos
robzolkos merged commit cc1b3ad into main Nov 22, 2026
41 checks passed
@robzolkos
robzolkos deleted the connect-json-recovery branch November 22, 2026 22:42
jeremy added a commit that referenced this pull request Nov 23, 2026
…950575

* origin/main:
  Keep a person's client flag when it is false (#1055)
  Filter gauge listings by chosen projects (#1049)
  Say how to recover a broken connect.json, and keep reporting around it (#1053)
  Support schedule entry drafts, highlights, and join links (#1019)
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations skills Agent skills tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants