@agentskit/doc-bridge 1.10.1 → 1.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 25f16f3: Say when a committed index could not have come from a clean checkout.
8
+
9
+ A scan walks what is on disk and has no reason to consult `.gitignore`, so a generated module or
10
+ document silently joins the corpus on a machine that has built and silently leaves it on one that
11
+ has not. That is harmless while the index is rebuilt on every run. It is a defect the moment the
12
+ index is committed so a gate can verify it — which is the setup `index-freshness` exists for: two
13
+ checkouts of the same commit then produce different artifacts, the gate reports staleness that
14
+ nothing caused, and regenerating cannot fix it because the next machine disagrees in the other
15
+ direction.
16
+
17
+ Dogfooding found this the expensive way. On a 25-package monorepo the freshness gate passed locally
18
+ and failed in CI, twice, because `pnpm lint` had generated one `.ts` file into the corpus before the
19
+ index was written; CI lints a narrower scope and never had the file. Diagnosing it took reading two
20
+ CI logs and diffing file inventories. Git already knew the answer.
21
+
22
+ `ak-docs index` now names those paths as it writes, and `ak-docs doctor` raises an
23
+ `index-not-reproducible` warning, each with the ignore rule that matched — for example
24
+ `apps/docs-next/lib/ask-context.ts (apps/docs-next/.gitignore:13:lib/ask-context.ts)` — so the fix
25
+ is one lookup away: add the path to `safety.exclude`.
26
+
27
+ Both are unconditional and neither changes an exit code or the doctor's score. Enforcement is the
28
+ new `index-reproducible` gate, which is in no preset and has to be requested with
29
+ `gates.include: ['index-reproducible']`, because turning it on for every consumer would fail gates
30
+ that pass for good reasons.
31
+
32
+ The check reports success rather than failure when the index is not committed or the project is not
33
+ a Git checkout, since there is nothing to reproduce in either case, and it does not flag a file that
34
+ is both tracked and matched by an ignore rule — being committed is the point.
35
+
3
36
  ## 1.10.1
4
37
 
5
38
  ### Patch Changes
package/action.yml CHANGED
@@ -20,7 +20,7 @@ inputs:
20
20
  package-version:
21
21
  description: Exact @agentskit/doc-bridge npm version (kept in sync with this Action release)
22
22
  required: false
23
- default: '1.10.1'
23
+ default: '1.11.0'
24
24
 
25
25
  runs:
26
26
  using: composite
