feat: replace in_namespace relation with ownership-based namespace membership
Remove the in_namespace edge relation. A node now belongs to a namespace if that namespace has has_ownership on it. This simplifies the model: namespace membership is determined by the ownership chain rather than a separate relation type. Changes: - Remove RelInNamespace constant - Add Namespace fields to AddInput, UpdateInput, and ListFilter - Update Add() to resolve namespace from input and assign it as owner - Update List() to filter by namespace ownership instead of in_namespace edges - Update() can now transfer nodes between namespaces via ownership transfer - Remove in_namespace self-references from ensureNamespace/ensureGlobalNamespace The ownership chain now fully describes both permissions and namespace membership, reducing redundancy. All tests pass with the new model. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ var addCmd = &cobra.Command{
|
||||
input.Rels = append(input.Rels, service.RelInput{Type: models.RelType("_prio::" + cPrio), Target: ""})
|
||||
}
|
||||
if cNamespace != "" {
|
||||
input.Rels = append(input.Rels, service.RelInput{Type: models.RelInNamespace, Target: cNamespace})
|
||||
input.Namespace = cNamespace
|
||||
}
|
||||
if cAssignee != "" {
|
||||
input.Rels = append(input.Rels, service.RelInput{Type: models.RelAssignee, Target: cAssignee})
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ var listCmd = &cobra.Command{
|
||||
filter.Rels = append(filter.Rels, service.RelInput{Type: models.RelType("_type::" + lType), Target: ""})
|
||||
}
|
||||
if lNamespace != "" {
|
||||
filter.Rels = append(filter.Rels, service.RelInput{Type: models.RelInNamespace, Target: lNamespace})
|
||||
filter.Namespace = lNamespace
|
||||
}
|
||||
if lAssignee != "" {
|
||||
filter.Rels = append(filter.Rels, service.RelInput{Type: models.RelAssignee, Target: lAssignee})
|
||||
|
||||
+2
-14
@@ -49,7 +49,7 @@ var (
|
||||
"low": {" ", "low", cDim},
|
||||
"": {" ", "n/a", cDim},
|
||||
}
|
||||
relIcons = map[string]string{"blocks": "\uf068", "subtask": "\uf0da", "related": "\uf0c1", "assignee": "\uf007", "in_namespace": "\uf07b"}
|
||||
relIcons = map[string]string{"blocks": "\uf068", "subtask": "\uf0da", "related": "\uf0c1", "assignee": "\uf007"}
|
||||
prioRanks = map[string]int{"high": 3, "medium": 2, "low": 1}
|
||||
statusRanks = map[string]int{"open": 2, "": 1, "done": 0}
|
||||
)
|
||||
@@ -94,24 +94,12 @@ func PrintNodes(w io.Writer, svc service.NodeService, nodes []*models.Node, json
|
||||
})
|
||||
|
||||
for _, n := range nodes {
|
||||
n_rels := n.Relations
|
||||
ns_rel_node_ids := n_rels[string(models.RelInNamespace)]
|
||||
ns_rel_node_titles := make([]string, 0, len(ns_rel_node_ids))
|
||||
for _, id := range ns_rel_node_ids {
|
||||
ns_rel_node, err := svc.GetByID(id)
|
||||
if err != nil {
|
||||
ns_rel_node_titles = append(ns_rel_node_titles, id)
|
||||
continue
|
||||
}
|
||||
ns_rel_node_titles = append(ns_rel_node_titles, ns_rel_node.Title)
|
||||
}
|
||||
fmt.Fprintf(w, " %s %s %s %s %s %s %s",
|
||||
fmt.Fprintf(w, " %s %s %s %s %s %s",
|
||||
cDim.Sprint(n.ID),
|
||||
render(prioRM, n.GetProperty("prio"), true),
|
||||
render(statusRM, n.GetProperty("status"), true),
|
||||
render(typeRM, n.GetProperty("type"), true),
|
||||
cTitle.Sprint(truncate(n.Title, 80)),
|
||||
cDim.Sprint("["+strings.Join(ns_rel_node_titles, ",")+"]"),
|
||||
dueDateShort(n.DueDate),
|
||||
)
|
||||
tags := n.GetDisplayTags()
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ var updateCmd = &cobra.Command{
|
||||
input.AddRels = append(input.AddRels, service.RelInput{Type: models.RelType("_prio::" + uPrio), Target: ""})
|
||||
}
|
||||
if cmd.Flags().Changed("namespace") {
|
||||
input.AddRels = append(input.AddRels, service.RelInput{Type: models.RelInNamespace, Target: uNamespace})
|
||||
input.Namespace = &uNamespace
|
||||
}
|
||||
if cmd.Flags().Changed("assignee") {
|
||||
input.AddRels = append(input.AddRels, service.RelInput{Type: models.RelAssignee, Target: uAssignee})
|
||||
|
||||
Reference in New Issue
Block a user