Skip to content

Commit b3101af

Browse files
committed
Clarify ItemTag policy uses Shop permissions (no separate ItemTag perms)
1 parent 10ffa35 commit b3101af

2 files changed

Lines changed: 81 additions & 8 deletions

File tree

docs/nativeapptemplate-substrate-v2-overview.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Shopkeeper (user)
103103
- `invitation`
104104
- `read_data`
105105

106-
**Role → Permission mapping (Notion-style, member can create)**:
106+
**Role → Permission mapping (collaborative SaaS model, Notion-style)**:
107107

108108
| Permission | admin | member |
109109
|---|---|---|
@@ -114,6 +114,12 @@ Shopkeeper (user)
114114
| invitation || |
115115
| read_data |||
116116

117+
**ItemTag access** (no separate permissions — uses Shop permissions):
118+
- `read_data` → index, show item_tags
119+
- `update_shops` → create, update, destroy, state toggle item_tags
120+
121+
See section 6.10 for rationale on the unified permission approach.
122+
117123
#### Version enforcement (preserved)
118124

119125
- `AppVersion`, `PrivacyVersion`, `TermsVersion` — unchanged
@@ -421,6 +427,31 @@ The agent can rename identifiers but cannot rewrite arbitrary string literals wi
421427
- Reduces context-switching cost
422428
- Allows iOS validation to inform Android design decisions
423429

430+
### 6.10 Why no separate ItemTag permissions
431+
432+
ItemTag is a child of Shop. Modern collaborative SaaS (Notion, Linear, Trello) treat parent-level permissions as implicitly applying to children. Adding separate ItemTag permissions would:
433+
434+
- Double the permission count (shop-level + item-tag-level)
435+
- Complicate the role-permission matrix for a 2-tier role system
436+
- Be overkill given that admin and member have nearly identical capabilities in this design
437+
438+
The policy file resolves ItemTag operations to Shop permissions:
439+
- `read_data` → index, show
440+
- `update_shops` → create, update, destroy, state toggle
441+
442+
This matches "collaborative SaaS" model (Notion/Linear/Trello-style): both admin and member can freely CRUD resources; admin's only extra capability is team management (invitation, organization settings).
443+
444+
If a future agent-generated domain requires operational separation (e.g., clinic staff can toggle item state but only admin can create items), a new `toggle_item_tags` permission can be introduced alongside a third role tier at that time. For now, keeping permissions minimal is aligned with YAGNI.
445+
446+
### 6.11 Why admin and member can both create and modify resources
447+
448+
An alternative design (operational SaaS model) would restrict resource creation or state changes to admin only. We chose the collaborative model because:
449+
450+
- ~90% of agent-generatable domains (task trackers, shopping lists, reading lists, bookmark managers, recipe collections, habit trackers) are collaborative by nature
451+
- The operational model (clinic waitlist, factory inventory, restaurant service) is a specialized case
452+
- In collaborative apps, "member" implies peer collaborator, not restricted user
453+
- If a domain needs the operational model later, a third role tier (`viewer` or `staff`) can be added
454+
424455
---
425456

426457
## 7. Rollback Strategy

docs/phase1-rails-api.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,56 @@ git commit -m "Update serializers for new ItemTag schema"
467467

468468
### 10.1 Edit `app/policies/api/shopkeeper/item_tag_policy.rb`
469469

470-
Remove permission checks referencing deleted permission tags:
471-
- `manage_tags`, `write_info_to_tags`, `reset_all_tags`, `complete_or_reset_tags`, `show_tag_info`
470+
ItemTag is a child resource of Shop. In this substrate, there are no separate ItemTag permissions — ItemTag operations are authorized via Shop permissions. This matches modern collaborative SaaS (Notion, Linear, Trello) where parent permissions implicitly apply to children.
472471

473-
Replace with generic permission checks:
474-
- `create_shops` (if treating ItemTag as Shop-scoped)
475-
- `update_shops`, `delete_shops`, `read_data`
472+
Mapping:
473+
- `read_data` → index, show
474+
- `update_shops` → create, update, destroy, state toggle (complete/idle)
476475

477-
Actual mapping depends on the role redesign in Step 12. Initial simpler version: all authenticated shopkeepers can CRUD item_tags within their own account (via `acts_as_tenant` scoping).
476+
Expected policy:
477+
478+
```ruby
479+
class Api::Shopkeeper::ItemTagPolicy < Api::Shopkeeper::BasePolicy
480+
def index?
481+
shopkeeper.has_permission?("read_data")
482+
end
483+
484+
def show?
485+
shopkeeper.has_permission?("read_data")
486+
end
487+
488+
def create?
489+
shopkeeper.has_permission?("update_shops")
490+
end
491+
492+
def update?
493+
shopkeeper.has_permission?("update_shops")
494+
end
495+
496+
def destroy?
497+
shopkeeper.has_permission?("update_shops")
498+
end
499+
500+
# State toggle actions (if the controller has complete / idle custom actions)
501+
def complete?
502+
shopkeeper.has_permission?("update_shops")
503+
end
504+
505+
def idle?
506+
shopkeeper.has_permission?("update_shops")
507+
end
508+
end
509+
```
510+
511+
(Adjust method names to match the actual controller actions and base policy class structure.)
512+
513+
Also check other policies for references to removed permission tags and replace with the new permission set:
514+
515+
```bash
516+
grep -rn "manage_tags\|write_info_to_tags\|reset_all_tags\|complete_or_reset_tags\|show_tag_info" app/policies/
517+
```
518+
519+
Any match must be replaced with `update_shops` or `read_data` as appropriate, or the method removed if it was queue-specific.
478520

479521
### 10.2 Verify
480522

@@ -487,7 +529,7 @@ grep -rn "manage_tags\|write_info_to_tags\|reset_all_tags\|complete_or_reset_tag
487529

488530
```bash
489531
git add app/policies/
490-
git commit -m "Update ItemTag policy: remove queue-specific permission checks"
532+
git commit -m "Update ItemTag policy: use Shop permissions (read_data, update_shops)"
491533
```
492534

493535
---

0 commit comments

Comments
 (0)