Skip to content

Commit fbb633f

Browse files
neo-opus-adatobiu
andauthored
refactor(agentos): drop redundant ?. on guaranteed sourcePaths SSOT in 11 KB source classes (#12467) (#12469)
B3 (ADR 0019 SS3): sourcePaths is an SSOT leaf (knowledge-base/config.template.mjs:220), always present (overlays inherit it), so aiConfig.sourcePaths?.X masked fail-loud. Behavior-equivalent ?. removal (callers already assume the value, e.g. .map). Also drops bare ticket-refs (#10097 chroma-zip-portability, #11316 skill sub-metadata) from touched comments per the check-ticket-archaeology guard; rationale preserved. ProtoSource example excluded (public external template, intentional fallback). Co-authored-by: tobiu <tobiasuhlig78@gmail.com>
1 parent 180034a commit fbb633f

11 files changed

Lines changed: 18 additions & 18 deletions

ai/services/knowledge-base/source/AdrSource.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AdrSource extends Base {
3737
let count = 0;
3838
// Per-source path from the `sourcePaths` config (SSOT — the leaf in the KB config template
3939
// defines every Source's default path).
40-
const adrDir = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths?.AdrSource);
40+
const adrDir = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths.AdrSource);
4141

4242
if (await fs.pathExists(adrDir)) {
4343
const files = await fs.readdir(adrDir);

ai/services/knowledge-base/source/ApiSource.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ApiSource extends Base {
4141
*/
4242
async extract(writeStream, createHashFn) {
4343
// Per-source sourceMap (path → type object) from the `sourcePaths` config (SSOT).
44-
const sourceMap = aiConfig.sourcePaths?.ApiSource;
44+
const sourceMap = aiConfig.sourcePaths.ApiSource;
4545

4646
// Load the authoritative class hierarchy
4747
let hierarchy = {};
@@ -96,7 +96,7 @@ class ApiSource extends Base {
9696
// Emit the neoRootDir-relative path as chunk metadata.source so the distributed
9797
// Chroma zip shipped with each neo release stays portable across recipients'
9898
// filesystems. SearchService resolves against its own neoRootDir at read time.
99-
// See #10097 — absolute paths would hard-code tobi's FS layout into the zip.
99+
// Absolute paths would hard-code the local FS layout into the distributed zip.
100100
const chunks = SourceParser.parse(content, relativeEntryPath, defaultType, hierarchy);
101101

102102
chunks.forEach(chunk => {

ai/services/knowledge-base/source/ConceptSource.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConceptSource extends Base {
3737
async extract(writeStream, createHashFn) {
3838
let count = 0;
3939
// Per-source path from the `sourcePaths` config (SSOT).
40-
const conceptsDir = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths?.ConceptSource);
40+
const conceptsDir = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths.ConceptSource);
4141

4242
if (await fs.pathExists(conceptsDir)) {
4343
const files = await fs.readdir(conceptsDir);

ai/services/knowledge-base/source/DiscussionSource.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class DiscussionSource extends Base {
6060
let count = 0;
6161
// Per-source paths (array) from the `sourcePaths` config (SSOT). Each entry is resolved
6262
// against `neoRootDir`.
63-
const discussionPaths = aiConfig.sourcePaths?.DiscussionSource;
63+
const discussionPaths = aiConfig.sourcePaths.DiscussionSource;
6464
const targetPaths = discussionPaths.map(p => path.resolve(aiConfig.neoRootDir, p));
6565

6666
const indexMap = await loadIndexMap(aiConfig.neoRootDir, 'discussions');
@@ -87,7 +87,7 @@ class DiscussionSource extends Base {
8787
kind : 'discussion',
8888
name : `discussion-${id}`,
8989
content,
90-
// Relative path keeps the distributed Chroma zip portable (#10097).
90+
// Relative path keeps the distributed Chroma zip portable.
9191
source : path.relative(aiConfig.neoRootDir, filePath)
9292
};
9393

ai/services/knowledge-base/source/LearningSource.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class LearningSource extends Base {
4242
let count = 0;
4343
// Per-source path from the `sourcePaths` config (SSOT). The value points at the tree.json
4444
// file; the base directory containing the .md files is its containing directory.
45-
const learnTreeRelative = aiConfig.sourcePaths?.LearningSource;
45+
const learnTreeRelative = aiConfig.sourcePaths.LearningSource;
4646
const learnTreePath = path.resolve(aiConfig.neoRootDir, learnTreeRelative);
4747
const learnBaseRelative = path.dirname(learnTreeRelative);
4848

@@ -57,7 +57,7 @@ class LearningSource extends Base {
5757
if (await fs.pathExists(filePath)) {
5858
const content = await fs.readFile(filePath, 'utf-8');
5959
// Pass the neoRootDir-relative path so stored chunk metadata stays
60-
// portable across distributed Chroma zips (#10097). fs.readFile above
60+
// portable across distributed Chroma zips. fs.readFile above
6161
// still uses the absolute path internally.
6262
const chunks = DocumentationParser.parse(item, content, path.relative(aiConfig.neoRootDir, filePath));
6363

ai/services/knowledge-base/source/PullRequestSource.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class PullRequestSource extends Base {
6262
async extract(writeStream, createHashFn) {
6363
let count = 0;
6464
// Per-source paths (array) from the `sourcePaths` config (SSOT).
65-
const pullRequestPaths = aiConfig.sourcePaths?.PullRequestSource;
65+
const pullRequestPaths = aiConfig.sourcePaths.PullRequestSource;
6666
const targetPaths = pullRequestPaths.map(p => path.resolve(aiConfig.neoRootDir, p));
6767

6868
const indexMap = await loadIndexMap(aiConfig.neoRootDir, 'pulls');
@@ -89,7 +89,7 @@ class PullRequestSource extends Base {
8989
kind : 'pull',
9090
name : `pr-${id}`,
9191
content,
92-
// Relative path keeps the distributed Chroma zip portable (#10097).
92+
// Relative path keeps the distributed Chroma zip portable.
9393
source : path.relative(aiConfig.neoRootDir, filePath)
9494
};
9595

ai/services/knowledge-base/source/RawRepoSource.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class RawRepoSource extends Base {
7777
* @returns {Promise<Number>} Number of file chunks extracted.
7878
*/
7979
async extract(writeStream, createHashFn) {
80-
const config = this.normalizeConfig(aiConfig.sourcePaths?.RawRepoSource),
80+
const config = this.normalizeConfig(aiConfig.sourcePaths.RawRepoSource),
8181
rootPath = path.resolve(aiConfig.neoRootDir, config.root);
8282

8383
if (!await fs.pathExists(rootPath)) {

ai/services/knowledge-base/source/ReleaseNotesSource.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ReleaseNotesSource extends Base {
3737
async extract(writeStream, createHashFn) {
3838
let count = 0;
3939
// Per-source path from the `sourcePaths` config (SSOT).
40-
const releaseNotesPath = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths?.ReleaseNotesSource);
40+
const releaseNotesPath = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths.ReleaseNotesSource);
4141

4242
if (await fs.pathExists(releaseNotesPath)) {
4343
const releaseFiles = await fs.readdir(releaseNotesPath);
@@ -52,7 +52,7 @@ class ReleaseNotesSource extends Base {
5252
kind : 'release',
5353
name : file.replace('.md', ''),
5454
content,
55-
// Relative path keeps the distributed Chroma zip portable (#10097).
55+
// Relative path keeps the distributed Chroma zip portable.
5656
source : path.relative(aiConfig.neoRootDir, filePath)
5757
};
5858

ai/services/knowledge-base/source/SkillSource.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SkillSource extends Base {
3939
async extract(writeStream, createHashFn) {
4040
let count = 0;
4141
// Per-source path from the `sourcePaths` config (SSOT).
42-
const skillsBasePath = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths?.SkillSource);
42+
const skillsBasePath = path.resolve(aiConfig.neoRootDir, aiConfig.sourcePaths.SkillSource);
4343

4444
if (await fs.pathExists(skillsBasePath)) {
4545
// Using fast-glob to recursively find all .md files in the skills directory
@@ -99,7 +99,7 @@ class SkillSource extends Base {
9999
name: chunkName,
100100
content: section.trim(),
101101
source: relativePath,
102-
// Sub-metadata for #11316 AC
102+
// Per-section skill sub-metadata (name, anchor, trigger).
103103
skillName,
104104
sectionAnchor,
105105
triggerCondition,

ai/services/knowledge-base/source/TestSource.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TestSource extends Base {
4141
*/
4242
async extract(writeStream, createHashFn) {
4343
// Per-source path from the `sourcePaths` config (SSOT).
44-
const testPath = aiConfig.sourcePaths?.TestSource;
44+
const testPath = aiConfig.sourcePaths.TestSource;
4545
return await this.indexRawDirectory(writeStream, createHashFn, testPath, 'test', {
4646
include: ['.mjs'],
4747
exclude: ['node_modules', 'test-results', 'reports']

0 commit comments

Comments
 (0)