forge-workflow 0.1.0-beta.5 → 0.1.0-beta.6

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.
Files changed (128) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +36 -0
  3. package/CLAUDE.md +0 -12
  4. package/CODING_STANDARDS.md +72 -0
  5. package/bin/forge.js +12 -1
  6. package/docs/guides/MIGRATION.md +3 -3
  7. package/docs/reference/FORGE_KERNEL_STORAGE_MODEL.md +4 -0
  8. package/docs/reference/INSTALL.md +4 -0
  9. package/docs/reference/LEGACY_CLAIM_REPAIR.md +112 -0
  10. package/docs/reference/RELEASE.md +4 -4
  11. package/docs/reference/github-accounts.md +134 -0
  12. package/docs/reference/shepherd.md +63 -13
  13. package/lib/adapters/pr-state-adapter.js +15 -2
  14. package/lib/base-remote.js +138 -0
  15. package/lib/beta5-compatibility-evidence.js +1093 -0
  16. package/lib/bun-lockfile-proof.js +413 -0
  17. package/lib/bun-workflow-pins.js +461 -0
  18. package/lib/capabilities/index.js +9 -0
  19. package/lib/capabilities/model.js +141 -0
  20. package/lib/capabilities/probes.js +347 -0
  21. package/lib/codex-skills.js +2 -2
  22. package/lib/commands/_manifest.js +1 -0
  23. package/lib/commands/_registry.js +48 -18
  24. package/lib/commands/clean.js +57 -1
  25. package/lib/commands/doctor.js +37 -6
  26. package/lib/commands/gate.js +197 -27
  27. package/lib/commands/github.js +215 -0
  28. package/lib/commands/hooks.js +54 -6
  29. package/lib/commands/memory.js +66 -2
  30. package/lib/commands/merge.js +720 -73
  31. package/lib/commands/plan.js +33 -2
  32. package/lib/commands/pr.js +2 -0
  33. package/lib/commands/preflight.js +10 -2
  34. package/lib/commands/push.js +108 -6
  35. package/lib/commands/recall.js +95 -61
  36. package/lib/commands/release.js +23 -2
  37. package/lib/commands/remember.js +28 -4
  38. package/lib/commands/serve.js +26 -9
  39. package/lib/commands/setup.js +132 -4
  40. package/lib/commands/shepherd.js +578 -72
  41. package/lib/commands/ship.js +15 -69
  42. package/lib/commands/skill.js +8 -0
  43. package/lib/commands/team.js +47 -8
  44. package/lib/commands/test.js +163 -4
  45. package/lib/commands/validate.js +65 -21
  46. package/lib/commands/worktree.js +155 -19
  47. package/lib/fixtures/beta5-corpus/v1/README.md +9 -0
  48. package/lib/fixtures/beta5-corpus/v1/contract/command-contract.json +26 -0
  49. package/lib/fixtures/beta5-corpus/v1/contract/package-contract.json +13 -0
  50. package/lib/fixtures/beta5-corpus/v1/contract/workflow-stage-matrix.json +8 -0
  51. package/lib/fixtures/beta5-corpus/v1/manifest.json +25 -0
  52. package/lib/fixtures/beta5-corpus/v1/state/comments.jsonl +1 -0
  53. package/lib/fixtures/beta5-corpus/v1/state/config.yaml +6 -0
  54. package/lib/fixtures/beta5-corpus/v1/state/dependencies.jsonl +1 -0
  55. package/lib/fixtures/beta5-corpus/v1/state/issues.jsonl +2 -0
  56. package/lib/fixtures/beta5-corpus/v1/state/kernel.sql +20 -0
  57. package/lib/forge-issues.js +78 -0
  58. package/lib/gate-events.js +98 -10
  59. package/lib/github-context.js +308 -0
  60. package/lib/global-flags.js +1 -0
  61. package/lib/hook-renderer.js +29 -1
  62. package/lib/issue-render.js +19 -0
  63. package/lib/kernel/broker.js +723 -31
  64. package/lib/kernel/claim-reconciler.js +238 -0
  65. package/lib/kernel/lease-enforcer.js +9 -4
  66. package/lib/kernel/legacy-claim-repair.js +442 -0
  67. package/lib/kernel/live-claim-projection.js +26 -0
  68. package/lib/kernel/migrations.js +118 -3
  69. package/lib/kernel/readiness-model.js +184 -12
  70. package/lib/kernel/schema.js +49 -1
  71. package/lib/kernel/sqlite-driver.js +3322 -183
  72. package/lib/kernel/taxonomy-validator.js +4 -1
  73. package/lib/kernel/windows-private-acl.js +239 -0
  74. package/lib/memory/hygiene.js +191 -0
  75. package/lib/memory/router.js +94 -27
  76. package/lib/memory/usage-evidence.js +4 -0
  77. package/lib/memory-digest.js +59 -0
  78. package/lib/merge-rules.js +135 -17
  79. package/lib/npm-publish-workflow.js +233 -40
  80. package/lib/package-root.js +2 -0
  81. package/lib/pr-monitor/auto-actions.js +169 -28
  82. package/lib/pr-monitor/differ.js +110 -4
  83. package/lib/pr-monitor/events.js +0 -0
  84. package/lib/pr-monitor/flow-monitor.js +1424 -0
  85. package/lib/pr-monitor/gather.js +251 -44
  86. package/lib/pr-monitor/journal.js +0 -37
  87. package/lib/pr-monitor/monitor.js +117 -10
  88. package/lib/pr-monitor/process-identity.js +117 -0
  89. package/lib/pr-monitor/reconcile-executor.js +1101 -625
  90. package/lib/pr-monitor/reconcile.js +0 -0
  91. package/lib/pr-monitor/render-summary.js +121 -24
  92. package/lib/pr-monitor/review-preflight.js +269 -0
  93. package/lib/pr-monitor/shepherd-lease.js +28 -19
  94. package/lib/pr-monitor/verdict.js +438 -0
  95. package/lib/pr-monitor/watch-lifecycle.js +144 -38
  96. package/lib/pr-monitor/watch-owner.js +1414 -0
  97. package/lib/pr-monitor/watch.js +129 -58
  98. package/lib/pr-shepherd.js +17 -3
  99. package/lib/project-memory.js +145 -3
  100. package/lib/protected-state-authority.js +799 -4
  101. package/lib/protected-state-surfaces.js +181 -3
  102. package/lib/release-readiness.js +2 -3
  103. package/lib/review-adapter.js +65 -0
  104. package/lib/skills-sync.js +65 -32
  105. package/lib/validation/risk-manifest.js +339 -0
  106. package/lib/workflow/enforce-stage.js +44 -0
  107. package/lib/workflow/plan-authority.js +225 -0
  108. package/package.json +8 -4
  109. package/scripts/commitlint.js +13 -15
  110. package/scripts/generate-risk-manifest.js +91 -0
  111. package/scripts/github-context-bridge.sh +10 -0
  112. package/scripts/legacy-claim-repair.js +145 -0
  113. package/scripts/lib/behavioral-eval-runtime.js +3 -2
  114. package/scripts/process-tree.js +14 -2
  115. package/scripts/protected-state-check.js +440 -17
  116. package/scripts/sync-agent-skills.js +333 -34
  117. package/scripts/test-full-suite.js +704 -18
  118. package/scripts/test-profile.js +13 -3
  119. package/scripts/test.js +95 -14
  120. package/skills/coverage.json +1 -0
  121. package/skills/review/SKILL.md +2 -0
  122. package/skills/review/evals/scorecard.json +2 -2
  123. package/skills/setup/SKILL.md +18 -0
  124. package/skills/setup/evals/scorecard.json +3 -3
  125. package/skills/shepherd/SKILL.md +19 -2
  126. package/skills/shepherd/evals/scorecard.json +3 -3
  127. package/skills/validate/SKILL.md +3 -0
  128. package/skills/validate/evals/scorecard.json +1 -1
