@dzhechkov/harness-core 0.3.140 → 0.3.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -96,7 +96,7 @@ export type {
96
96
  export { runSetup, generateHooksConfig, generateAgentdbWriter, writerVersionOf, AGENTDB_WRITER_VERSION } from './setup.js';
97
97
  export { statuslineData, readFeatureAdrState, writeFeatureAdrState, featureAdrStatePath } from './statusline.js';
98
98
  export type { StatuslineData, FeatureAdrState, WriteFeatureAdrStateInput } from './statusline.js';
99
- export { indexPatternsToAgentdb, resolveAgentdbPath, searchAgentdbPatterns, listAgentdbDzIds, resolveAgentdbEmbedder, cosineSimilarity, importVectorsToAgentdb, reindexAgentdbRows, bumpAgentdbUses, clearAgentdbQuarantine } from './agentdb-index.js';
99
+ export { indexPatternsToAgentdb, resolveAgentdbPath, searchAgentdbPatterns, listAgentdbDzIds, resolveAgentdbEmbedder, cosineSimilarity, importVectorsToAgentdb, reindexAgentdbRows, bumpAgentdbUses, clearAgentdbQuarantine, deleteAgentdbByDzIds, readAgentdbRowsByTaskType, DZ_OWNED_TASK_TYPES } from './agentdb-index.js';
100
100
  export type { AgentdbSearchHit, AgentdbSearchResult, AgentdbImportRow } from './agentdb-index.js';
101
101
  export { DEFAULT_EMBED_MODEL, LEGACY_EMBED_MODEL, DEFAULT_EMBED_DIM, KNOWN_EMBED_DIMS, resolveEmbedModel, readEmbedManifest, writeEmbedManifest, embedManifestPath, legacyEmbedManifest } from './embedding-config.js';
102
102
  export type { EmbedModelConfig, EmbedModelSource, EmbedManifest } from './embedding-config.js';
@@ -330,3 +330,8 @@ export * from './compounding.js';
330
330
  // Run-process scorecard (feature dz-score, Reading C) — scores the DISCIPLINE of a feature-adr run
331
331
  // from its artifacts. Descriptive-only, permanently: it never gates.
332
332
  export * from './score.js';
333
+
334
+ // Smart Backlog (feature smart-backlog) — goal-directed idea pipeline: capture → semantic dedup
335
+ // against the EXISTING Brain vector engine (ADR-001, no 2nd store) → GoalMap alignment (ADR-003) →
336
+ // weighted roulette (ADR-004) → idea2prd enrich hand-off → stub-first Jira adapter seam (ADR-006).
337
+ export * from './backlog.js';
package/src/registry.ts CHANGED
@@ -191,6 +191,8 @@ function categoryFromPack(pack: string): string {
191
191
  // digitizer outputs like `skills-12factor` (The Twelve-Factor App). Future digitized public packs
192
192
  // (e.g. AOSA) should be added here or carry a `book`/digitized marker.
193
193
  if (pack.includes('book') || pack.includes('12factor')) return 'knowledge';
194
+ // Course/tutorial manufacturing (skills-tutorial-factory: package → Head-First edu-site course).
195
+ if (pack.includes('tutorial')) return 'learning';
194
196
  return 'other';
195
197
  }
196
198
 
@@ -65,7 +65,13 @@ import {
65
65
  cosineSimilarity,
66
66
  importVectorsToAgentdb,
67
67
  reindexAgentdbRows,
68
+ readAgentdbRowsByTaskType,
69
+ DZ_OWNED_TASK_TYPES,
68
70
  } from './agentdb-index.js';
71
+ // smart-backlog (ADR-001/005 lifecycle): `dz vector reindex` must re-embed dz-backlog rows too, or
72
+ // they rot in a stale embedding space after a model bump. One-directional import — backlog.ts imports
73
+ // agentdb-index/compounding only, never vector-tier, so there is no cycle.
74
+ import { BACKLOG_TASK_TYPE } from './backlog.js';
69
75
  import { currentEmbedManifest, guardEmbedSpace, DEFAULT_EMBED_DIM, resolveEmbedModel, type EmbedModelConfig } from './embedding-config.js';
70
76
  import { applyLearningSignals, applyLearningSignalsWithDelta, resolveLearningBackend, type LearningSignalBackend } from './learning-backend.js';
71
77
 
@@ -278,6 +284,15 @@ export interface ReindexVectorReport {
278
284
  * silent, since a mixed store looks healthy right up until someone widens a query.
279
285
  */
280
286
  readonly staleTaskTypes?: readonly string[];
287
+ /**
288
+ * smart-backlog honest-skip status. Set ONLY on the non-agentdb-engine path: backlog code never touches
289
+ * the shared manifest, so under a non-agentdb engine NOTHING is reindexed — `backlog:'skipped'` +
290
+ * `generic:'skipped'` + a non-empty `error` say so (overall success is never claimed). Unset on the full
291
+ * agentdb reindex path (which owns and re-embeds dz-backlog together with the other types) — behavior for
292
+ * every other caller is unchanged.
293
+ */
294
+ readonly backlog?: 'skipped';
295
+ readonly generic?: 'skipped';
281
296
  }
282
297
 
283
298
  export type TeachGuardResult =
@@ -963,10 +978,31 @@ export async function vectorTierStatus(
963
978
  }
964
979
 
965
980
  export async function reindexVectorStore(projectRoot: string, opts: VectorServiceOptions = {}): Promise<ReindexVectorReport> {
981
+ // ARCHITECTURAL INVARIANT (smart-backlog): backlog code never PARTIALLY advances the SHARED agentdb
982
+ // model manifest — no path re-stamps it to a new model while leaving a sibling task type un-re-embedded.
983
+ // The FIRST backlog write legitimately establishes the manifest when the store is new (correct); a model
984
+ // ADVANCE happens ONLY here, in a full reindex that re-embeds EVERY owned task type together atomically
985
+ // (taskTypes = DZ_OWNED_TASK_TYPES, which owns dz-backlog — HIGH-3). The old backlog-only re-stamp path
986
+ // spawned an endless class of edge cases (missing/corrupt/rollback/scan-error); it is REMOVED.
966
987
  const resolved = pickEngine(projectRoot, opts);
967
- if (resolved.engine === undefined) return { reembedded: 0, error: resolved.reason ?? 'no vector engine available' };
968
- if (resolved.engine.kind !== 'agentdb') {
969
- return { reembedded: 0, error: 'dz vector reindex currently rewrites the agentdb learned-pattern mirror; switch memory.vector.engine to agentdb/auto' };
988
+ if (resolved.engine === undefined || resolved.engine.kind !== 'agentdb') {
989
+ // Non-agentdb (or absent) engine: the generic learned-pattern reindex can't run here, and backlog must
990
+ // not advance the shared manifest partially. Touch NOTHING honest skip with a UNIFORM shape (LOW-I:
991
+ // always report backlog/generic skipped). Backlog's same-model writes already bind vectors to the
992
+ // current model (HIGH-2); a model bump needs a FULL reindex under the agentdb engine.
993
+ // A non-agentdb vector engine is CONFIGURED (rvf resolved, or requested-but-not-installed) ⇒ the
994
+ // manifest-untouched message pointing to the full agentdb reindex. Only a genuinely absent engine
995
+ // (no config, nothing resolvable) falls back to the bare reason.
996
+ const nonAgentdbConfigured = resolved.engine !== undefined || readVectorEngineMode(projectRoot) === 'rvf';
997
+ return {
998
+ reembedded: 0,
999
+ backlog: 'skipped',
1000
+ generic: 'skipped',
1001
+ error: nonAgentdbConfigured
1002
+ ? 'a non-agentdb vector engine (e.g. RVF) is configured; no reindex was performed and the shared model manifest was NOT touched. ' +
1003
+ 'Run a full reindex under memory.vector.engine=agentdb/auto to re-embed every task type (dz-teach/dz-learning/dz-backlog) together.'
1004
+ : resolved.reason ?? 'no vector engine available',
1005
+ };
970
1006
  }
971
1007
  let records: MemoryRecord[];
972
1008
  try {
@@ -984,7 +1020,14 @@ export async function reindexVectorStore(projectRoot: string, opts: VectorServic
984
1020
  ...(r.tags !== undefined ? { tags: r.tags } : {}),
985
1021
  ...(r.metadata !== undefined ? { metadata: r.metadata } : {}),
986
1022
  }));
987
- return reindexAgentdbRows(projectRoot, rows);
1023
+ // HIGH-G: ownership is by STORE-PRESENCE. Read the dz-backlog rows that ACTUALLY EXIST IN THE STORE and
1024
+ // re-embed THOSE (their stored text) — never reconstruct them from ideas.jsonl, or an empty/unreadable
1025
+ // sidecar would advance the manifest while the store's real dz-backlog rows rot in the old model space.
1026
+ // Symmetric with dz-teach/dz-learning (re-embedded from their store of truth). Only widen the owned set
1027
+ // when the store actually holds dz-backlog rows — a store with none reindexes byte-identically to before.
1028
+ const backlogStoreRows = readAgentdbRowsByTaskType(projectRoot, BACKLOG_TASK_TYPE).rows;
1029
+ if (backlogStoreRows.length === 0) return reindexAgentdbRows(projectRoot, rows);
1030
+ return reindexAgentdbRows(projectRoot, [...rows, ...backlogStoreRows], { taskTypes: DZ_OWNED_TASK_TYPES });
988
1031
  }
989
1032
 
990
1033
  /* ------------------------------------------------------------------ */