@@ -430,6 +430,7 @@ var GatesConfigSchema = z.object({
430
430
  include: z.array(
431
431
  z.enum([
432
432
  "index-freshness",
433
+ "index-reproducible",
433
434
  "human-guide-links",
434
435
  "link-rot",
435
436
  "okf-type",
@@ -442,6 +443,7 @@ var GatesConfigSchema = z.object({
442
443
  exclude: z.array(
443
444
  z.enum([
444
445
  "index-freshness",
446
+ "index-reproducible",
445
447
  "human-guide-links",
446
448
  "link-rot",
447
449
  "okf-type",
@@ -4060,7 +4062,7 @@ var buildLookup = (config, packages, corpus, indexOutFile, humanDocs = {}, root
4060
4062
  };
4061
4063
 
4062
4064
  // src/version.ts
4063
- var PACKAGE_VERSION = "1.10.1";
4065
+ var PACKAGE_VERSION = "1.11.0";
4064
4066
 
4065
4067
  // src/index-builder/capabilities.ts
4066
4068
  var renderCapabilitiesJson = (config, index, paths) => {
@@ -8025,6 +8027,50 @@ var loadFreshDocBridgeIndex = (root, config) => {
8025
8027
  return index;
8026
8028
  };
8027
8029
 
8030
+ // src/discovery/reproducibility.ts
8031
+ import { execFileSync as execFileSync2 } from "child_process";
8032
+ var NOT_CHECKED = (skipped) => ({
8033
+ checked: false,
8034
+ skipped,
8035
+ ignored: []
8036
+ });
8037
+ var git = (root, args, options = {}) => {
8038
+ try {
8039
+ return execFileSync2("git", args, {
8040
+ cwd: root,
8041
+ encoding: "utf8",
8042
+ stdio: ["pipe", "pipe", "ignore"],
8043
+ maxBuffer: 64 * 1024 * 1024,
8044
+ ...options.input === void 0 ? {} : { input: options.input }
8045
+ });
8046
+ } catch (error) {
8047
+ const status = error.status;
8048
+ if (options.allowExit1 && status === 1) return error.stdout ?? "";
8049
+ return void 0;
8050
+ }
8051
+ };
8052
+ var checkIndexReproducibility = (root, indexPath, paths) => {
8053
+ if (git(root, ["rev-parse", "--is-inside-work-tree"]) === void 0) return NOT_CHECKED("no-git");
8054
+ if (git(root, ["ls-files", "--error-unmatch", "--", indexPath]) === void 0) {
8055
+ return NOT_CHECKED("index-untracked");
8056
+ }
8057
+ if (paths.length === 0) return { checked: true, ignored: [] };
8058
+ const unique3 = [...new Set(paths)].sort();
8059
+ const output = git(root, ["check-ignore", "--verbose", "-z", "--stdin"], {
8060
+ input: `${unique3.join("\0")}\0`,
8061
+ allowExit1: true
8062
+ });
8063
+ if (output === void 0) return NOT_CHECKED("no-git");
8064
+ const fields = output.split("\0");
8065
+ const ignored = [];
8066
+ for (let index = 0; index + 3 < fields.length; index += 4) {
8067
+ const [source, line, pattern, path] = [fields[index], fields[index + 1], fields[index + 2], fields[index + 3]];
8068
+ if (!path) continue;
8069
+ ignored.push({ path, rule: `${source ?? "?"}:${line ?? "?"}:${pattern ?? "?"}` });
8070
+ }
8071
+ return { checked: true, ignored: ignored.sort((left, right) => left.path.localeCompare(right.path)) };
8072
+ };
8073
+
8028
8074
  // src/gates/run-gates.ts
8029
8075
  var RESERVED_GATE_IDS = /* @__PURE__ */ new Set(["link-rot", "routing-currency", "bootstrap-size"]);
8030
8076
  var runGate = (root, config, id) => {
@@ -8042,6 +8088,38 @@ var runGate = (root, config, id) => {
8042
8088
  if (id === "human-guide-links") return runHumanGuideLinksGate(root, config);
8043
8089
  if (id === "okf-type") return runOkfTypeGate(root, config);
8044
8090
  if (id === "docs-style") return runDocsStyleGate(root, config);
8091
+ if (id === "index-reproducible") {
8092
+ let index;
8093
+ try {
8094
+ index = loadDocBridgeIndex(root, config);
8095
+ } catch (error) {
8096
+ if (error instanceof IndexNotFoundError) return { id, ok: false, message: error.message };
8097
+ throw error;
8098
+ }
8099
+ const result = checkIndexReproducibility(
8100
+ root,
8101
+ config.index?.outFile ?? ".doc-bridge/index.json",
8102
+ index.knowledge.map((entry) => entry.path)
8103
+ );
8104
+ if (!result.checked) {
8105
+ return {
8106
+ id,
8107
+ ok: true,
8108
+ message: result.skipped === "index-untracked" ? "Index is not committed, so nothing has to reproduce it" : "Not a Git checkout; reproducibility was not checked"
8109
+ };
8110
+ }
8111
+ if (result.ignored.length === 0) {
8112
+ return { id, ok: true, message: "Every indexed path is committed" };
8113
+ }
8114
+ const sample = result.ignored.slice(0, 5).map((entry) => `${entry.path} (${entry.rule})`);
8115
+ return {
8116
+ id,
8117
+ ok: false,
8118
+ message: `${result.ignored.length} indexed path(s) are ignored by Git, so a clean checkout builds a different index. Add them to safety.exclude.`,
8119
+ expected: "every indexed path is committed",
8120
+ actual: sample.join(", ")
8121
+ };
8122
+ }
8045
8123
  if (id !== "index-freshness") throw new Error(`Unsupported gate "${id}"`);
8046
8124
  let current;
8047
8125
  try {
@@ -9072,7 +9150,7 @@ var draftMemoryPromotion = (classifications) => {
9072
9150
  };
9073
9151
 
9074
9152
  // src/memory/github-pr.ts
9075
- import { execFileSync as execFileSync2, spawnSync } from "child_process";
9153
+ import { execFileSync as execFileSync3, spawnSync } from "child_process";
9076
9154
  import { existsSync as existsSync15, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
9077
9155
  import { join as join15 } from "path";
9078
9156
  var run = (cmd, args, cwd) => {
@@ -9199,7 +9277,7 @@ ${auth.out}`
9199
9277
  ];
9200
9278
  let prUrl = "";
9201
9279
  try {
9202
- prUrl = execFileSync2("gh", prArgs, { cwd: root, encoding: "utf8" }).trim();
9280
+ prUrl = execFileSync3("gh", prArgs, { cwd: root, encoding: "utf8" }).trim();
9203
9281
  } catch (error) {
9204
9282
  const message = error instanceof Error ? error.message : String(error);
9205
9283
  return {
@@ -10170,6 +10248,16 @@ var buildIssues = (coverage) => {
10170
10248
  action: "ak-docs index"
10171
10249
  });
10172
10250
  }
10251
+ const { ignored } = coverage.reproducibility;
10252
+ if (ignored.length > 0) {
10253
+ const sample = ignored.slice(0, 5).map((entry) => `${entry.path} (${entry.rule})`);
10254
+ issues.push({
10255
+ severity: "warn",
10256
+ code: "index-not-reproducible",
10257
+ message: `${ignored.length} indexed path(s) are ignored by Git, so a clean checkout builds a different index: ${sample.join(", ")}${ignored.length > sample.length ? `, and ${ignored.length - sample.length} more` : ""}.`,
10258
+ action: "edit doc-bridge.config.json # add the generated paths to safety.exclude"
10259
+ });
10260
+ }
10173
10261
  for (const id of coverage.packages.missingAgentDoc) {
10174
10262
  issues.push({
10175
10263
  severity: "warn",
@@ -10307,7 +10395,12 @@ var runDoctor = (root, config) => {
10307
10395
  message: freshnessMessage,
10308
10396
  hasIndex
10309
10397
  },
10310
- gates
10398
+ gates,
10399
+ reproducibility: checkIndexReproducibility(
10400
+ root,
10401
+ config.index?.outFile ?? ".doc-bridge/index.json",
10402
+ index.knowledge.map((entry) => entry.path)
10403
+ )
10311
10404
  };
10312
10405
  const issues = buildIssues(coverage);
10313
10406
  const score = computeScore(coverage);
@@ -16983,7 +17076,7 @@ var loadProject = (configPath) => {
16983
17076
  const root = projectRootFromConfigPath(path, config.project?.root);
16984
17077
  return { config, configPath: path, root };
16985
17078
  };
16986
- var indexDiagnostics = (config, result) => {
17079
+ var indexDiagnostics = (root, config, result) => {
16987
17080
  const diagnostics = [];
16988
17081
  const onlyDoc = result.index.knowledge.length === 1 ? result.index.knowledge[0] : void 0;
16989
17082
  if (onlyDoc?.path === config.corpus.agent.index) {
@@ -16998,6 +17091,18 @@ var indexDiagnostics = (config, result) => {
16998
17091
  "No ownership handoffs yet. Add routing.options.ownership, package frontmatter (package + editRoot), or a monorepo plugin."
16999
17092
  );
17000
17093
  }
17094
+ const reproducibility = checkIndexReproducibility(
17095
+ root,
17096
+ config.index?.outFile ?? ".doc-bridge/index.json",
17097
+ result.index.knowledge.map((entry) => entry.path)
17098
+ );
17099
+ if (reproducibility.ignored.length > 0) {
17100
+ const sample = reproducibility.ignored.slice(0, 5).map((entry) => `${entry.path} (${entry.rule})`);
17101
+ diagnostics.push(
17102
+ `${reproducibility.ignored.length} indexed path(s) are ignored by Git: ${sample.join(", ")}${reproducibility.ignored.length > sample.length ? `, and ${reproducibility.ignored.length - sample.length} more` : ""}.`,
17103
+ "A clean checkout will not have them, so it builds a different index. Add them to safety.exclude in doc-bridge.config.json."
17104
+ );
17105
+ }
17001
17106
  return diagnostics;
17002
17107
  };
17003
17108
  var diagnosticNextCommands = (config, result) => {
@@ -18125,7 +18230,7 @@ var runCli2 = (argv) => {
18125
18230
  });
18126
18231
  }
18127
18232
  const result = buildDocBridgeIndex({ root, config });
18128
- const diagnostics = indexDiagnostics(config, result);
18233
+ const diagnostics = indexDiagnostics(root, config, result);
18129
18234
  const handoffCount = Object.keys(result.index.handoffs ?? {}).length;
18130
18235
  writeJson2({
18131
18236
  ok: true,