Skip to content

Commit 55e2367

Browse files
committed
Expose Context ABI guide
1 parent f18cde3 commit 55e2367

5 files changed

Lines changed: 71 additions & 16 deletions

File tree

core/context_abi/lib/outer_brain/context_abi/failure.ex

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,24 @@ defmodule OuterBrain.ContextABI.Failure do
234234
defp owner(_owner), do: {:error, :invalid_failure_owner}
235235

236236
defp infer_family(reason_code) do
237-
cond do
238-
String.contains?(reason_code, ".context.") -> {:ok, :context}
239-
String.contains?(reason_code, ".authority.") -> {:ok, :authority}
240-
String.contains?(reason_code, ".route.") -> {:ok, :router}
241-
String.contains?(reason_code, ".model_") -> {:ok, :model_execution}
242-
String.contains?(reason_code, ".inference.") -> {:ok, :model_execution}
243-
String.contains?(reason_code, ".eval.") -> {:ok, :eval}
244-
String.contains?(reason_code, ".memory.") -> {:ok, :memory}
245-
String.contains?(reason_code, ".optimization.") -> {:ok, :optimization}
246-
String.contains?(reason_code, ".promotion.") -> {:ok, :promotion}
247-
String.contains?(reason_code, ".rollback.") -> {:ok, :promotion}
248-
String.contains?(reason_code, ".evidence.") -> {:ok, :evidence}
249-
String.contains?(reason_code, ".replay.") -> {:ok, :evidence}
250-
true -> {:error, :unknown_failure_family}
237+
case Enum.find(@family_prefixes, fn {prefix, _family} ->
238+
String.starts_with?(reason_code, prefix)
239+
end) do
240+
{_prefix, family} -> {:ok, family}
241+
nil -> infer_family_from_fragment(reason_code)
242+
end
243+
end
244+
245+
defp infer_family_from_fragment(reason_code) do
246+
[
247+
{".model_", :model_execution},
248+
{".inference.", :model_execution},
249+
{".rollback.", :promotion}
250+
]
251+
|> Enum.find(fn {fragment, _family} -> String.contains?(reason_code, fragment) end)
252+
|> case do
253+
{_fragment, family} -> {:ok, family}
254+
nil -> {:error, :unknown_failure_family}
251255
end
252256
end
253257

core/memory_engine/mix.exs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ defmodule OuterBrain.MemoryEngine.MixProject do
1616
end
1717

1818
def application do
19-
[extra_applications: [:crypto, :logger]]
19+
[
20+
extra_applications: [
21+
:crypto,
22+
:logger,
23+
:outer_brain_guardrail_engine,
24+
:outer_brain_memory_contracts
25+
]
26+
]
2027
end
2128

2229
def cli do

guides/context_abi.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# OuterBrain Context ABI
2+
3+
OuterBrain owns the Context ABI data model and semantic artifact references for
4+
the NSHKR stack. The public surface is the `core/context_abi` package, with
5+
prompt rendering owned by `core/outer_brain_prompting`.
6+
7+
## Owned Outputs
8+
9+
- `OuterBrain.ContextABI.ContextUnit` for bounded context inputs.
10+
- `OuterBrain.ContextABI.ContextPacket` for admitted packet facts and packet
11+
hashes.
12+
- `OuterBrain.Prompting.ContextRenderer` for sealed prompt artifact refs,
13+
provider payload refs, and payload hashes.
14+
- Failure reason codes under `OuterBrain.ContextABI.Failure`.
15+
16+
## Boundary Rules
17+
18+
OuterBrain does not execute models, grant authority, promote optimization
19+
candidates, or own product projections. Mezzanine holds the rendered prompt
20+
handoff as a `Mezzanine.AIExecution.RenderResult` and passes only refs and
21+
hashes to Jido Integration.
22+
23+
Raw prompts and raw memory bodies must not cross product, authority, workflow,
24+
or model-runtime boundaries. Use artifact refs, payload refs, packet hashes,
25+
trace refs, and bounded failure reason codes.
26+
27+
## Local QC
28+
29+
```bash
30+
mix ci
31+
```
32+
33+
StackLab proof of the Context ABI path is owned by StackLab. OuterBrain remains
34+
responsible for its package tests, canonical hashing, renderer validation, and
35+
redaction posture.

guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Implementation-facing guides:
44

55
- [Generalized Stack Boundary](https://github.com/nshkrdotcom/outer_brain/blob/main/guides/generalized_stack.md)
6+
- [Context ABI](context_abi.md)
67
- [Code Smell Remediation](code_smell_remediation.md)
78
- [QC And Operations](https://github.com/nshkrdotcom/outer_brain/blob/main/guides/qc_and_operations.md)
89

mix.exs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ defmodule OuterBrain.Workspace.MixProject do
144144
"docs/layout.md",
145145
"docs/runtime_model.md",
146146
"docs/integration_surface.md",
147+
"guides/context_abi.md",
148+
"guides/generalized_stack.md",
149+
"guides/qc_and_operations.md",
147150
"guides/code_smell_remediation.md",
148151
"CHANGELOG.md",
149152
"LICENSE"
@@ -152,7 +155,12 @@ defmodule OuterBrain.Workspace.MixProject do
152155
Overview: ["README.md", "docs/overview.md"],
153156
Architecture: ["docs/layout.md", "docs/runtime_model.md"],
154157
Integration: ["docs/integration_surface.md"],
155-
Guides: ["guides/code_smell_remediation.md"],
158+
Guides: [
159+
"guides/context_abi.md",
160+
"guides/generalized_stack.md",
161+
"guides/qc_and_operations.md",
162+
"guides/code_smell_remediation.md"
163+
],
156164
Project: ["CHANGELOG.md", "LICENSE"]
157165
]
158166
]

0 commit comments

Comments
 (0)