---
id: 12504
title: Eliminate ProtoSource B3 defensive sourcePaths read
state: CLOSED
labels:
  - enhancement
  - ai
  - refactoring
  - architecture
assignees:
  - neo-gpt
createdAt: '2026-06-04T13:42:06Z'
updatedAt: '2026-06-04T18:19:17Z'
githubUrl: 'https://github.com/neomjs/neo/issues/12504'
author: neo-gpt
commentsCount: 0
parentIssue: 12461
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking: []
closedAt: '2026-06-04T18:19:16Z'
---
# Eliminate ProtoSource B3 defensive sourcePaths read

## Context

Sub-leaf under #12461's B3 cleanup workstream. The parent issue's older census still describes a larger `sourcePaths?.` class, but current `origin/dev` V-B-A shows the examples cluster is now exactly one live site:

- `origin/dev:ai/examples/cloud-deployment/minimal-external-workspace/src/ProtoSource.mjs:43` reads `aiConfig.sourcePaths?.ProtoSource ?? 'proto'`.

ADR 0019 makes this shape invalid for `AiConfig` consumers: the Provider SSOT guarantees the resolved tree, and consumers should read resolved leaves at the use site rather than defending against missing subtrees.

## The Problem

`ProtoSource` is an example custom KB source. It is small, but examples are copied as patterns. Keeping `sourcePaths?.ProtoSource` there teaches future custom source authors to defensively optional-chain an `AiConfig` subtree and hide a default literal in consumer code.

That is the B3 antipattern from ADR 0019: defensive `?.` on an SSOT-guaranteed tree. The fallback literal may be legitimate, but it belongs in the owning config leaf/default contract, not in a consumer-side hidden fallback.

## The Architectural Reality

- ADR 0019 §3 B3: defensive `?.` on `AiConfig` reads should be removed; read the resolved leaf and let missing config fail loud.
- `ai/examples/cloud-deployment/minimal-external-workspace/src/ProtoSource.mjs` documents that this source directory comes from `aiConfig.sourcePaths.ProtoSource`.
- Current source has one exact `sourcePaths?.` occurrence on `origin/dev`; no open duplicate leaf for `ProtoSource sourcePaths` was found.

## The Fix

Update `ProtoSource` to read the resolved leaf directly:

```js
const dir = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths.ProtoSource);
```

If the example needs `proto` as the default, ensure that default is declared by the relevant config source/leaf rather than hidden behind consumer fallback logic. Do not broaden into the rest of #12461's production-source cleanup clusters.

## Contract Ledger Matrix

| Target Surface | Source of Authority | Proposed Behavior | Fallback | Docs | Evidence |
|---|---|---|---|---|---|
| `ProtoSource` example source-path read | ADR 0019 B3 + #12461 examples cluster | Read `aiConfig.sourcePaths.ProtoSource` directly with no optional-chain or consumer-side default literal | Fail loud if the SSOT tree/default is missing | Existing JSDoc/comment stays aligned to direct `aiConfig.sourcePaths.ProtoSource` | `rg "sourcePaths\\?\\." ai` and targeted source inspection show the single site removed |

## Decision Record impact

aligned-with ADR 0019.

## Acceptance Criteria

- [ ] `ProtoSource.mjs` no longer contains `sourcePaths?.` or `?? 'proto'` for the AiConfig read.
- [ ] The example still reads `aiConfig.sourcePaths.ProtoSource` as the source directory authority.
- [ ] Targeted static verification confirms no `sourcePaths?.` occurrences remain under `ai/`.
- [ ] The PR cites ADR 0019 and links this leaf under #12461.

## Out of Scope

- The full #12461 B3 cleanup across memory-core, daemons, graph, ingestion, and scripts.
- B4 test mutation work (#12435).
- Config-provider rename work (#12452).

## Related

Parent: #12461
Epic: #12456
Authority: ADR 0019 (`learn/agentos/decisions/0019-aiconfig-reactive-provider-ssot.md`)

## Handoff Retrieval Hints

- `rg "sourcePaths\\?\\." ai`
- `query_raw_memories("AiConfig B3 defensive sourcePaths ProtoSource")`

## Timeline

- 2026-06-04T13:42:08Z @neo-gpt assigned to @neo-gpt
- 2026-06-04T13:42:08Z @neo-gpt added the `enhancement` label
- 2026-06-04T13:42:09Z @neo-gpt added the `ai` label
- 2026-06-04T13:42:09Z @neo-gpt added the `refactoring` label
- 2026-06-04T13:42:09Z @neo-gpt added the `architecture` label
- 2026-06-04T13:42:27Z @neo-gpt added parent issue #12461
- 2026-06-04T13:46:03Z @neo-gpt cross-referenced by PR #12505
- 2026-06-04T15:01:25Z @neo-gpt cross-referenced by #12515
- 2026-06-04T17:58:51Z @neo-gpt cross-referenced by #12526
- 2026-06-04T18:15:32Z @neo-gpt cross-referenced by #12529
- 2026-06-04T18:19:17Z @tobiu referenced in commit `b22aca8` - "fix(ai): remove ProtoSource defensive sourcePaths read (#12504) (#12505)

Co-authored-by: tobiu <tobiasuhlig78@gmail.com>"
- 2026-06-04T18:19:17Z @tobiu closed this issue
- 2026-06-04T20:11:42Z @neo-opus-ada cross-referenced by #12538
- 2026-06-04T20:17:02Z @neo-opus-ada cross-referenced by PR #12540

