@codacy/verity-cli 0.33.3-experimental.9d77663 → 0.33.3-experimental.aea5331

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 (2) hide show
  1. package/bin/verity.js +26 -17
  2. package/package.json +1 -1
package/bin/verity.js CHANGED
@@ -27021,7 +27021,7 @@ function channelSilence(input) {
27021
27021
  // src/lib/cli-version.ts
27022
27022
  function cliVersion() {
27023
27023
  try {
27024
- return true ? "0.33.3-experimental.9d77663" : "dev";
27024
+ return true ? "0.33.3-experimental.aea5331" : "dev";
27025
27025
  } catch {
27026
27026
  return "dev";
27027
27027
  }
@@ -33579,9 +33579,11 @@ function basisOf(source2, files) {
33579
33579
  }
33580
33580
  return { ok: false, why: `line ${n} does not contain "${quoted.slice(0, 60)}"` };
33581
33581
  }
33582
- var NEEDS_FAILURE = /(?<!\beven )\b(?:after|when|if|once|on)\b[^,.;:]{0,60}?\b(?:fails?|failed|errors?|throws?|times? out|timed out|rejects?|rejected|is unavailable|is down)\b|\bon (?:an? )?(?:error|failure|timeout)\b|\ba failed\b/;
33583
- var NEEDS_CRASH = /(?<!\beven )\b(?:after|when|if|on)\b[^,.;:]{0,60}?\bcrash/;
33584
- var HAS_FAILURE = /fail|error|throw|timeout|timedout|timesout|reject|exception|unavailable|down/i;
33582
+ var NOT_A_MENTION = "(?<!\\b(?:even|including|also|or) )";
33583
+ var UNTIL_FIRST = "(?:(?!\\bor\\b)[^,.;:]){0,60}?";
33584
+ var NEEDS_FAILURE = new RegExp(`${NOT_A_MENTION}\\b(?:after|when|if|once|on)\\b${UNTIL_FIRST}\\b(?:fails?|failed|errors?|throws?|times? out|timed out|rejects?|rejected|is unavailable|is down)\\b|${NOT_A_MENTION}\\bon (?:an? )?(?:error|failure|timeout)\\b|\\ba failed\\b`);
33585
+ var NEEDS_CRASH = new RegExp(`${NOT_A_MENTION}\\b(?:after|when|if|on)\\b${UNTIL_FIRST}\\bcrash`);
33586
+ var HAS_FAILURE = /fail|error|throw|time[sd]?[\s_-]*out|reject|exception|unavailable|\bdown\b|\bis down/i;
33585
33587
  var HAS_CRASH = /crash|die|kill|abort|restart/i;
33586
33588
  function missingTrigger(desc, trace) {
33587
33589
  const d = desc.toLowerCase();
@@ -34336,7 +34338,7 @@ STEP 3 \u2014 Properties: 2 to 4, in this order of priority:
34336
34338
  A counterexample must run the real function: a trace made only of environment moves (another writer, a clock) says nothing about this code. A promise about the END result (nothing lost, nothing charged twice, totals add up) is checked on states where every invocation has finished or crashed \u2014 guard the \`inv\` with the program counters, as exemplar 2's second property does; a violation that exists only while work is still pending is not a bug.
34337
34339
  A property is about an OUTCOME someone would call a bug \u2014 money, stock or records wrong, access granted, work lost or done twice, a job stuck forever \u2014 never about the mechanism's internals (a key's format, two timestamps being distinct, a lease's exact boundary tick). A comment that says HOW the code works ("make each attempt's key unique") is not the promise; the promise is what that mechanism is for.
34338
34340
  A comment that states a SAFE design choice ("a spent token presented again ends every session", "consumers dedupe, so publishing twice is harmless") is the design: never claim the opposite. A comment never makes an UNSAFE outcome safe: granting access on an error, losing or double-counting money, stock or records is a bug whatever the comment says ("don't block people when the permission service is flaky" describes a fail-open bug).
34339
- Every property says what it rests on, in \`source\`: either \`L<n>: <words copied from that line>\` \u2014 a line of the numbered source above (a comment, docstring, check, error message or name) that states the promise \u2014 or one rule: \`rule:conservation\` (money, stock or counts add up), \`rule:once\` (no double effect, only where the code dedups, as above), \`rule:no-lost-update\`, \`rule:fail-closed\` (an error never grants access or reports success), \`rule:progress\` (nothing stuck forever). A property that neither a line nor one of these rules supports is not a promise: do not state it. A property whose \`source\` is empty, or cites words its line does not contain, sends the model back.
34341
+ Every property says what it rests on, in \`source\`: either \`L<n>: <words copied from that line>\` \u2014 a line of the numbered source above (a comment, docstring, check, error message or name) that states the promise \u2014 or one rule: \`rule:conservation\` (money, stock or counts add up), \`rule:once\` (no double effect: where the code dedups, or where the same input can arrive twice \u2014 a webhook or queue message redelivered, a client or job retry \u2014 even when the code has no dedup at all; a missing dedup is the bug, not a reason to drop the property), \`rule:no-lost-update\`, \`rule:fail-closed\` (an error never grants access or reports success), \`rule:progress\` (nothing stuck forever). A property that neither a line nor one of these rules supports is not a promise: do not state it. A property whose \`source\` is empty, or cites words its line does not contain, sends the model back.
34340
34342
  When the input lists where the function is called, a caller's guard bounds its inputs: never build a counterexample from an input no caller can pass (an empty list a caller refuses).
34341
34343
  Property ids name the promise in snake_case (refund_total_within_capture) \u2014 never P1. \`desc\` states the promise in the code's own terms and names the move the trace needs ("two concurrent calls \u2026", "after the charge succeeded and the call timed out \u2026").
34342
34344
  A PURE computation (no effect sites) is checked with \`Verity.checkData\` on small concrete inputs, including the edge cases (exemplar 3).
@@ -36306,9 +36308,11 @@ async function runFormalPhase(input) {
36306
36308
  progress.usage = usage;
36307
36309
  progress.step = "select";
36308
36310
  let candidates2;
36311
+ const grounding = { sentBack: 0, dropped: [], triggerMissing: [] };
36309
36312
  const done = (partial) => ({
36310
36313
  findings: [],
36311
36314
  ...candidates2 ? { candidates: candidates2 } : {},
36315
+ ...grounding.sentBack || grounding.dropped.length || grounding.triggerMissing.length ? { grounding } : {},
36312
36316
  ...partial,
36313
36317
  usage,
36314
36318
  durationMs: deps.now() - started
@@ -36552,11 +36556,13 @@ async function runFormalPhase(input) {
36552
36556
  });
36553
36557
  if (bad.length > 0) {
36554
36558
  if (round < 2 && timeLeft() >= GENERATE_RESERVE_MS / 2) {
36559
+ grounding.sentBack++;
36555
36560
  previous = { source: gen.source, error: ungroundedMessage(bad.join("; ")) };
36556
36561
  report = null;
36557
36562
  continue;
36558
36563
  }
36559
36564
  const grounded = report.properties.filter((p) => basisOf(p.source, files2).ok);
36565
+ grounding.dropped = report.properties.filter((p) => !grounded.includes(p)).map((p) => p.id);
36560
36566
  if (grounded.length === 0) return done({ status: "skipped", skip: "model-did-not-elaborate", detail: `no property says what it rests on: ${bad.join("; ").slice(0, 240)}`, target, model: { name: gen.name, file: rel, rounds: round } });
36561
36567
  report = { ...report, properties: grounded };
36562
36568
  }
@@ -36578,11 +36584,8 @@ async function runFormalPhase(input) {
36578
36584
  } catch {
36579
36585
  }
36580
36586
  const isCrash = (p) => isCrashTrace(p.trace ?? []) || /\bcrash/i.test(p.desc);
36581
- const skipsTrigger = new Map(report.properties.filter((p) => p.result === "counterexample").flatMap((p) => {
36582
- const missing = missingTrigger(p.desc, p.trace ?? []);
36583
- return missing ? [[p.id, missing]] : [];
36584
- }));
36585
- const cexes = report.properties.filter((p) => p.result === "counterexample" && !skipsTrigger.has(p.id)).map((p, i2) => ({ p, i: i2 })).sort((a, b) => Number(isCrash(a.p)) - Number(isCrash(b.p)) || a.i - b.i).map(({ p }) => p);
36587
+ grounding.triggerMissing = report.properties.filter((p) => p.result === "counterexample" && missingTrigger(p.desc, p.trace ?? [])).map((p) => p.id);
36588
+ const cexes = report.properties.filter((p) => p.result === "counterexample").map((p, i2) => ({ p, i: i2 })).sort((a, b) => Number(isCrash(a.p)) - Number(isCrash(b.p)) || a.i - b.i).map(({ p }) => p);
36586
36589
  const baseOf = (p) => ({ property: p.id, desc: p.desc, kind: p.kind, trace: p.trace ?? [], file: top.file, symbol: top.ai.symbol });
36587
36590
  const maxReplays = input.maxReplays ?? MAX_REPLAYS;
36588
36591
  let skipWhy = null;
@@ -36617,10 +36620,6 @@ async function runFormalPhase(input) {
36617
36620
  }).finally(settle);
36618
36621
  }
36619
36622
  });
36620
- for (const p of report.properties) {
36621
- const missing = skipsTrigger.get(p.id);
36622
- if (missing) findings.push({ ...baseOf(p), verdict: "model-only", reason: `not replayed: the property needs ${missing} first, and the counterexample has none` });
36623
- }
36624
36623
  const replayedIds = new Set(toReplay.map((p) => p.id));
36625
36624
  for (const p of cexes) {
36626
36625
  const r = byId.get(p.id);
@@ -37376,6 +37375,16 @@ async function runGuard(opts, globals) {
37376
37375
  rounds: formalOutcome.model?.rounds ?? null,
37377
37376
  properties: formalOutcome.properties?.map((p) => `${p.id}:${p.result}`) ?? [],
37378
37377
  findings: formalOutcome.findings.map((f) => `${f.property}:${f.verdict}`),
37378
+ // Decision 81: what each property rests on (a rule, or "line"), what was
37379
+ // sent back or dropped as ungrounded, and which counterexamples lack their
37380
+ // property's trigger (shadow). Ids and rule names only, never code.
37381
+ grounding: {
37382
+ sources: (formalOutcome.properties ?? []).map((p) => /^rule:[a-z-]+$/.test(p.source) ? p.source : p.source ? "line" : "none"),
37383
+ sent_back: formalOutcome.grounding?.sentBack ?? 0,
37384
+ dropped: formalOutcome.grounding?.dropped ?? [],
37385
+ // Shadow: counterexamples whose trace lacks the move their property names. Replayed anyway.
37386
+ trigger_missing: formalOutcome.grounding?.triggerMissing ?? []
37387
+ },
37379
37388
  input_tokens: formalOutcome.usage.inputTokens,
37380
37389
  output_tokens: formalOutcome.usage.outputTokens,
37381
37390
  cost_usd: formalOutcome.usage.costUsd,
@@ -39768,7 +39777,7 @@ function registerInitCommand(program2) {
39768
39777
  ...telemetryChoice ? { telemetry: telemetryChoice } : {},
39769
39778
  init: {
39770
39779
  completed_at: (/* @__PURE__ */ new Date()).toISOString(),
39771
- cli_version: true ? "0.33.3-experimental.9d77663" : "dev"
39780
+ cli_version: true ? "0.33.3-experimental.aea5331" : "dev"
39772
39781
  }
39773
39782
  });
39774
39783
  } catch (err2) {
@@ -41241,8 +41250,8 @@ function registerLeanCommand(program2) {
41241
41250
  }
41242
41251
 
41243
41252
  // src/cli.ts
41244
- program.name("verity").description("CLI for Verity quality gate service").version("0.33.3-experimental.9d77663").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
41245
- installStderrLog(actionCommand.name(), process.argv.slice(2), "0.33.3-experimental.9d77663");
41253
+ program.name("verity").description("CLI for Verity quality gate service").version("0.33.3-experimental.aea5331").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
41254
+ installStderrLog(actionCommand.name(), process.argv.slice(2), "0.33.3-experimental.aea5331");
41246
41255
  setUserNamedServiceUrl(program.opts().serviceUrl);
41247
41256
  try {
41248
41257
  await foldLegacyLocalCredential();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/verity-cli",
3
- "version": "0.33.3-experimental.9d77663",
3
+ "version": "0.33.3-experimental.aea5331",
4
4
  "description": "CLI for Verity quality gate service",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://verity.md",