Skip to content

feat(metadata): rename MeditationTags → UserChoices and add SubtleSystemNodes - #321

Merged
Ardnived merged 4 commits into
mainfrom
310-subtle-system-nodes-and-user-choices
Apr 28, 2026
Merged

Ardnived merged 4 commits into
mainfrom
310-subtle-system-nodes-and-user-choices

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Closes #310

Summary

  • Rename MeditationTags → UserChoices (slug meditation-tags → user-choices). Adds required type enum (mood | goal) on UserChoices; mood-only fields hide via admin.condition for goal-type rows.
  • Add SubtleSystemNodes — closed 12-slug enum (chakras + nadis), each linked to a required pages doc. Reverse joins surface attached lectures + frames.
  • Wire up Lectures (+userChoices, +subtleSystemNodes hasMany) and Frames (-category enum, +subtleSystemNode single relationship; 4 non-chakra category values move into tags, deprecated ida/pingala/kundalini tag values removed).
  • Inline migration backfill (per ticket spec): seeds 12 nodes + placeholder Pages, maps existing frames data, fixes two Drizzle polymorphic-FK rebuild bugs (type column on user_choices, meditation_tags_id → user_choices_id rename in payload_locked_documents_rels).

Migration verification

Run against a snapshot of the local D1 (120 frames, 24 meditation_tags, 8 deprecated tag rows, 0 chakra/nadi pages) — all checks pass:

Check Result
12 subtle_system_nodes rows seeded ✅
12 placeholder Pages created (_status='published') ✅
24 user_choices preserved with type='mood' ✅
Frames chakra/nadi backfilled to relationship (8 categories + 4 ida + 4 pingala from tag fallback) ✅
clearing/meditate/ready/namaste appended to frames_tags (10/2/2/2 = 16) ✅
Deprecated tag rows (ida/pingala/kundalini) removed ✅
frames.category column dropped ✅
meditation_tags* tables removed ✅

Test Results

  • Unit tests: 226 passed (11 files)
  • Integration tests: 579 passed, 1 pre-existing flaky failure
  • Build: ✓ Success
  • Lint: ✓ No warnings or errors

Pre-existing flaky test (not introduced by this PR)

tests/int/access-performance.int.spec.ts has timing-based perf assertions (e.g. expect(duration).toBeLessThan(100)) that fail intermittently when run alongside the full suite due to CPU contention. Running the file in isolation passes all 10 cases consistently. This file was not modified in this PR; the flakiness is on main.

Test plan

  • Admin UI: create + edit a SubtleSystemNode, attach userChoices and subtleSystemNodes to a Lecture, see reverse-join counts on both sides.
  • Admin UI: create a UserChoice with type: 'goal' — verify timings + per-timing meditation rels are hidden. Switch to mood and verify they reappear.
  • REST API: /api/user-choices?... returns the same shape the old /api/meditation-tags did.
  • REST API: /api/subtle-system-nodes lists 12 nodes.
  • REST API: /api/frames/:id includes subtleSystemNode (id) and no category.
  • FrameEditor (Meditation > Video tab): the chakra-pill filter still works against the relationship-derived slug.

🤖 Generated with Claude Code

Ardnived and others added 2 commits April 28, 2026 00:09
…temNodes

Closes #310

- Rename `meditation-tags` collection → `user-choices` (slug, labels, hooks
  file, project visibility, role permissions, R2 storage routing).
- Add required `type` enum (`mood` | `goal`) on UserChoices; gate the
  mood-only fields (`timings`, per-timing meditation rels) behind
  `admin.condition` so goal-type rows skip them.
- Add new `SubtleSystemNodes` collection: closed enum of 12 chakra/nadi
  slugs, each linked to a required `pages` doc. Reverse joins expose
  attached lectures + frames.
- Lectures gain optional `userChoices` and `subtleSystemNodes` hasMany
  relationships for future server-side smart selection.
- Frames replace the `category` enum with a `subtleSystemNode`
  relationship; the four non-chakra category values (`clearing`,
  `meditate`, `ready`, `namaste`) move into `tags`. `ida` / `pingala` /
  `kundalini` are removed from `tags` in favour of the relationship.
- Inline migration backfill (per ticket spec): seeds the 12 nodes and
  bootstraps placeholder Pages, then maps existing Frames data — chakra
  categories → relationship, non-chakra → tags, tag-only ida/pingala
  → relationship — before dropping the `category` column. Fixes the two
  Drizzle polymorphic-FK rebuild bugs the change triggered (the new
  `type` column on user_choices and the `meditation_tags_id` →
  `user_choices_id` rename in `payload_locked_documents_rels`).
- FrameEditor admin UI grouping/filtering switches from
  `frame.category` to a slug derived from the populated relationship;
  `framesByNarrator` endpoint now uses `depth: 1` so the relationship
  surfaces for client-side grouping.
- Test factories add `createUserChoice` and `createSubtleSystemNode`;
  spec files renamed; new `subtle-system-nodes.int.spec.ts` covers slug
  uniqueness + reverse-join shape.
- Updated seeds (meditations + tags + tests), docs, and the seeds
  expectedCounts metadata.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…Nodes PR

- Document that Frames.subtleSystemNode is intentionally optional ("Other"
  bucket for non-chakra frames like bandhan/namaste).
- Thread `req` through updateIsParent so the count→update pair joins the
  caller's Payload transaction; prevents two concurrent reparenting events
  from racing on isParent.
- Clarify in UserChoices.parent description that the field is admin-only,
  matching the existing access.update guard.
- Update 3 stale "Meditation Tags" strings in scripts/create-sample-page.ts
  to use "User Choices" terminology.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit da29d3f into main Apr 28, 2026
@Ardnived
Ardnived deleted the 310-subtle-system-nodes-and-user-choices branch April 28, 2026 12:10
sydevs-bot pushed a commit that referenced this pull request Oct 25, 2026
After sydevs/SahajAtlasWeb#321 the failure dialog takes its heading from
`common.map.location_not_available`, the same key that labels the geolocate
control. Its description named only the label, so a manager rewording a
control label would silently reword a dialog heading with nothing to warn
them. Both roles are now stated, in the idiom `submit.report.title` already
uses for a key serving three places.

`location_failed` is described as that heading's introductory line, mirroring
`submit.report.description`. The key keeps its name: #321 reads
`common.map.location_failed` under exactly that spelling, and renaming it to
a `_body` half would break the consumer the key exists for.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01No89uA3CHa1Km3NC1a3EBo
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.

Introduce SubtleSystemNodes collection and rename MeditationTags → UserChoices for unified cross-collection tagging

1 participant