@vantageos/backend-doctor 0.1.13 → 0.2.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.
Files changed (58) hide show
  1. package/README.md +19 -2
  2. package/dist/args.d.ts +16 -0
  3. package/dist/args.js +54 -0
  4. package/dist/build-stamp.d.ts +13 -0
  5. package/dist/build-stamp.js +76 -0
  6. package/dist/build-stamp.json +4 -0
  7. package/dist/caller-resolution.d.ts +222 -0
  8. package/dist/caller-resolution.js +1195 -0
  9. package/dist/cli.js +217 -10
  10. package/dist/coverage-cli.js +8 -0
  11. package/dist/crud-coverage.d.ts +81 -0
  12. package/dist/crud-coverage.js +375 -0
  13. package/dist/detectors/oracle-axis1.d.ts +5 -3
  14. package/dist/detectors/oracle-axis1.js +24 -15
  15. package/dist/detectors/oracle-axis2.js +5 -6
  16. package/dist/detectors/predicates.d.ts +3 -0
  17. package/dist/detectors/predicates.js +81 -16
  18. package/dist/detectors/shared.js +5 -5
  19. package/dist/detectors/source/_scan.js +6 -1
  20. package/dist/detectors/source/backfill.js +9 -1
  21. package/dist/detectors/source/guard-helper-flow.d.ts +112 -0
  22. package/dist/detectors/source/guard-helper-flow.js +1173 -0
  23. package/dist/detectors/source/identity.d.ts +51 -2
  24. package/dist/detectors/source/identity.js +815 -14
  25. package/dist/detectors/source/isolation.d.ts +11 -1
  26. package/dist/detectors/source/isolation.js +106 -25
  27. package/dist/detectors/source/jobs.js +165 -2
  28. package/dist/detectors/source/readbudget.d.ts +1 -0
  29. package/dist/detectors/source/readbudget.js +67 -4
  30. package/dist/detectors/source/security.d.ts +16 -0
  31. package/dist/detectors/source/security.js +225 -7
  32. package/dist/detectors/source/write-isolation.d.ts +8 -1
  33. package/dist/detectors/source/write-isolation.js +64 -30
  34. package/dist/detectors/standard/r46-returns-validator.d.ts +8 -0
  35. package/dist/detectors/standard/r46-returns-validator.js +45 -14
  36. package/dist/detectors/structural.js +14 -10
  37. package/dist/oracle.d.ts +92 -3
  38. package/dist/oracle.js +229 -12
  39. package/dist/registry.d.ts +7 -0
  40. package/dist/registry.js +48 -6
  41. package/dist/report.d.ts +11 -1
  42. package/dist/report.js +15 -2
  43. package/dist/state-rank.d.ts +5 -0
  44. package/dist/state-rank.js +9 -0
  45. package/dist/tally.d.ts +35 -0
  46. package/dist/tally.js +76 -8
  47. package/dist/target.d.ts +32 -0
  48. package/dist/target.js +173 -0
  49. package/fixtures/cr1-classes/_generated/api.d.ts +24 -0
  50. package/fixtures/cr1-classes/surface.ts +206 -0
  51. package/fixtures/cr1-empty/nothing.ts +1 -0
  52. package/fixtures/cr1-refusal-on-resolved/_generated/api.d.ts +24 -0
  53. package/fixtures/cr1-refusal-on-resolved/doors.ts +180 -0
  54. package/fixtures/cr1-refusal-on-resolved/lib/auth.ts +104 -0
  55. package/fixtures/r34-vp-auth-30e821b/auth-805-812.ts.txt +8 -0
  56. package/fixtures/r34-vp-auth-30e821b/auth-878-890.ts.txt +13 -0
  57. package/fixtures/vp-writer-tier-1e4ab36.csv +55 -0
  58. package/package.json +2 -2
@@ -1,8 +1,10 @@
1
1
  import type { LiveDetector } from "@vantageos/mcp-doctor";
2
2
  import type { Detector, DetectorResult, Tree } from "../../engine-types.js";
3
+ import { type GuardHelperKind, type HelperVerdict } from "./guard-helper-flow.js";
3
4
  /** The standard both are pinned against (short hash a9d7877b), §15/§18. */
4
5
  export declare const IDENTITY_STANDARD_PIN = "analysis/vantagepeers/backend-standard/backend-standard.md @ a9d7877b4947ed8ae61d234433debb2182a2ba44 (elpiarthera/ElPi-Corp) \u00A715/\u00A718";
5
6
  type SrcFile = Tree["files"][number];
7
+ type SrcLine = SrcFile["lines"][number];
6
8
  /** A registrable entry — structurally the RegistryEntry the orchestrator spreads
7
9
  * into REGISTRY. We do NOT import registry.ts; we mirror its shape so the
8
10
  * orchestrator owns the integration (same discipline as security.ts). */
@@ -21,8 +23,55 @@ interface Scan {
21
23
  violate: Site[];
22
24
  cnj: Site[];
23
25
  }
24
- export declare function scanR6(files: SrcFile[]): Scan;
25
- export declare function scanR16(files: SrcFile[]): Scan;
26
+ interface Handler {
27
+ name: string;
28
+ startN: number;
29
+ lines: SrcLine[];
30
+ /** true for an `internalMutation` registration — no client can call it, so
31
+ * its arguments are supplied by server code, never by a caller (R-6 scope). */
32
+ internal: boolean;
33
+ }
34
+ /** Split a convex file into its top-level mutation/internalMutation handler
35
+ * blocks. A block runs from `export const <name> = mutation(` to the next
36
+ * top-level `export ` (or EOF). Queries/actions are not R-6 write handlers.
37
+ * Each block records whether it is an `internalMutation` registration. */
38
+ export declare function splitMutationHandlers(f: SrcFile): Handler[];
39
+ export declare function normalizeArgsAccess(raw: string): string;
40
+ /** The taint result of following a boundary local. `matched` is the count of
41
+ * assignments/declarations of the local actually FOUND in the handler — a
42
+ * `matched === 0` local is a THIRD state (could-not-judge), never silently
43
+ * tainted (Eta REVISE #3 defect 2). `cnj` counts RHSes whose own provenance
44
+ * could not be resolved (a bare-identifier hop that dead-ends or exhausts the
45
+ * bound) — again could-not-judge, never a guess. */
46
+ export interface LocalTaint {
47
+ fromArgs: number;
48
+ fromScope: number;
49
+ matched: number;
50
+ cnj: number;
51
+ /** Present (and > 0) only when a scope-derived assignment is the return of
52
+ * a function judged in the tree as an identity resolver. */
53
+ fromResolver?: number;
54
+ }
55
+ /** Follow ONE hop (plus one bounded bare-identifier hop): classify every
56
+ * assignment/declaration of `local` in the handler as scope-derived, arg-derived,
57
+ * or could-not-judge. Reads a PLAIN assignment RHS and a DESTRUCTURING RHS with
58
+ * the same scope test (defect 1). Exposes `matched` so a local with NO resolvable
59
+ * assignment is a third state, not silently tainted (defect 2). A bare-identifier
60
+ * RHS (`const t = orgSlug`) is NOT scope evidence on its own — the identifier's
61
+ * own provenance is resolved one further, bounded, cycle-guarded hop (defect 3);
62
+ * exhaustion is `cnj`, never a guess. */
63
+ export declare function analyzeLocalTaint(h: Handler, local: string, isResolver?: (name: string) => boolean): LocalTaint;
64
+ export declare const R6_GUARD_HELPERS: Readonly<Record<string, GuardHelperKind>>;
65
+ interface HelperDef {
66
+ rel: string;
67
+ n: number;
68
+ exported: boolean;
69
+ judgement: HelperVerdict;
70
+ }
71
+ /** Index every definition of an allowlisted helper in the tree. */
72
+ export declare function indexGuardHelpers(files: SrcFile[]): Map<string, HelperDef[]>;
73
+ export declare function scanR6(files: SrcFile[], rootIsConvex?: boolean): Scan;
74
+ export declare function scanR16(files: SrcFile[], rootIsConvex?: boolean): Scan;
26
75
  /** A live-probe outcome for R-6: what a boundary-less write call returned. */
27
76
  export type LiveWriteOutcome = {
28
77
  kind: "refused";