@besales/ops-framework 0.1.21 → 0.1.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.22
4
+
5
+ - Added a compact `standard_plus` LLM context mode between `standard` and `strict` so near-cap Check/Verify runs avoid full strict context when compact evidence is sufficient.
6
+ - Refreshed `task-manifest.json` after successful Check and cache hits so `lastCheckResult` reflects the final current verdict instead of stale `return_to_plan` results.
7
+
3
8
  ## 0.1.21
4
9
 
5
10
  - Added `verify-timeline.json` telemetry for Verify runs, including deterministic blocks, LLM input sizing, context-mode escalation, provider duration/failure and final verdict.
@@ -8,10 +8,11 @@ import {
8
8
  renderRelevantPlaybooks,
9
9
  } from './check-context-utils.mjs';
10
10
 
11
- export const LLM_CONTEXT_MODES = ['fast', 'standard', 'strict'];
11
+ export const LLM_CONTEXT_MODES = ['fast', 'standard', 'standard_plus', 'strict'];
12
12
  export const LLM_CONTEXT_CAPS = {
13
13
  fast: 8000,
14
14
  standard: 20000,
15
+ standard_plus: 26000,
15
16
  strict: 45000,
16
17
  };
17
18
 
@@ -20,6 +21,7 @@ const PACK_CAP_SAFETY_MULTIPLIER = 1.15;
20
21
  const MEMORY_MAX_CHARS = {
21
22
  fast: 3000,
22
23
  standard: 3500,
24
+ standard_plus: 4500,
23
25
  strict: Infinity,
24
26
  };
25
27
 
@@ -163,6 +165,9 @@ export function nextLlmContextMode(mode) {
163
165
  return 'standard';
164
166
  }
165
167
  if (mode === 'standard') {
168
+ return 'standard_plus';
169
+ }
170
+ if (mode === 'standard_plus') {
166
171
  return 'strict';
167
172
  }
168
173
  return null;