@@ -4,6 +4,62 @@ const remember = require('./remember');
4
4
  const recall = require('./recall');
5
5
  const insights = require('./insights');
6
6
  const { stripGlobalFlags } = require('../global-flags');
7
+ const projectMemory = require('../project-memory');
8
+ const { MEMORY_REVIEW_ENTRY_LIMIT, reviewMemories, stalenessForMemory } = require('../memory/hygiene');
9
+
10
+ function renderReview(review) {
11
+ const lines = [`Memory hygiene: ${review.findings.length} finding(s), ${review.scanned}/${review.total} scanned.`];
12
+ for (const finding of review.findings) {
13
+ const detail = finding.claim ? finding.claim : `${finding.count} equivalent records`;
14
+ lines.push(`${finding.review_id} ${finding.kind} ${detail}`);
15
+ }
16
+ if (!review.usage.available) lines.push('Usage staleness: unavailable; no demotion applied.');
17
+ else if (review.usage.demoted > 0) lines.push(`Usage staleness: ${review.usage.demoted} memory record(s) demoted after 90 days.`);
18
+ if (review.truncated) lines.push('Results truncated by the bounded review limits.');
19
+ return lines.join('\n');
20
+ }
21
+
22
+ async function reviewHandler(args, flags, projectRoot, opts = {}) {
23
+ const recentMemories = opts.recentMemories || projectMemory.recent;
24
+ const countMemories = opts.countMemories || projectMemory.count;
25
+ const loadUsageStatus = opts.usageProjections
26
+ ? async (root, keys, options) => {
27
+ try {
28
+ const projections = await opts.usageProjections(root, keys, options);
29
+ return projections instanceof Map
30
+ ? { available: true, projections }
31
+ : { available: false, projections: new Map() };
32
+ } catch {
33
+ return { available: false, projections: new Map() };
34
+ }
35
+ }
36
+ : projectMemory.usageProjectionStatus;
37
+ const store = opts.store || projectMemory.resolveStore(projectRoot, opts);
38
+ const sharedOptions = { ...opts, store };
39
+ const entries = await recentMemories(projectRoot, MEMORY_REVIEW_ENTRY_LIMIT, sharedOptions);
40
+ const total = await countMemories(projectRoot, sharedOptions);
41
+ const usageStatus = await loadUsageStatus(projectRoot, entries.map(entry => entry.key), sharedOptions);
42
+ const usageAvailable = usageStatus?.available === true && usageStatus.projections instanceof Map;
43
+ const projections = usageAvailable ? usageStatus.projections : new Map();
44
+ const now = typeof opts.now === 'string' ? opts.now : new Date().toISOString();
45
+ const usageFindings = usageAvailable ? entries.map(entry => {
46
+ if (typeof entry?.key !== 'string' || typeof entry.timestamp !== 'string') return null;
47
+ try {
48
+ const status = stalenessForMemory({ created_at: entry.timestamp }, projections.get(entry.key) || null, { now });
49
+ return status.demote ? { memory_id: projectMemory.memoryUsageIdentity(entry.key), ...status } : null;
50
+ } catch {
51
+ return null;
52
+ }
53
+ }).filter(Boolean).map(({ age_days: _ageDays, ...finding }) => finding) : [];
54
+ const review = {
55
+ ...reviewMemories(entries, { total }),
56
+ usage: { available: usageAvailable, demoted: usageFindings.length, findings: usageFindings },
57
+ };
58
+ return {
59
+ success: true,
60
+ output: args.includes('--json') || flags.json ? JSON.stringify(review, null, 2) : renderReview(review),
61
+ };
62
+ }
7
63
 
