Shared Context
In monorepo and multi-agent systems, agents need to share configuration context — which files to read, which scopes to enforce, and what overrides apply. LODE’s ContextManifest schema encodes this shared context as a verified binary that agents can inherit and extend.
Schema: ContextManifest
context-manifest-v1.lode
{
"schema": "lode",
"version": 1,
"name": "ContextManifest",
"fields": [
{ "id": 1, "name": "scope", "type": "string", "required": true },
{ "id": 2, "name": "inheritsFrom", "type": "string", "required": false },
{ "id": 3, "name": "contextFiles", "type": "string[]", "required": true },
{ "id": 4, "name": "overrides", "type": "map<string,string>", "required": false },
{ "id": 5, "name": "agentScopes", "type": "string[]", "required": false },
{ "id": 6, "name": "locked", "type": "bool", "required": true }
]
}TypeScript Interface
interface ContextManifest {
scope: string; // "org", "team:platform", "repo:api"
inheritsFrom?: string; // Parent scope to inherit from
contextFiles: string[]; // Files that define the context
overrides?: Record<string, string>; // Key-value overrides
agentScopes?: string[]; // Agents this context applies to
locked: boolean; // Prevent downstream overrides
}Example: Monorepo Context Hierarchy
Root context shared by all agents:
org-context.json
{
"scope": "org",
"contextFiles": ["CLAUDE.md", ".agent-config.yaml", "security-policy.yaml"],
"overrides": {
"maxTokens": "100000",
"logLevel": "info"
},
"agentScopes": ["*"],
"locked": false
}Team-level context that inherits from org:
platform-context.json
{
"scope": "team:platform",
"inheritsFrom": "org",
"contextFiles": ["packages/api/CLAUDE.md", "packages/api/.env.schema"],
"overrides": {
"logLevel": "debug",
"testFramework": "vitest"
},
"agentScopes": ["code-reviewer", "test-writer"],
"locked": false
}Locked production context that cannot be overridden:
prod-context.json
{
"scope": "env:production",
"inheritsFrom": "team:platform",
"contextFiles": ["deploy/production.yaml"],
"overrides": {
"logLevel": "warn",
"dryRun": "false"
},
"locked": true
}Compilation
$ lodec compile org-context.json -s context-manifest-v1.lode -o contexts/org.vein
Compiled org-context.json → contexts/org.vein (156 bytes)
Fingerprint: f1a2b3c4...
$ lodec compile platform-context.json -s context-manifest-v1.lode -o contexts/platform.vein
Fingerprint: d5e6f7a8...
$ lodec compile prod-context.json -s context-manifest-v1.lode -o contexts/prod.vein
Fingerprint: b9c0d1e2...Context Resolution
Resolve the full context for an agent by walking the inheritance chain:
async function resolveContext(scope: string): Promise<Record<string, string>> {
const schema = loadLode("context-manifest-v1.lode");
const chain: ContextManifest[] = [];
let current: string | undefined = scope;
while (current) {
const manifest = await loadVerifiedManifest(current, schema);
chain.unshift(manifest);
current = manifest.inheritsFrom;
}
// Merge overrides — later scopes win, unless parent is locked
const merged: Record<string, string> = {};
for (const ctx of chain) {
if (ctx.locked) {
Object.assign(merged, ctx.overrides); // Locked values can't be overridden
} else {
Object.assign(merged, ctx.overrides);
}
}
return merged;
}Lock Enforcement
When a context manifest has locked: true, child scopes cannot override its values:
function mergeWithLock(
parent: ContextManifest,
child: ContextManifest
): Record<string, string> {
const merged = { ...parent.overrides };
if (!parent.locked) {
Object.assign(merged, child.overrides);
}
return merged;
}This ensures production safety constraints propagate down the hierarchy and cannot be accidentally weakened by team or repo-level overrides.
Last updated on