@@ -215,8 +220,8 @@ export function buildCheckerLlmInputPack({
215
220
  fullContextAvailableViaStrict: selectedMode !== 'strict',
216
221
  contextInsufficientFallback: selectedMode === 'strict' ? 'stop_and_report' : `rerun_${nextLlmContextMode(selectedMode)}`,
217
222
  },
218
- checkEvidence: compactGeneratedMarkdown('check-evidence.md', checkEvidence, selectedMode, { fast: 2800, standard: 4000 }),
219
- checkerContextPack: compactGeneratedMarkdown('checker-context-pack.md', checkerContextPack, selectedMode, { fast: 3300, standard: 4600 }),
223
+ checkEvidence: compactGeneratedMarkdown('check-evidence.md', checkEvidence, selectedMode, { fast: 2800, standard: 4000, standard_plus: 5600 }),
224
+ checkerContextPack: compactGeneratedMarkdown('checker-context-pack.md', checkerContextPack, selectedMode, { fast: 3300, standard: 4600, standard_plus: 6200 }),
220
225
  relevantPlaybooks: selectedMode === 'strict'
221
226
  ? renderRelevantPlaybooks(readRelevantPlaybooks(checkContext.riskTriggers || []), { mode: 'strict' })
222
227
  : renderRelevantPlaybooks(readRelevantPlaybooks(checkContext.riskTriggers || []), { mode: 'compact' }),
@@ -521,7 +526,7 @@ function compactExecutionLedger(ledger, mode) {
521
526
  }
522
527
  const changedFiles = Array.isArray(ledger.git?.changedFiles) ? ledger.git.changedFiles : [];
523
528
  const unrelatedDirtyFiles = Array.isArray(ledger.git?.unrelatedDirtyFiles) ? ledger.git.unrelatedDirtyFiles : [];
524
- const limit = mode === 'fast' ? 40 : mode === 'standard' ? 90 : 160;
529
+ const limit = mode === 'fast' ? 40 : mode === 'standard' ? 90 : mode === 'standard_plus' ? 120 : 160;
525
530
  const compact = {
526
531
  schemaVersion: ledger.schemaVersion,
527
532
  taskId: ledger.taskId,
@@ -580,7 +585,11 @@ function compactGeneratedMarkdown(fileName, content, mode, limits) {
580
585
  if (mode === 'strict' || !content) {
581
586
  return content;
582
587
  }
583
- const limit = mode === 'fast' ? limits.fast : limits.standard;
588
+ const limit = mode === 'fast'
589
+ ? limits.fast
590
+ : mode === 'standard_plus'
591
+ ? limits.standard_plus || Math.ceil(limits.standard * 1.35)
592
+ : limits.standard;
584
593
  return markCompacted(fileName, content, truncateMiddle(content, limit));
585
594
  }
586
595
 
@@ -707,7 +716,13 @@ function isProtectedSection(value) {
707
716
  }
708
717
 
709
718
  function charLimitForMode(mode, fastChars, standardChars) {
710
- return mode === 'fast' ? fastChars : standardChars;
719
+ if (mode === 'fast') {
720
+ return fastChars;
721
+ }
722
+ if (mode === 'standard_plus') {
723
+ return Math.ceil(standardChars * 1.25);
724
+ }
725
+ return standardChars;
711
726
  }
712
727
 
713
728
  function readOptionalJson(taskDir, fileName) {
@@ -84,12 +84,40 @@ describe('llm input pack utilities', () => {
84
84
  });
85
85
 
86
86
  it('builds bounded fallback mode sequence for context insufficient results', () => {
87
- expect(buildContextModeSequence('fast')).toEqual(['fast', 'standard', 'strict']);
88
- expect(buildContextModeSequence('standard')).toEqual(['standard', 'strict']);
87
+ expect(buildContextModeSequence('fast')).toEqual(['fast', 'standard', 'standard_plus', 'strict']);
88
+ expect(buildContextModeSequence('standard')).toEqual(['standard', 'standard_plus', 'strict']);
89
+ expect(buildContextModeSequence('standard_plus')).toEqual(['standard_plus', 'strict']);
89
90
  expect(buildContextModeSequence('strict')).toEqual(['strict']);
90
91
  expect(isContextInsufficientResult({ verdict: 'context_insufficient' })).toBe(true);
91
92
  });
92
93
 
94
+ it('provides a compact standard_plus check mode before strict', () => {
95
+ const taskDir = createTask();
96
+ const pack = buildCheckerLlmInputPack({
97
+ taskDir,
98
+ taskId: 'TASK-999-token-pack',
99
+ checkerPromptSha: 'sha256:test',
100
+ cacheKey: { test: true },
101
+ checkContext: {
102
+ planSha: 'sha256:plan',
103
+ memorySha: 'sha256:memory',
104
+ riskProfile: 'high',
105
+ riskTriggers: ['source-sync-provider', 'prisma-schema'],
106
+ },
107
+ checkEvidence: '# Evidence\n\nok\n'.repeat(900),
108
+ checkerContextPack: '# Checker Context Pack\n\nok\n'.repeat(900),
109
+ taskManifest: '{}',
110
+ projectMemory: [],
111
+ mode: 'standard_plus',
112
+ });
113
+
114
+ expect(pack.meta.mode).toBe('standard_plus');
115
+ expect(pack.meta.capTokens).toBe(26000);
116
+ expect(pack.input.llmInputPolicy.contextInsufficientFallback).toBe('rerun_strict');
117
+ expect(pack.input.taskArtifacts['plan.md']).toContain('<!-- compacted:plan.md');
118
+ expect(pack.meta.compactedArtifacts).toContain('plan.md');
119
+ });
120
+
93
121
  it('preserves protected verification sections when compacting long plans', () => {
94
122
  const taskDir = createTask();
95
123
  const longPlan = [
package/bin/run-check.mjs CHANGED
@@ -226,6 +226,7 @@ async function runMain() {
226
226
  rerunCount,
227
227
  timing: buildTiming(runStartedAt),
228
228
  });
229
+ refreshTaskManifestAfterCheck(taskDir);
229
230
  console.log(`Checker cache hit for ${taskId}: ${cacheKeySha}`);
230
231
  return;
231
232
  }
@@ -329,12 +330,22 @@ async function runMain() {
329
330
  rerunCount,
330
331
  timing: buildTiming(runStartedAt),
331
332
  });
333
+ refreshTaskManifestAfterCheck(taskDir);
332
334
  runValidator(taskArg);
333
335
  console.log(`Checker run completed for ${taskId}: ${providerOutput.checkResultJson?.verdict}`);
334
336
  console.log(`- finalLlmInputMode: ${promptPayload.pack.meta.mode}`);
335
337
  console.log(`- finalEstimatedInputTokens: ${promptPayload.pack.meta.estimatedTokens}`);
336
338
  }
337
339
 
340
+ function refreshTaskManifestAfterCheck(taskDir) {
341
+ const manifest = buildTaskManifest({ taskDir });
342
+ writeTaskManifest(taskDir, manifest);
343
+ appendCheckTimeline(taskDir, {
344
+ event: 'task_manifest_refreshed_after_check',
345
+ lastCheckResult: manifest.lastCheckResult,
346
+ });
347
+ }
348
+
338
349
  function appendCheckTimeline(taskDir, event) {
339
350
  const timelinePath = path.join(taskDir, 'check-timeline.json');
340
351
  let existing = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@besales/ops-framework",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "ops-agent": "bin/ops-agent.mjs"