scroll # Stack-Based Implementation Guidelines ##Invocation This guideline captures what shouldbe implemented, enforced, and tested based onthe stack as it exists now. The immediatepressure came from the migration of`ruby.priority` into `topaz.priority`, but thedeeper law is larger: **the stack must expressgem canon truthfully, and implementation mustfollow that truth without ambiguity.** This isnot only a data migration concern. It is aquery concern, a display concern, a creationconcern, a compatibility concern, and a futurevalidation concern. --- ## Core Law **Gemmeaning is fixed.** Implementation must notcasually blur semantic ownership across gems.Current working law: - **onyx** → name -**sapphire** → archetype / kind - **pearl**→ body / content - **ruby** →classification / tags / status-likenon-numeric metadata - **topaz** → numericmeasurements and quantities - **amethyst** →access / visibility - **obsidian** →relationships - **diamond** → provenance -**emerald** → timestamps / time -**citrine** → locality / realm / host / pathThat means: - `priority` belongs in **topaz**- `loc_estimate` belongs in **topaz** -`byte_weight` belongs in **topaz** - `ip`,`ssh_host`, and similar location-bearingvalues belong in **citrine** - `status`remains in **ruby** --- ## Guideline I — AllNew Writes Must Follow Canon Creation pathsmust write new fields into the correct gem onfirst creation. This means: - no new codeshould write numeric operational values into`ruby` - creation helpers should place numericvalues directly into `topaz` -locality-bearing fields should be written into`citrine` - relation-bearing fields should bewritten into `obsidian` This applies to: - gapcreation - route creation - node creation -mesh/forest records - atlas/material/objectThings - any new Thing categories introducedlater **Implementation rule:** New code shouldnever rely on future migration to fix bad gemplacement. --- ## Guideline II — Reads MustBe Backward-Compatible During Migration Wherehistorical data exists in the wrong gem, readsshould temporarily support both the canonicaland legacy field locations. The pattern is: -read canonical location first - fall back tolegacy location - present one coherent valueto the user/system Example shape: -`topaz.priority` first, fallback to`ruby.priority` - `topaz.byte_weight` first,fallback to `ruby.byte_weight` This shouldremain in place only while migration isincomplete or old data still exists.**Implementation rule:** Use compatibilityreads as a bridge, not a permanent excuse fordrift. --- ## Guideline III — Ordering,Ranking, and Selection Must Use CanonicalFields Anything that sorts, ranks, filters, orprioritizes Things must read from the correctgem. That includes: - forge gap ordering -stem queries - route priority ordering -pending work ranking - futureatlas/material/object selection logic - any UIor world-system that ranks by priority, cost,density, or magnitude If the meaning isnumeric, the primary source must be **topaz**.**Implementation rule:** Ordering logic isontology made executable. If ordering readsthe wrong gem, the system is lying. --- ##Guideline IV — Display Layers Must ReflectCanon Without Breaking Old Data All displaypaths should be updated to present canonicalfields while still tolerating older bodies.This includes: - forge displays - add/successsummaries - query results - status views -diagnostic screens - future Portal/Web and 3Dviews The user should see the correct valueregardless of whether the Thing has alreadybeen migrated. **Implementation rule:** Do notlet the interface become a second schema. ---## Guideline V — Migrations Must Be Paired Areal migration is not only data. A completemigration must include: 1. **data migration**2. **query migration** 3. **write-pathmigration** 4. **display migration** 5.**help/docs/example migration** 6. **testmigration** If one of these is skipped, themigration is incomplete. The recent prioritymove showed this clearly: - database rows wereupdated - code references were found -ordering logic was fixed - creation logic wascorrected - display reads were updated - helptext was adjusted That is the minimum propershape. **Implementation rule:** Never call amigration done because the database changed.--- ## Guideline VI — Query and HelpSurfaces Must Teach Canon User-facing queryexamples, help text, and docs must reinforcethe real gem locations. If examples stillteach: - `ruby.priority` when the system nowexpects: - `topaz.priority` then thedocumentation becomes a source of corruption.This applies to: - CLI help - forge help -scrolls and FIDs when they speak concretely -Portal query builders - future onboardingsurfaces **Implementation rule:** Examples areschema pressure. Treat them as part ofimplementation. --- ## Guideline VII — TypesShould Acquire Chord Profiles Each `sapphire`type should gradually develop an expected**gem chord profile**. Not a rigid prison atfirst, but a known pattern: - dominant gems -expected gems - optional gems - suspiciouslyabsent gems For example: ### Gap Thing Likelyheavy in: - `onyx` - `sapphire` - `pearl` -`ruby.status` - `topaz.priority` -`topaz.loc_estimate` - `topaz.byte_weight` -`obsidian` links - `citrine` locality ### NodeThing Likely heavy in: - `onyx` - `sapphire` -`ruby` role/class - `citrine` host/networklocality - `topaz` numeric ports/load/weights- `obsidian` peer/service links This shouldeventually support: - validation - linting -migration hints - query optimization - displaydefaults **Implementation rule:** Gem canondefines field meaning. Chord profiles defineexpected body shape. --- ## Guideline VIII —Validation Should Become System Truth Thestack should eventually enforce or at leastwarn on suspicious placement. Examples: -numeric fields found in `ruby` - localityfields found in `ruby` - timestamps outside`emerald` - host/path values outside `citrine`- relation lists outside `obsidian` Thisshould not begin as brittle refusaleverywhere. It can begin as: - warnings duringcreation - lint tools - diagnostic reports -migration suggestions - CI checks for coreThings **Implementation rule:** The ontologyshould be testable, not just discussable. ---## Guideline IX — Load Pressure Should BeMeasured Against Semantic Shape Gem placementis not only neatness. It affects pressure. Badplacement causes: - worse queries -inconsistent ordering - harder indexing - morecomplicated displays - more expensivemigrations - weaker validation So bottlenecktesting should include semantic integritychecks, not only runtime speed. Questions toask: - are topaz-heavy queries using topazconsistently? - are locality filters pullingfrom citrine consistently? - are relationtraversals staying inside obsidian? - aredisplays composing one Thing body orcompensating for schema drift?**Implementation rule:** Semantic drift is aperformance problem in slow motion. --- ##Guideline X — Compatibility Paths Must Havean End Every fallback should imply a futurecleanup target. For example: - support`ruby.priority` during transition - migrateall known records - remove legacy fallbackonce the body is clean - document the cutoffOtherwise compatibility code becomes permanentrot. **Implementation rule:** Backwardcompatibility is a bridge, not a homeland. ---## Immediate Implementation List Based on thecurrent stack and migration direction, thefollowing should be implemented or continued:### 1. Canonical field ownership audit Auditcommon Things for obvious gem misplacements: -numeric values in ruby - locality in ruby -timestamps outside emerald - relation bodiesoutside obsidian ### 2. Chord profiles formajor Thing kinds Start with: - gap - node -route - fid - ring -atlas/material/object-related Things -mesh/forest deployment Things ### 3.Read/write parity checks For each migratedfield: - ensure creators write canonically -ensure readers prefer canonical fields -ensure displays show canonical values - ensuresort/order paths use canonical values ### 4.Query/help example cleanup Update examples andhelp text to teach real gem usage. ### 5.Migration registry Maintain a simple list of:- migrated fields - pending migrations -temporary fallbacks - removal targets ### 6.Validation/lint layer Add a lightweightvalidator for gem misuse by Thing type. ### 7.Bottleneck testing with semantic tracing Whentesting load, tag pressure by: - gem family -query type - traversal type - manifestationlayer so bottlenecks can be tied back tosemantic structure. --- ## Closing The recentmigration was not just cleanup. It revealedthe real law: **implementation must serve thestack, not quietly redefine it.** When thecanon is correct and the code obeys it: -queries simplify - displays clarify -migrations shrink - validation becomespossible - load testing becomes more honest -the ontology begins to carry its own weightThat is the path worth keeping.