#!/usr/bin/env node
/**
* Add Table of Contents and Glossary to the Taiuru mapping blog post
*
* Usage:
* node scripts/add-toc-glossary-taiuru.js # local dev DB
* node scripts/add-toc-glossary-taiuru.js mongodb://... # production DB
*/
const mongoose = require('mongoose');
const MONGODB_URI = process.argv[2] || 'mongodb://localhost:27017/tractatus_dev';
const SLUG = 'kaupapa-maori-ai-framework-tractatus-mapping';
const tableOfContents = `
`;
const glossary = `
Glossary
Te Reo Māori Terms
Ātārangi
Shadow or reflection. In Taiuru's framework, the third dimension of AI — AI is constituted entirely by human thought, language, and culture. The shadow carries something of the original.
Hapū
Sub-tribe or clan. A political and social unit within an iwi, typically comprising several whānau.
He Tangata
A person, a human being. In Taiuru's framework, the first dimension — AI presents as a person but meets none of the conditions of personhood in te ao Māori.
Hui
A gathering, meeting, or assembly for discussion and decision-making.
Iwi
Tribe or nation. The largest political unit in Māori society, comprising multiple hapū.
Kaitiakitanga
Guardianship, stewardship. The obligation to care for and protect something for future generations.
Karetao
Puppet or marionette. In Taiuru's framework, the second dimension — AI is animated by external forces (developers, operators, users) like a puppet by strings.
Kaupapa Māori
A Māori approach or philosophy. A framework grounded in Māori worldview, values, and practices.
Kōrero
Speech, discussion, conversation.
Mana Motuhake
Autonomous authority, self-determination. The right of Māori to control their own affairs.
Marae
A communal meeting ground and its buildings. The focal point of Māori community life.
Mātauranga Māori
Māori knowledge, wisdom, and understanding. The body of knowledge originating from Māori ancestors.
Mauri
Life force, vital essence. An essential quality of all things, both animate and inanimate.
Noa
Free from tapu, ordinary, unrestricted.
Pūrākau
Stories, narratives. Traditional and contemporary Māori storytelling.
Rōpū
Group, organisation, or collective.
Taonga
A treasured possession, something of value. Can be tangible (an artifact) or intangible (language, knowledge).
Tapu
Sacred, restricted, set apart. Indicates spiritual restriction and the need for respectful handling.
Te Ao Māori
The Māori world, worldview, and way of understanding reality.
Te Tiriti o Waitangi
The Treaty of Waitangi (1840). The founding document of New Zealand, establishing the relationship between Māori and the Crown.
Tikanga
Correct procedure, custom, protocol. The Māori way of doing things according to cultural values.
Tino Rangatiratanga
Absolute sovereignty, self-determination, autonomy. The right of Māori to govern their own affairs.
Waka Hourua
Double-hulled canoe. Used by Te Kāhui Raraunga as a governance model — two hulls (te ao Māori and Kāwanatanga) structurally independent, neither dominating, connected by a shared deck.
Wānanga
A forum for discussion, learning, and deliberation. An extended meeting for deep consideration of issues.
Whakapapa
Genealogy, lineage, identity. The network of relationships connecting people, ancestors, and the natural world.
Whānau
Extended family group. The foundational social unit in Māori society.
Technical and Governance Terms
CARE Principles
Collective Benefit, Authority to Control, Responsibility, Ethics — principles for indigenous data governance developed by the Global Indigenous Data Alliance.
Constitutional AI
An approach to AI safety where behaviour is governed by a set of principles (a constitution) rather than case-by-case rules.
Federation
A system where independent communities form bilateral agreements to share specific capabilities while each retaining full sovereignty over their own data and governance.
Guardian Agents
Deterministic (non-AI) code that evaluates AI outputs before they reach community members. Four-phase system: evidence gathering, baseline comparison, classification, risk assessment.
Koha
A gift given with reciprocity. In the platform context, voluntary contributions without transaction fees.
Metagovernance
Governance of the governance system itself — ensuring that the mechanisms controlling AI are themselves accountable and auditable.
OCAP Principles
Ownership, Control, Access, Possession — First Nations (Canadian) principles asserting community-level authority over data.
Polycentric Governance
A governance model with multiple independent centres of authority (drawn from Elinor Ostrom's work), as opposed to a single hierarchical structure.
Situated Language Layer (SLL)
Product-type-specific AI model fine-tuning. Each community type gets an AI tuned to its domain knowledge and vocabulary.
Steering Vectors
Mathematical adjustments applied to an AI model's internal representations during inference, shaping how it processes concepts at the embedding layer. Only possible with sovereign model hosting.
Steering Packs
Versioned governance artefacts published by steering authorities. Can contain system prompt additions, cultural boundary sets, or activation vectors that shape AI behaviour.
Tractatus Framework
An architectural framework for AI governance developed by My Digital Sovereignty Ltd. Enforces governance structurally through boundary enforcement, mathematical verification, and layered accountability. Published under Apache 2.0.
`;
// Section heading ID mapping
const headingIds = {
'Two Frameworks, Two Traditions, One Problem': 'two-frameworks',
'He Tangata: The Person': 'he-tangata',
'He Karetao: The Puppet': 'he-karetao',
'Guardian Agents: The Karetao\'s Accountability Mechanism': 'guardian-agents',
'He Ātārangi: The Shadow': 'he-atarangi',
'Steering Vectors, Polycentric Governance, and Cultural Weight': 'steering-vectors',
'Federation: From Village to Network': 'federation',
'Te Tiriti Principles and the Architecture': 'te-tiriti',
'What Both Frameworks Reveal About Each Other': 'what-both-reveal',
'Research Directions': 'research-directions',
'The Legal Governance Layer: Kaitiakitanga Licence': 'legal-governance',
'The Economics of Sovereign AI: Training, Inference, and Value': 'economics',
'What Remains Genuinely Missing': 'gaps',
'Gaps': 'gaps'
};
async function main() {
await mongoose.connect(MONGODB_URI);
console.log('Connected to:', MONGODB_URI);
const db = mongoose.connection.db;
const post = await db.collection('blog_posts').findOne({ slug: SLUG });
if (!post) {
console.error('Blog post not found:', SLUG);
process.exit(1);
}
console.log('Found:', post.title);
console.log('Content length:', (post.content || '').length);
let content = post.content || '';
// Check if already applied
if (content.includes('id="table-of-contents"')) {
console.log('ToC already present. Skipping.');
await mongoose.disconnect();
return;
}
// Add section IDs to headings
for (const [heading, id] of Object.entries(headingIds)) {
// Match
heading text
and add id attribute
const escaped = heading.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(`