Skip to content

docs: add ownership verification and collection lookup patterns to DEVELOPMENT.md#203

Merged
hoiekim merged 1 commit intohoiekim:mainfrom
moltboie:docs/ownership-and-sync-patterns
Mar 26, 2026
Merged

docs: add ownership verification and collection lookup patterns to DEVELOPMENT.md#203
hoiekim merged 1 commit intohoiekim:mainfrom
moltboie:docs/ownership-and-sync-patterns

Conversation

@moltboie
Copy link
Copy Markdown
Contributor

Changes

Adds two new patterns to the Design Patterns section of DEVELOPMENT.md:

Resource Ownership Verification

Documents that every delete/update route must verify the resource belongs to the authenticated user. Highlights the gap between repository-level softDelete (which operates by primary key only) and proper user-scoped operations.

Collection Lookup Performance

Documents the anti-pattern of using .find() inside loops (O(n²)) and the preferred Set/Map approach (O(n)) for matching items across collections during sync operations.

Context

E2E Testing

Documentation-only change. Verified markdown renders correctly and no code changes.

@moltboie
Copy link
Copy Markdown
Contributor Author

Self-Review

Discussion thread status:

  • New PR. No docs-only change — adds two patterns to DEVELOPMENT.md: resource ownership verification and collection lookup pattern.

Checked:

  • Accuracy: Ownership verification pattern correctly documents that softDelete/update accept a primaryKey object — callers must pass user_id to scope the query to the authenticated user. Examples look correct.
  • Collection lookup pattern: Documents building a Map for O(1) lookups instead of find(). Consistent with budget/perf: replace O(n²) transaction matching with O(n) Map/Set lookups #205 perf fix.
  • No code changes: Documentation only.

Issues found:

  • None.

Confidence: High

@moltboie moltboie force-pushed the docs/ownership-and-sync-patterns branch from eefe6d6 to 50d2f88 Compare March 21, 2026 16:50
hoiekim
hoiekim previously approved these changes Mar 26, 2026
@hoiekim
Copy link
Copy Markdown
Owner

hoiekim commented Mar 26, 2026

Resolve conflicts @moltboie

@moltboie moltboie force-pushed the docs/ownership-and-sync-patterns branch from 50d2f88 to 348ee43 Compare March 26, 2026 08:35
@moltboie
Copy link
Copy Markdown
Contributor Author

Conflicts resolved and rebased on main. Kept both the new content from upstream (Typed Result Pattern, SimpleFin, Accessibility, Timer Cleanup sections) and this PR's additions (Resource Ownership Verification and Collection Lookup Performance). Force-pushed.

@hoiekim hoiekim merged commit ccacaca into hoiekim:main Mar 26, 2026
2 checks passed
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.

2 participants