-
Notifications
You must be signed in to change notification settings - Fork 0
Social federation #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PetalCat
wants to merge
9
commits into
pr-8
Choose a base branch
from
social-federation
base: pr-8
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f578891
feat: Implement initial federation features including identity, share…
ParkerH27 f978e4e
feds or somth
ParkerH27 35c460c
broken ahh code
ParkerH27 96596af
THE FEDS BE WORKIN
ParkerH27 d77ed58
feat: Add scripts for a federated development setup and database insp…
ParkerH27 5280b64
feat: Implement Loro connection state management with auto-reconnect …
ParkerH27 4db0271
feat: Implement password-protected federated notes, account settings,…
ParkerH27 a827ad6
fancy shmancy perms stuff
ParkerH27 36be6b7
feat: Add drafted design spec for sharing and permissions.
ParkerH27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,350 @@ | ||
| # **Federated Notes App — Structure, Permissions, and Sharing Spec** | ||
|
|
||
| ## **Status**: | ||
|
|
||
| **_Draft_** | ||
|
|
||
| # Please Approve or Edit | ||
|
|
||
| --- | ||
|
|
||
| ## **1. Core Design Invariants** | ||
|
|
||
| The system MUST obey the following rules at all times: | ||
|
|
||
| 1. Spaces define visibility | ||
| 2. Visibility has exactly one source | ||
| 3. Notes never define visibility | ||
| 4. Per-note permissions restrict actions only | ||
| 5. Structure never implies permission | ||
| 6. Permission never implies structure | ||
| 7. One space has exactly one authority(server in the federated system) of record | ||
|
|
||
| Any feature that violates one of these invariants is invalid. | ||
|
|
||
| --- | ||
|
|
||
| ## **2. Spaces** | ||
|
|
||
| ### **2.1 Definition** | ||
|
|
||
| A **Space** is the only internal visibility and collaboration boundary. | ||
|
|
||
| ### **2.2 Properties** | ||
|
|
||
| Space | ||
| - space_id | ||
| - authority_id | ||
| - members: Map<UserID, Role> | ||
| - root_folder_id | ||
|
|
||
| ### **2.3 Rules** | ||
|
|
||
| - Every space has exactly one authority of record | ||
| - Spaces cannot be nested | ||
| - Spaces may include members from multiple federations | ||
| - All notes in a space are owned by the space authority | ||
| - All space members can see all notes in the space | ||
| - Spaces may not include notes owned by other authorities | ||
|
|
||
| ### **2.4 Purpose** | ||
|
|
||
| Answers the question: | ||
|
|
||
| > Who can see all content here by default? | ||
|
|
||
| --- | ||
|
|
||
| ## **3. Folders (Within Spaces)** | ||
|
|
||
| ### **3.1 Definition** | ||
|
|
||
| Folders are structural containers inside a space. | ||
|
|
||
| ### **3.2 Rules** | ||
|
|
||
| - Folders inherit space visibility | ||
| - Folders may be nested arbitrarily | ||
| - Folders cannot be shared | ||
| - Folders cannot alter permissions | ||
| - Folders cannot contain notes from other spaces | ||
|
|
||
| ### **3.3 Purpose** | ||
|
|
||
| Answers the question: | ||
|
|
||
| > How is content organized within the space? | ||
|
|
||
| --- | ||
|
|
||
| ## **4. Notes** | ||
|
|
||
| ### **4.1 Definition** | ||
|
|
||
| A **Note** is the smallest unit of content and the smallest externally shareable unit. | ||
|
|
||
| ### **4.2 Properties** | ||
|
|
||
| Note | ||
| - note_id | ||
| - space_id | ||
| - authority_id | ||
| - content | ||
| - metadata | ||
|
|
||
| ### **4.3 Rules** | ||
|
|
||
| - A note belongs to exactly one space | ||
| - A note is visible to all space members | ||
| - A note may be included in zero or more Share Groups | ||
| - A note may have per-note action restrictions | ||
| - A note cannot exist in multiple spaces simultaneously | ||
|
|
||
| --- | ||
|
|
||
| ## **5. Per-Note Action Permissions** | ||
|
|
||
| ### **5.1 Definition** | ||
|
|
||
| Per-note permissions restrict **actions**, not visibility. | ||
|
|
||
| ### **5.2 Allowed Restrictions** | ||
|
|
||
| - Read | ||
| - Comment | ||
| - Suggest | ||
| - Edit | ||
| - Lock | ||
| - Prevent delete | ||
| - Prevent move | ||
| - Prevent rename | ||
|
|
||
| ### **5.3 Forbidden Capabilities** | ||
|
|
||
| - Restricting visibility | ||
| - Adding new viewers | ||
| - Creating sub-audiences | ||
| - Partial space visibility | ||
|
|
||
| ### **5.4 Resolution Order** | ||
|
|
||
| Effective Action Permission = | ||
| least_privileged( | ||
| External Share Role (if applicable), | ||
| Note Policy, | ||
| Space Role | ||
| ) | ||
|
|
||
| ### **5.5 Rule** | ||
|
|
||
| If a user can see a note, per-note policies only determine what they may do to it. | ||
|
|
||
| --- | ||
|
|
||
| ## **6. Collections** | ||
|
|
||
| ### **6.1 Definition** | ||
|
|
||
| Collections are **local, per-user organizational folders for spaces**. | ||
|
|
||
| ### **6.2 Rules** | ||
|
|
||
| - Collections are client-side only | ||
| - Collections are not shared | ||
| - Collections have no permissions | ||
| - Collections do not affect visibility | ||
| - Collections are not part of URLs or linking | ||
|
|
||
| ### **6.3 Invariant** | ||
|
|
||
| Removing collections does not affect collaboration or access. | ||
|
|
||
| --- | ||
|
|
||
| ## **7. File Tree** | ||
|
|
||
| ### **7.1 Purpose** | ||
|
|
||
| The file tree displays structural truth only. | ||
|
|
||
| ### **7.2 Displays** | ||
|
|
||
| - Spaces | ||
| - Folders | ||
| - Notes | ||
|
|
||
| ### **7.3 Does Not Display** | ||
|
|
||
| - External share groupings | ||
| - Permission bundles | ||
| - Visibility differences | ||
|
|
||
| ### **7.4 Annotations** | ||
|
|
||
| Notes may display informational badges indicating: | ||
|
|
||
| - External sharing | ||
| - Locked or restricted actions | ||
|
|
||
| These annotations do not alter structure. | ||
|
|
||
| --- | ||
|
|
||
| ## **8. External Shares** | ||
|
|
||
| ## **9\. Share Groups** | ||
|
|
||
| ### **9.1 Definition** | ||
|
|
||
| An **is the only wat\* y to share a norte mm, re ,,h o outside of a space.f | ||
| A **Share Group\*\* is a first-class permission object representing an external share. | ||
|
|
||
| ### **9.2 Properties** | ||
|
|
||
| ShareGroup | ||
| - share_group_id | ||
| - owner_space_id | ||
| - note_ids[] | ||
| - user_ids[] | ||
| - role (viewer | commenter | editor) | ||
|
|
||
| ### **.3 Rules** | ||
|
|
||
| - Only listed notes are visible | ||
| - Only listed users receive access | ||
| - No inheritance | ||
| - No structure | ||
| - Not represented in the file tree | ||
|
|
||
| --- | ||
|
|
||
| ## **10\. Visibility Resolution (Authoritative)** | ||
|
|
||
| A user may see a note if and only if: | ||
|
|
||
| user ∈ space.members | ||
| OR | ||
| (user ∈ share_group.users AND note ∈ share_group.notes) | ||
|
|
||
| Exactly one visibility source applies. | ||
|
|
||
| --- | ||
|
|
||
| ## **11\. External User Experience** | ||
|
|
||
| ### **11.1 Entry Point** | ||
|
|
||
| . | ||
| **Shared with Me** | ||
|
|
||
| ### **11.2 Display Model** | ||
|
|
||
| Each Share Group appears as a grouped entry. | ||
|
|
||
| Shared with Me | ||
| Project – Teacher Review | ||
| - notes.md | ||
| - research.md | ||
| - summary.md | ||
|
|
||
| ### **11.3 Restrictions** | ||
|
|
||
| External users: | ||
|
|
||
| - Cannot browse spaces or folders | ||
| - Cannot see sibling notes | ||
| - Cannot resolve non-shared links | ||
| - Cannot view backlinks or graphs | ||
|
|
||
| --- | ||
|
|
||
| ## **12\. Private Notes** | ||
|
|
||
| ### **12.1 Definition** | ||
|
|
||
| A private note is a note in a single-user space. | ||
|
|
||
| ### **12.2 Sharing** | ||
|
|
||
| Private notes are shared exclusively via Share Groups. | ||
|
|
||
| There is no separate private-sharing mechanism. | ||
|
|
||
| --- | ||
|
|
||
| ## **13\. Moving Notes Between Spaces** | ||
|
|
||
| . | ||
|
|
||
| ### **13.1 Definition** | ||
|
|
||
| Moving a note between spaces changes its ownership and visibility. | ||
|
|
||
| ### **13.2 Same-Authority Move** | ||
|
|
||
| - space_id is updated | ||
| - note_id remains unchanged | ||
| - Note becomes visible to destination space members | ||
| - All external shares are revoked | ||
|
|
||
| ### **13.3 Cross-Authority Move** | ||
|
|
||
| - Conte. is exported | ||
| - New note is created under the destination authority | ||
| - New note_id is assigned | ||
| - Original note may be deleted explicitly | ||
| - Links are rewritten where possible | ||
|
|
||
| ### **13.4 UX Requirement** | ||
|
|
||
| Users must be warned on move: | ||
|
|
||
| > Moving this note will make it visible to all members of the destination space. | ||
| > External shares will be removed. | ||
|
|
||
| --- | ||
|
|
||
| ## **15\. Explicitly Disallowed** | ||
|
|
||
| The system will never support: | ||
|
|
||
| - Nested spaces | ||
| - Folder-level sharing | ||
| - Structure-derived permissions | ||
| - Partial visibility inside a space | ||
| - Cross-authority notes within a space | ||
| - Implicit sharing | ||
| - Share Groups as navigable containers | ||
|
|
||
| --- | ||
|
|
||
| ## **16\. Model Summary** | ||
|
|
||
| . | ||
| **Layer** | ||
|
|
||
| **Responsibility** | ||
|
|
||
| Spaces | ||
|
|
||
| Visibility and ownership | ||
|
|
||
| Folders | ||
|
|
||
| Structure | ||
|
|
||
| Notes | ||
| . | ||
| Content | ||
|
|
||
| Note Policies | ||
|
|
||
| Action restrictions | ||
|
|
||
| Collections | ||
|
|
||
| Personal navigation | ||
|
|
||
| Share Groups | ||
|
|
||
| Explicit visibility exceptions |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { fetchUserIdentity } from "./src/lib/server/federation.ts"; | ||
|
|
||
| async function testIdentity() { | ||
| console.log("=== Identity Fetch Verification ==="); | ||
| const handle = "@bob:localhost:5174"; | ||
| const requestingDomain = "localhost:5173"; | ||
|
|
||
| try { | ||
| console.log(`Fetching identity for ${handle} from ${requestingDomain}...`); | ||
| const identity = await fetchUserIdentity(handle, requestingDomain); | ||
|
|
||
| console.log("Result:"); | ||
| console.log(JSON.stringify(identity, null, 2)); | ||
|
|
||
| if (identity && identity.publicKey) { | ||
| console.log( | ||
| "\nPublic Key First 10 chars:", | ||
| identity.publicKey.slice(0, 10), | ||
| ); | ||
| } else { | ||
| console.log("\n❌ No Public Key found!"); | ||
| } | ||
| } catch (e) { | ||
| console.error("❌ Error fetching identity:", e); | ||
| } | ||
| } | ||
|
|
||
| testIdentity(); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need all these? If yes, move them to
scripts/.