Skip to content

Preserve user state and validate identifiers without lossy aliases - #40

Merged
mazze93 merged 12 commits into
mainfrom
codex/fix-bug-in-important-code-section
Nov 9, 2026
Merged

mazze93 merged 12 commits into
mainfrom
codex/fix-bug-in-important-code-section

Conversation

@mazze93

@mazze93 mazze93 commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Existing user names must retain their state without silently sharing directories. This repair reconciles the branch with current main and replaces lossy sanitization with validation of explicit identifiers.

  • Preserve safe raw names, including spaces and dots; retain existing config, regions, logs, profiles, and session state in place.
  • Throw recoverable errors before state writes for invalid identifiers, conflicting directory owners, and ambiguous historical aliases. The CLI reports these on stderr with exit status 2.
  • Keep main's LighthouseStore migration, edge identity fix, strict concurrency, and later persistence/session work. Retain the isolated-frontier propagation-depth fix.
  • Put new storage, CLI invalid-input, and circuit regression coverage in separate files under Tests/.

Historical aliases cannot safely be assigned automatically: if users/AdaName exists and users/Ada.Name does not, selecting Ada.Name reports the ambiguity. The owner must select the stored name explicitly or back up and rename it. Existing data is left untouched.

Validation: local whitespace and journal append-only checks pass. Swift and xcodebuild are absent from the cloud container used for this repair; this says nothing about the maintainer's Mac. Native macOS CI and CodeQL have been triggered, and runtime tests are pending.

RetriggerView in GreptileConfidence Score: 4/5

The PR should not merge until existing users named Default or DEFAULT can reopen their saved state.

Fix All in Claude CodeFindings

  1. P1 Existing user names stop working ▶
Fix with agent prompt
### Issue 1
Sources/SynapseCore/UserStorage.swift:29-30
This guard rejects an existing user named `Default` or `DEFAULT`, even when the caller supplies the exact stored name and its profile matches. Those names were accepted before this change. On a case-insensitive Mac, selecting lowercase `default` also fails the directory-owner check for a stored `Default` directory. That leaves the user's saved state inaccessible through the CLI. Check the stored owner before rejecting case variants of the built-in name.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR preserves safe user names without dropping characters and returns recoverable errors for invalid names, conflicting owners, and ambiguous historical names.

  • Safe user names keep their own folders.
  • Fault-depth reports stop when no new nodes are reached.

Reviews (3) · Last reviewed commit: "fix(tests): mark throwing SynapseCore in..." · Reviewed by Greptile


Note

Medium Risk
Changes per-user persistence paths and initialization contract (throwing vs sanitized fatalError); incorrect validation could block access to existing data, though the expanded test matrix targets that perimeter.

Overview
Replaces lossy user-folder sanitization with UserStorage.validate and a throwing SynapseCore(folderName:user:baseOverride:) so safe names (spaces, dots, punctuation) map to distinct directories and invalid or ambiguous inputs fail before any disk writes.

CLI --user is validated pre-init: malformed flags and rejected identifiers print to stderr and exit 2 without creating Application Support state. switchUser propagates the same throws. The nonthrowing default initializer keeps GUI/source compatibility on "default".

Validation covers path separators, legacy dot-stripped alias ambiguity, profile/directory owner mismatches, and Default/DEFAULT case rules (existing exact owners retained; new case variants of the built-in namespace blocked).

SynapticCircuit stops fault-propagation depth counting when the BFS frontier stalls (isolated nodes report depth 0). New tests cover storage, CLI integration, circuit regression, and updated persistence failure cases; conventions/journal entries document the boundary.

Reviewed by Cursor Bugbot for commit 341d716. Configure here.

Comment thread Sources/SynapseCore/SynapseCore.swift Resolved
Comment thread Sources/SynapseCore/SynapseCore.swift Resolved
Comment thread Sources/SynapseCore/SynapseCore.swift Resolved
Comment thread Sources/contextsynapse/main.swift Resolved
Comment thread Tests/BayesianConvergenceTests.swift Resolved
@greptile-apps

This comment has been minimized.

@mazze93
mazze93 marked this pull request as ready for review September 26, 2026 17:28
…ases

Preserve existing space-named state and main's LighthouseStore migration. Reject invalid CLI identifiers normally and refuse ambiguous legacy aliases before writing state. Move new regression coverage to separate test files.

Local verification: diff whitespace and journal append-only checks pass. Swift/Xcode are unavailable in this cloud container; macOS CI remains required.
@mazze93 mazze93 changed the title Sanitize per-user storage, preserve edge identity, refactor package, and add tests Preserve user state and validate identifiers without lossy aliases Oct 5, 2026
Comment thread Sources/SynapseCore/SynapseCore.swift Resolved
Comment thread Sources/SynapseCore/UserStorage.swift Resolved
mazze93 and others added 3 commits October 21, 2026 17:47
…lureTests

#40 made SynapseCore.init(folderName:user:baseOverride:) throwing; the
persistence-failure tests landed on main afterwards and called it without
try, so CI failed to compile. Verified locally: swift build + swift test,
226 tests, 0 failures.

Signed-off-by: Mazze LeCzzare Frazer <mazze@mazzeleczzare.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TfxFgJK5GcRzMzXfgumDM8
@mazze93
mazze93 marked this pull request as draft October 30, 2026 04:47
@mazze93
mazze93 marked this pull request as ready for review October 31, 2026 01:22
# Conflicts:
#	docs/journal/DECISIONS.md
Resolve DECISIONS append-only conflict (main entries first).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because on-demand usage is turned off. To enable Bugbot Autofix, turn on on-demand usage and set a spend limit in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 341d716. Configure here.

Comment thread Sources/SynapseCore/UserStorage.swift Resolved
mazze93 and others added 4 commits November 9, 2026 20:40
On a case-insensitive volume the stripped legacy name can match a
directory spelled differently. The error then named an identifier that
failed the exact-name check with conflictingOwner. Report the on-disk
entry instead, and cover it with a regression test (skipped on
case-sensitive volumes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
XCTAssertThrowsError's handler is non-throwing, so the follow-up
validate call inside it failed to compile. Capture the reported key and
assert on it after the throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mazze93
mazze93 merged commit de3143d into main Nov 9, 2026
4 checks passed
@mazze93
mazze93 deleted the codex/fix-bug-in-important-code-section branch November 9, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants