dsh-harbor-evolution 0.4.0 → 0.6.0

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Installable DeepSeek Harness Plugin + Skill for running stable Harbor evaluation and controlled Agent evolution loops, with a native DSH Web dashboard.
4
4
 
5
- The package gives DSH four deterministic Harbor tools, dedicated Tool cards, a Harbor conversation tab, an installation Doctor, and the model- and user-invocable `evolve-agent-with-harbor` Skill. The Skill clarifies the evaluation contract, initializes missing structures, establishes a baseline, diagnoses evidence, limits each iteration to one controlled Candidate change, runs regression evaluation, and produces a Promotion Gate recommendation.
5
+ The package gives DSH twelve strict Harbor tools, dedicated Tool cards, a nine-stage Evaluation Workbench, an installation Doctor, and the model- and user-invocable `evolve-agent-with-harbor` Skill. The Skill clarifies and initializes the Evaluation Stack, validates Dataset identity, checks Trial Lifecycle and Score Validity, governs independent Ground Truth meta-evaluation, diagnoses evidence provenance, limits each iteration to one controlled Candidate change, and invokes the Promotion Gate only as an explicit action.
6
6
 
7
7
  ## Install
8
8
 
@@ -14,8 +14,8 @@ npx --yes dsh-harbor-evolution@latest setup --project-root "$PWD"
14
14
 
15
15
  The setup command installs both required runtimes:
16
16
 
17
- - `harbor-dsh-evolution==0.4.0` in a managed Python environment.
18
- - `dsh-harbor-evolution@0.4.0` in the selected DSH profile.
17
+ - `harbor-dsh-evolution==0.6.0` in a managed Python environment.
18
+ - `dsh-harbor-evolution@0.6.0` in the selected DSH profile.
19
19
 
20
20
  It then stores the absolute Harbor executable paths and `projectRoot` in the profile's `harbor-evolution` block and verifies the integration. Existing unrelated profile entries are preserved, and rerunning setup updates the same block.
21
21
 
@@ -35,19 +35,27 @@ Inspect this workspace and help me clarify and initialize a stable Harbor self-e
35
35
  The Plugin registers:
36
36
 
37
37
  - `harbor_candidate_snapshot`
38
+ - `harbor_evolution_init`
39
+ - `harbor_evolution_doctor`
40
+ - `harbor_dataset_validate`
41
+ - `harbor_context_preview`
38
42
  - `harbor_eval_run`
39
43
  - `harbor_eval_result`
40
44
  - `harbor_candidate_compare`
41
45
 
42
46
  In the `web` profile, the same package also registers:
43
47
 
44
- - a `Harbor` conversation tab for recent Jobs, metrics, Candidate identity, and evaluation-context digests;
45
- - four compact result cards for the Harbor Tool calls;
46
- - a `Harbor Evolution` Settings section that checks the configured project, Jobs directory, and CLI paths.
48
+ - a localized nine-stage Workbench that directly exposes fixed experiment identities, Agent-visible Dataset queries/instructions, safe business-artifact previews, Ground Truth meta-evaluation, paginated per-Trial evidence and recommendations, Population validity/coverage, controlled optimization hypotheses, and Baseline/Gate deltas; raw JSON remains in the audit drawer;
49
+ - descriptor-authorized Evaluator/Rubric source editing for `script` and `llm-as-judge` implementations, with optimistic concurrency and mandatory new identities;
50
+ - a `harbor-dsh-evaluator/v1` interface shared by deterministic scripts and LLM-as-Judge implementations;
51
+ - compact result cards for all Harbor Tool calls;
52
+ - a `Harbor Evolution` Settings section that checks the configured project, Evaluation Stack, Jobs directory, and CLI paths.
47
53
 
48
54
  The Web UI is intentionally read-only. Starting an evaluation or deciding promotion remains an explicit Agent + Skill workflow, so a page refresh can never launch an expensive Job.
49
55
 
50
- The shortest direct evaluation call needs `candidatePath` and `datasetPath`. Prefer the Skill for a new project because it will not run or compare Jobs until the material evaluation contract is resolved.
56
+ A direct evaluation requires `candidatePath`, `datasetPath`, `stackPath`, and explicit `mode`; `promotion-eligible` additionally requires `policyPath`. Prefer the Skill because it will not run or compare Jobs until the material identities and evaluation contract are resolved.
57
+
58
+ `harbor_eval_result` defaults to the stable Summary. Use `view=job`, `view=dataset`, `view=progress`, `view=trial` plus a returned `trialId`, or `view=governance` to inspect sanitized instructions, generated output, evidence, and evaluator source without coupling the Agent to artifact file paths.
51
59
 
52
60
  ## What setup writes
53
61
 
package/index.js CHANGED
@@ -72,26 +72,133 @@ export function apply(ctx, config) {
72
72
  },
73
73
  }, args => service.snapshot(args)))
74
74
 
75
+ ctx.tools.register(jsonTool({
76
+ name: 'harbor_evolution_init',
77
+ description: 'Initialize a strict, non-overwriting Evaluation Stack project after the Skill has clarified identities, primary metric, judge, and promotion threshold.',
78
+ parameters: {
79
+ datasetPath: { type: 'string', required: true },
80
+ stackId: { type: 'string', required: true },
81
+ stackVersion: { type: 'string', required: true },
82
+ datasetId: { type: 'string', required: true },
83
+ datasetVersion: { type: 'string', required: true },
84
+ contractId: { type: 'string', required: true },
85
+ contractVersion: { type: 'string', required: true },
86
+ primaryMetric: { type: 'string', required: true },
87
+ primaryDirection: { type: 'string', required: true },
88
+ judgeProvider: { type: 'string', required: true },
89
+ judgeModel: { type: 'string', required: true },
90
+ judgeVersion: { type: 'string', required: true },
91
+ policyId: { type: 'string', required: true },
92
+ policyVersion: { type: 'string', required: true },
93
+ minImprovement: { type: 'number', required: true },
94
+ },
95
+ }, args => service.initialize(args)))
96
+
97
+ ctx.tools.register(jsonTool({
98
+ name: 'harbor_evolution_doctor',
99
+ description: 'Validate the Evaluation Stack architecture, Dataset manifest, Candidate, and optional Promotion Policy before an expensive Harbor Job.',
100
+ parameters: {
101
+ candidatePath: { type: 'string', required: true },
102
+ datasetPath: { type: 'string', required: true },
103
+ stackPath: { type: 'string', required: true },
104
+ policyPath: { type: 'string' },
105
+ mode: { type: 'string', required: true },
106
+ },
107
+ }, args => service.doctor(args)))
108
+
109
+ ctx.tools.register(jsonTool({
110
+ name: 'harbor_dataset_validate',
111
+ description: 'Validate dataset-manifest.json, task uniqueness, instructions, paths, sensitive metadata, and the immutable source digest.',
112
+ parameters: {
113
+ datasetPath: { type: 'string', required: true },
114
+ },
115
+ }, args => service.validateDataset(args)))
116
+
117
+ ctx.tools.register(jsonTool({
118
+ name: 'harbor_context_preview',
119
+ description: 'Preview Evaluation Context v2 and find comparable baselines before launching a Job.',
120
+ parameters: {
121
+ candidatePath: { type: 'string', required: true },
122
+ candidateId: { type: 'string' },
123
+ version: { type: 'string' },
124
+ datasetPath: { type: 'string', required: true },
125
+ stackPath: { type: 'string', required: true },
126
+ mode: { type: 'string', required: true },
127
+ },
128
+ }, args => service.previewContext(args)))
129
+
75
130
  ctx.tools.register(jsonTool({
76
131
  name: 'harbor_eval_run',
77
- description: 'Snapshot and run one DeepSeek Harness Candidate against a Harbor dataset, then return the completed evaluation summary.',
132
+ description: 'Run a strict diagnostic or promotion-eligible Harbor Job bound to Candidate, Dataset Manifest, Evaluation Stack, and Context v2 identities.',
78
133
  parameters: {
79
134
  candidatePath: { type: 'string', required: true },
80
135
  candidateId: { type: 'string' },
81
136
  version: { type: 'string' },
82
137
  datasetPath: { type: 'string', required: true },
138
+ stackPath: { type: 'string', required: true },
139
+ mode: { type: 'string', required: true },
140
+ policyPath: { type: 'string' },
83
141
  jobName: { type: 'string' },
84
142
  },
85
143
  }, args => service.run(args)))
86
144
 
87
145
  ctx.tools.register(jsonTool({
88
146
  name: 'harbor_eval_result',
89
- description: 'Read the stable evaluation summary produced for a Harbor Job.',
147
+ description: 'Read a stable Job summary or a sanitized Workbench, Dataset instruction, Trial output/evidence, progress, or Evaluator governance view. Invalid scores remain distinct from raw verifier rewards.',
90
148
  parameters: {
91
149
  jobPath: { type: 'string', required: true },
150
+ view: { type: 'string', description: 'summary (default), job, dataset, progress, trial, or governance' },
151
+ trialId: { type: 'string', description: 'Required only for view=trial; use an id returned by the Job/Progress view' },
152
+ compareJob: { type: 'string', description: 'Optional previous Job for view=governance impact analysis' },
153
+ since: { type: 'string', description: 'Optional ISO timestamp for incremental progress changes' },
92
154
  },
93
155
  }, args => service.result(args)))
94
156
 
157
+ ctx.tools.register(jsonTool({
158
+ name: 'harbor_evaluator_inspect',
159
+ description: 'Inspect the active harbor-dsh-evaluator/v1 descriptor, implementation kind, ternary Criteria, and safely editable source files.',
160
+ parameters: {
161
+ stackPath: { type: 'string', description: 'Defaults to .harbor/evaluation-stack.yml' },
162
+ },
163
+ }, args => service.evaluatorInspect(args)))
164
+
165
+ ctx.tools.register(jsonTool({
166
+ name: 'harbor_evaluator_update',
167
+ description: 'Update one descriptor-authorized Evaluator source file with optimistic concurrency. Requires new Evaluator and Stack identities and never runs evaluation or Gate automatically.',
168
+ parameters: {
169
+ stackPath: { type: 'string', description: 'Defaults to .harbor/evaluation-stack.yml' },
170
+ filePath: { type: 'string', required: true },
171
+ content: { type: 'string', required: true },
172
+ expectedDigest: { type: 'string', required: true },
173
+ newEvaluatorVersion: { type: 'string', required: true },
174
+ newStackVersion: { type: 'string', required: true },
175
+ },
176
+ }, args => service.evaluator(args)))
177
+
178
+ ctx.tools.register(jsonTool({
179
+ name: 'harbor_ground_truth_init',
180
+ description: 'Create a non-overwriting Ground Truth draft for evaluator meta-evaluation. GT may be human, programmatic, consensus, model, or external, but must have explicit provenance and remain independent of the Candidate evaluator.',
181
+ parameters: {
182
+ outputPath: { type: 'string', description: 'Defaults to .harbor/ground-truth.json' },
183
+ groundTruthId: { type: 'string', required: true },
184
+ version: { type: 'string', required: true },
185
+ sourceKind: { type: 'string', required: true, description: 'human, programmatic, consensus, model, or external' },
186
+ sourceDescription: { type: 'string', required: true },
187
+ provenance: { type: 'string', required: true },
188
+ criteria: { type: 'string', required: true, description: 'Comma-separated criterion ids' },
189
+ },
190
+ }, args => service.groundTruthInitialize(args)))
191
+
192
+ ctx.tools.register(jsonTool({
193
+ name: 'harbor_evaluator_meta_evaluate',
194
+ description: 'Compare repeated evaluator-observations/v1 with independent ground-truth/v1 and write an ESF, SCE, and RCR meta-evaluation report.',
195
+ parameters: {
196
+ groundTruthPath: { type: 'string', description: 'Defaults to .harbor/ground-truth.json' },
197
+ observationsPath: { type: 'string', required: true },
198
+ outputPath: { type: 'string', description: 'Defaults to .harbor/meta-evaluation-report.json' },
199
+ },
200
+ }, args => service.evaluatorMetaEvaluate(args)))
201
+
95
202
  ctx.tools.register(jsonTool({
96
203
  name: 'harbor_candidate_compare',
97
204
  description: 'Apply the deterministic Promotion Gate to a baseline Job and a Candidate Job.',
package/lib/candidate.js CHANGED
@@ -6,6 +6,16 @@ export const MANIFEST_NAME = 'candidate-manifest.json'
6
6
  const DIGEST_PREFIX = Buffer.from('harbor-dsh-candidate-v1\0')
7
7
  const EXCLUDED_DIRS = new Set(['.git', 'node_modules', '__pycache__'])
8
8
  const EXCLUDED_FILES = new Set([MANIFEST_NAME, '.DS_Store'])
9
+ const LOCKFILES = ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock', 'bun.lock', 'bun.lockb']
10
+ const CREDENTIAL_FILES = new Set([
11
+ 'credentials.json',
12
+ 'service-account.json',
13
+ 'secrets.json',
14
+ 'secrets.yaml',
15
+ 'secrets.yml',
16
+ 'id_rsa',
17
+ 'id_ed25519',
18
+ ])
9
19
 
10
20
  async function walk(root, current = root) {
11
21
  const entries = await readdir(current, { withFileTypes: true })
@@ -46,8 +56,7 @@ export async function computeCandidate(candidateDir) {
46
56
  return { digest: `sha256:${digest.digest('hex')}`, files }
47
57
  }
48
58
 
49
- export async function snapshotCandidate(candidateDir, options = {}) {
50
- const root = path.resolve(candidateDir)
59
+ async function validateCandidateContract(root) {
51
60
  for (const required of ['cordis.yml', 'package.json']) {
52
61
  try {
53
62
  if (!(await stat(path.join(root, required))).isFile()) throw new Error()
@@ -55,6 +64,24 @@ export async function snapshotCandidate(candidateDir, options = {}) {
55
64
  throw new Error(`Candidate is missing required file: ${required}`)
56
65
  }
57
66
  }
67
+ const files = await walk(root)
68
+ if (!files.some(item => LOCKFILES.includes(item.relative))) {
69
+ throw new Error(`Candidate requires a JavaScript lockfile: ${LOCKFILES.join(', ')}`)
70
+ }
71
+ const credentialPaths = files
72
+ .map(item => item.relative)
73
+ .filter((relative) => {
74
+ const name = path.basename(relative).toLowerCase()
75
+ return name.startsWith('.env') || CREDENTIAL_FILES.has(name)
76
+ })
77
+ if (credentialPaths.length > 0) {
78
+ throw new Error(`Candidate contains credential-bearing files: ${credentialPaths.join(', ')}; inject credentials at runtime instead`)
79
+ }
80
+ }
81
+
82
+ export async function snapshotCandidate(candidateDir, options = {}) {
83
+ const root = path.resolve(candidateDir)
84
+ await validateCandidateContract(root)
58
85
  let packageJson
59
86
  try {
60
87
  packageJson = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'))