8
64
  // One memorable surface over the EXISTING memory commands (kernel issue 25362344): every
9
65
  // subcommand delegates to the standalone remember/recall/insights handlers — the same
@@ -29,9 +85,17 @@ const SUBCOMMANDS = {
29
85
  handler: insights.handler,
30
86
  summary: 'Detect recurring evidence patterns and suggest follow-ups (= forge insights)',
31
87
  },
88
+ review: {
89
+ handler: reviewHandler,
90
+ summary: 'Report bounded duplicate and explicit-contradiction findings with stable review ids',
91
+ },
92
+ doctor: {
93
+ handler: reviewHandler,
94
+ summary: 'Alias for memory review',
95
+ },
32
96
  };
33
97
 
34
- const usage = 'Usage: forge memory <add|recall|search|insights> [args]';
98
+ const usage = 'Usage: forge memory <add|recall|search|insights|review|doctor> [args]';
35
99
 
36
100
  function renderHelp() {
37
101
  const width = Math.max(...Object.keys(SUBCOMMANDS).map(name => name.length));
@@ -75,7 +139,7 @@ async function handler(args, flags, projectRoot, opts) {
75
139
  module.exports = {
76
140
  name: 'memory',
77
141
  description:
78
- 'Unified memory surface: forge memory add|recall|search|insights (wraps remember/recall/insights)',
142
+ 'Unified memory surface: add, recall, search, insights, and bounded hygiene review',
79
143
  usage,
80
144
  handler,
81
145
  };