@letsrebase/verify 0.1.0 → 0.1.2

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
@@ -93,7 +93,7 @@ Seven lenses, all built from your logs.
93
93
 
94
94
  Plus a trajectory block (how your behavior shifted across the observed window), three to five representative projects (adaptive: flagships by significance, extra slots only for type diversity or comparable significance), each carrying per-product orchestration counts: sessions per agent CLI (with overlapping vs disjoint activity periods), sub-agent delegations, and headless agent-dispatch commands (to the same tool or another; all lower bounds), and a groundedness check (the prose has to track back to the data; below 60%, submission is blocked).
95
95
 
96
- At submit time everything is re-checked, not trusted: groundedness is recomputed on the file as it is now, the structured numbers are re-derived from your logs (the profile can't claim more sessions or commits than the logs contain), and the intake recomputes groundedness and the structural invariants server-side on what it receives. An incoherent hand-edit of `candidate.json` doesn't survive the trip; the log-level re-derivation runs only on your machine, since your logs never leave it.
96
+ At submit time everything is re-checked, not trusted: groundedness is recomputed on the file as it is now, the structured numbers are re-derived from your logs (the profile can't claim more sessions, commits or code practice counts than the logs contain), and the intake recomputes groundedness and the structural invariants server-side on what it receives. An incoherent hand-edit of `candidate.json` doesn't survive the trip; the log-level re-derivation runs only on your machine, since your logs never leave it.
97
97
 
98
98
  The profile also discloses its own coverage: a `sources` block records which log sources were read, at what capture level (*full* = tamper-evident records the authenticity screen can verify; *structural* = well-formed data without a verification story), and how many sessions each contributed. The window and every count are **lower bounds** of your real activity, logs rotate and old sessions are pruned, so what the tool can still see is never more than what you did. Like the authenticity score, this is a screen, not proof.
99
99
 
@@ -147,6 +147,7 @@ How it is read:
147
147
  - **Failures.** `failure_reproduced_before_fix` only counts failed checks. A failed command that contains a check counts as a failed check, and in a chain such as `npm test && git push` the exit status cannot say which part failed, so the chain counts as its first check. Two runs are the same check when their command words match (the words before the first flag or path, wrappers dropped), so a narrower rerun of the same check (`pytest tests/a.py` after `pytest`) is the same command. Pi, oh-my-pi and Cursor sessions are left out of this practice, because their logs cannot show a failure reliably. A session whose adapter cannot give a field for a practice is left out of that practice rather than counted as not seen.
148
148
  - **Sessions with no time.** A session with no timestamped message cannot be placed in a month, so it is left out of every practice's counts. A practice no session could show (M is 0) is left out of the profile.
149
149
  - **Counts only.** Only the counts leave your machine, never a command, a path or a file name.
150
+ - **At submit.** The seven code practices are counted again from your logs, in the timezone the profile recorded, and a profile that claims more than that count is blocked, like the other numbers. The four model practices cannot be counted again, so only their shape is checked.
150
151
 
151
152
  The full rules are in `share/practices.json`, generated from `src/practices-rules.mjs`: every command pattern, the path patterns, the source extensions, the commit and pull request patterns, and the tool names read as a planning step or an edit.
152
153
 
@@ -60,8 +60,9 @@ import { computeAgenticLiteracy } from "../src/agentic-literacy.mjs";
60
60
  import { computeIntensity } from "../src/intensity.mjs";
61
61
  import { computeDistribution } from "../src/distribution.mjs";
62
62
  import { computeTechUsage, recordedTechUsageTz } from "../src/tech-usage.mjs";
63
- import { computeCodePractices, mergeModelPractices, practicesBlock } from "../src/practices.mjs";
63
+ import { computeCodePractices, mergeModelPractices, practicesBlock, recordedPracticesTz } from "../src/practices.mjs";
64
64
  import { DEFAULT_TZ } from "../src/days.mjs";
65
+ import { invocation } from "../src/invocation.mjs";
65
66
 
66
67
  // Friendly Node floor (package.json `engines` is advisory only when invoked
67
68
  // as `node bin/rebase-verify.mjs`). Imports hoist and evaluate before this line
@@ -126,6 +127,8 @@ try {
126
127
  // practices-sample.json, practices.json, practices-detail.json, agent-log.jsonl,
127
128
  // candidate.json, profile.md) lands in ./out, never in the repo root.
128
129
  const OUT_DIR = "out";
130
+ // How to run this tool again, as the person started it (npx, an installed bin, a clone).
131
+ const CMD = invocation();
129
132
  const outPath = () => join(process.cwd(), OUT_DIR);
130
133
  // Created only once logs were found. A `*` .gitignore inside keeps every file in it out of a commit.
131
134
  const ensureOut = () => {
@@ -306,7 +309,7 @@ function writeProfile(out, profile, { print = true } = {}) {
306
309
  if (!print) return;
307
310
  console.log(md);
308
311
  console.log(`Saved: ${OUT_DIR}/candidate.json + ${OUT_DIR}/profile.md`);
309
- console.log(`To send it to rebase when ready: rebase-verify submit`);
312
+ console.log(`To send it to rebase when ready: ${CMD} submit`);
310
313
  }
311
314
 
312
315
  // What the agent run adds to the profile: the answers merged into the practices block, who
@@ -382,7 +385,7 @@ async function cmdGenerate() {
382
385
  writeFileSync(join(out, "narrative-input.json"), JSON.stringify(generated.input, null, 2));
383
386
  console.log(` no narrative yet (no API key, no --narrative-file).`);
384
387
  console.log(` From a clone, inside Claude Code: /rebase-verify (writes ${OUT_DIR}/narrative.json and finalizes)`);
385
- console.log(` Manual: write ${OUT_DIR}/narrative.json, then rebase-verify finalize`);
388
+ console.log(` Manual: write ${OUT_DIR}/narrative.json, then ${CMD} finalize`);
386
389
  return;
387
390
  }
388
391
  if (generated.source === "api") generatedBy = { narrative: API_KEY_PATH };
@@ -424,7 +427,7 @@ async function cmdPrepare() {
424
427
  });
425
428
  writeFileSync(join(out, "narrative-input.json"), JSON.stringify(input, null, 2));
426
429
  console.log(`Wrote ${OUT_DIR}/narrative-input.json.`);
427
- console.log(`Next: write ${OUT_DIR}/narrative.json (rules in the slash command), then rebase-verify finalize`);
430
+ console.log(`Next: write ${OUT_DIR}/narrative.json (rules in the slash command), then ${CMD} finalize`);
428
431
  }
429
432
 
430
433
  // The model's answers, when the person's model wrote out/practices.json: checked
@@ -438,7 +441,7 @@ function mergePracticesAnswers(out, codeBlock, classifiedBy) {
438
441
  const fail = (msg) => { console.error(`${msg} Fix it, or delete ${OUT_DIR}/practices.json to leave the model practices out.`); process.exit(2); };
439
442
  const read = (file) => { try { return JSON.parse(readFileSync(file, "utf8")); } catch { return undefined; } };
440
443
  const sample = read(sampleFile);
441
- if (!Array.isArray(sample)) fail(`Missing or unreadable ${sampleFile}: run rebase-verify prepare again.`);
444
+ if (!Array.isArray(sample)) fail(`Missing or unreadable ${sampleFile}: run ${CMD} prepare again.`);
442
445
  const answers = read(answersFile);
443
446
  if (answers === undefined) fail(`${answersFile} is not valid JSON.`);
444
447
  const shared = JSON.parse(readFileSync(new URL("../share/practices.json", import.meta.url), "utf8"));
@@ -457,7 +460,7 @@ async function cmdFinalize() {
457
460
  console.log(`\nrebase-verify finalize\n`);
458
461
  const narrativeFile = flag("narrative-file", join(outPath(), "narrative.json"));
459
462
  if (!existsSync(narrativeFile)) {
460
- console.error(`Missing ${narrativeFile}. Run rebase-verify prepare first, then write ${OUT_DIR}/narrative.json.`);
463
+ console.error(`Missing ${narrativeFile}. Run ${CMD} prepare first, then write ${OUT_DIR}/narrative.json.`);
461
464
  process.exit(2);
462
465
  }
463
466
  const { parsed, fingerprint, forensics, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, out } = await loadProfileInputs();
@@ -488,7 +491,7 @@ async function cmdSubmit({ yes = false } = {}) {
488
491
  console.log(`(using ./candidate.json from an older run, new runs write to ${OUT_DIR}/)`);
489
492
  }
490
493
  if (!existsSync(profilePath)) {
491
- console.error(`No ${OUT_DIR}/candidate.json yet. Generate the profile first: rebase-verify generate`);
494
+ console.error(`No ${OUT_DIR}/candidate.json yet. Generate the profile first: ${CMD} generate`);
492
495
  process.exit(2);
493
496
  }
494
497
  const profile = JSON.parse(readFileSync(profilePath, "utf8"));
@@ -506,7 +509,7 @@ async function cmdSubmit({ yes = false } = {}) {
506
509
  console.log(`Controller: Rebase S.r.l. (VAT IT 14971460960). Details: https://letsrebase.com/privacy and PRIVACY.md.`);
507
510
  console.log(`NOT sent: raw logs, local repo context, third-party proper names.`);
508
511
  console.log(`Repository names (repoLabel) are stripped from the payload before it leaves your machine.`);
509
- console.log(`Inspect the exact outgoing payload: rebase-verify submit --dry-run`);
512
+ console.log(`Inspect the exact outgoing payload: ${CMD} submit --dry-run`);
510
513
 
511
514
  // Pre-flight groundedness: how much of the prose is anchored in the data.
512
515
  // Recomputed on the file as it is NOW, not trusted from the embedded score.
@@ -545,7 +548,8 @@ async function cmdSubmit({ yes = false } = {}) {
545
548
  const digest = buildDigest(parsed, { tz: techTz });
546
549
  const intensity = computeIntensity(parsed, { tz: profile.intensity?.timezone || DEFAULT_TZ });
547
550
  const techUsage = computeTechUsage(digest.projects, { tz: techTz });
548
- const logs = assessAgainstLogs(profile, digest.projects, { intensity, techUsage });
551
+ const practices = computeCodePractices(parsed, { tz: recordedPracticesTz(profile) });
552
+ const logs = assessAgainstLogs(profile, digest.projects, { intensity, techUsage, practices });
549
553
  issues.push(...logs.issues);
550
554
  excessClaims = logs.excessClaims || 0;
551
555
  for (const w of logs.warnings) console.log(` ~ ${w}`);
@@ -564,9 +568,9 @@ async function cmdSubmit({ yes = false } = {}) {
564
568
  console.log(` Claude Code prunes sessions older than its cleanup period (~30 days by default),`);
565
569
  console.log(` and the oldest part of your window aged out after the profile was generated.`);
566
570
  console.log(` Nothing is wrong with what you did: the numbers are just stale.`);
567
- console.log(` Fix: regenerate now and submit right away (rebase-verify generate, or re-run /rebase-verify).`);
571
+ console.log(` Fix: regenerate now and submit right away (${CMD} generate, or re-run /rebase-verify).`);
568
572
  } else {
569
- console.log(` If your logs were pruned since generation, regenerate (rebase-verify generate).`);
573
+ console.log(` If your logs were pruned since generation, regenerate (${CMD} generate).`);
570
574
  }
571
575
  } else {
572
576
  console.log(` structured data is internally consistent and matches your logs`);
@@ -577,15 +581,15 @@ async function cmdSubmit({ yes = false } = {}) {
577
581
  for (const b of blockers) {
578
582
  if (b.kind === "consistency") {
579
583
  console.error(`\nConsistency check failed (${b.count} issue${b.count > 1 ? "s" : ""}). Submission blocked.`);
580
- console.error(`Regenerate the profile (rebase-verify generate) or pass --force to bypass.`);
584
+ console.error(`Regenerate the profile (${CMD} generate) or pass --force to bypass.`);
581
585
  console.error(`Note: the intake re-checks groundedness and these invariants server-side.`);
582
586
  } else if (b.kind === "groundedness-unscored") {
583
587
  console.error(`\nGroundedness could not be scored: the prose has too few checkable anchors for the screen to run. Submission blocked.`);
584
- console.error(`Regenerate the profile (rebase-verify generate) or pass --force to bypass.`);
588
+ console.error(`Regenerate the profile (${CMD} generate) or pass --force to bypass.`);
585
589
  console.error(`Note: the intake flags unscoreable prose server-side as well.`);
586
590
  } else if (b.kind === "groundedness-low") {
587
591
  console.error(`\nGroundedness is low (${b.score}%). Submission blocked.`);
588
- console.error(`Regenerate the profile (rebase-verify generate) or pass --force to bypass.`);
592
+ console.error(`Regenerate the profile (${CMD} generate) or pass --force to bypass.`);
589
593
  }
590
594
  }
591
595
  };
@@ -607,7 +611,7 @@ async function cmdSubmit({ yes = false } = {}) {
607
611
  }
608
612
 
609
613
  if (!(yes || has("yes"))) {
610
- console.log(`\nTo confirm: rebase-verify submit --yes`);
614
+ console.log(`\nTo confirm: ${CMD} submit --yes`);
611
615
  return;
612
616
  }
613
617
  if (blockers.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsrebase/verify",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Work profile: build a tamper-evident, PII-redacted work profile from your coding-agent logs and send it to rebase for review.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,7 +31,7 @@
31
31
  "homepage": "https://github.com/letsrebase/verify",
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://github.com/letsrebase/verify.git"
34
+ "url": "git+https://github.com/letsrebase/verify.git"
35
35
  },
36
36
  "dependencies": {
37
37
  "@agentclientprotocol/sdk": "2.8.0",
@@ -23,7 +23,7 @@
23
23
  import { bandFor, monthSpan } from "./tech-usage.mjs";
24
24
  import { labelVocabulary } from "./digest.mjs";
25
25
  import { isValidTimezone } from "./days.mjs";
26
- import { RUBRIC, practicesArtifact } from "./practices-rules.mjs";
26
+ import { CODE_PRACTICES, RUBRIC, practicesArtifact } from "./practices-rules.mjs";
27
27
 
28
28
  // { agent, model } as the hub reads it: an agent id of 1-40 [a-z0-9-], a model
29
29
  // name of 1-120 printable, non-blank characters, or null.
@@ -232,6 +232,10 @@ export function submitBlockers({ issues = [], groundedness = null, force = false
232
232
  // .timezone })) — never the machine zone, or a candidate who generated with
233
233
  // --tz Europe/Rome and submits from a CI box would be flagged for the bucketing
234
234
  // difference, not for any real excess.
235
+ //
236
+ // opts.practices: the code practices recounted from the same logs in the zone the
237
+ // practices block RECORDED (computeCodePractices(parsed, { tz })), null when no
238
+ // session could show any of them. Left undefined, the recount is skipped.
235
239
  export function assessAgainstLogs(profile, digestProjects, opts = {}) {
236
240
  const issues = [];
237
241
  const warnings = [];
@@ -353,5 +357,26 @@ export function assessAgainstLogs(profile, digestProjects, opts = {}) {
353
357
  }
354
358
  }
355
359
 
360
+ // Code practices, same one-directional gate: every count only grows with
361
+ // ongoing use, so a claimed seen, of, products or months above the recount is
362
+ // pruning or a hand edit. Like dispatch detection, the counting rules are
363
+ // matcher-derived, so a tool update that narrows them shrinks the recount on
364
+ // unchanged logs; the remedy is the same: regenerate. The model practices are
365
+ // the person's model reading a sample, which no recount can repeat: they stay
366
+ // under the structure check alone. The rubric decides which ids are code, not
367
+ // the item's own method, which a hand edit could change.
368
+ const codeIds = new Set(CODE_PRACTICES.map((p) => p.id));
369
+ if (Array.isArray(profile?.practices?.items) && opts.practices !== undefined) {
370
+ const recounted = new Map((opts.practices?.items ?? []).map((x) => [x.id, x]));
371
+ for (const c of profile.practices.items) {
372
+ if (!codeIds.has(c?.id)) continue;
373
+ const d = recounted.get(c.id);
374
+ for (const k of ["seen", "of", "products", "months"]) {
375
+ const got = d?.[k] ?? 0;
376
+ if ((Number(c[k]) || 0) > got) excess(`practices.${c.id}: claims ${k} ${c[k]}, the logs recount ${got} (the counting rules may also have changed in an update: regenerate)`);
377
+ }
378
+ }
379
+ }
380
+
356
381
  return { issues, warnings, excessClaims };
357
382
  }
@@ -0,0 +1,17 @@
1
+ // The command a person types to run rebase-verify again, as they started it this time:
2
+ // npx puts nothing on the PATH and a clone has no `rebase-verify` either, so a hint that
3
+ // says `rebase-verify submit` fails for both.
4
+ import { basename, isAbsolute, relative } from "node:path";
5
+
6
+ export const PACKAGE_NAME = "@letsrebase/verify";
7
+
8
+ export function invocation({ env = process.env, script = process.argv[1] ?? "", cwd = process.cwd() } = {}) {
9
+ // npm exec and npx both set npm_command=exec for the process they start.
10
+ if (env.npm_command === "exec") return `npx ${PACKAGE_NAME}`;
11
+ // An installed package runs through its bin link (or, on Windows, a shim that passes the
12
+ // path inside node_modules): the `rebase-verify` command exists.
13
+ if (basename(script) !== "rebase-verify.mjs" || /[\\/]node_modules[\\/]/.test(script)) return "rebase-verify";
14
+ const rel = relative(cwd, script);
15
+ const path = rel && !rel.startsWith("..") && !isAbsolute(rel) ? rel : script;
16
+ return `node ${/\s/.test(path) ? `"${path}"` : path}`;
17
+ }
package/src/practices.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  // been": a session whose log lacks a field a practice needs (see `needs` in
5
5
  // practices-rules.mjs), or whose adapter cannot show it (ADAPTERS_WITHOUT), is
6
6
  // left out of that denominator, never counted as "not seen".
7
- import { DEFAULT_TZ, monthKeyFor } from "./days.mjs";
7
+ import { DEFAULT_TZ, isValidTimezone, monthKeyFor } from "./days.mjs";
8
8
  import { isEphemeral, repoKey, splitTopLevel, stripHeredocs } from "./digest.mjs";
9
9
  import {
10
10
  ADAPTERS_WITHOUT, CODE_PRACTICES, EDIT_TOOLS as EDIT_TOOL_NAMES, PLAN_TOOLS as PLAN_TOOL_NAMES, RUBRIC,
@@ -208,6 +208,13 @@ export function computeCodePractices(parsed, { tz = DEFAULT_TZ } = {}) {
208
208
  return items.length ? { items } : null;
209
209
  }
210
210
 
211
+ // The zone a submit recounts the code practices in: the one the block recorded,
212
+ // never the machine's, so the recount measures the data and not the bucketing.
213
+ export function recordedPracticesTz(profile) {
214
+ const tz = profile?.practices?.timezone;
215
+ return isValidTimezone(tz) ? tz : DEFAULT_TZ;
216
+ }
217
+
211
218
  // The block as the profile carries it: the rubric id and the zone the months
212
219
  // were bucketed in travel with the counts. No items, no block. `classifiedBy`
213
220
  // ({ agent, model }) names who read the sessions for the model items.