@odavl/guardian 0.1.0-rc1

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 (56) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/bin/guardian.js +690 -0
  5. package/flows/example-login-flow.json +36 -0
  6. package/flows/example-signup-flow.json +44 -0
  7. package/guardian-contract-v1.md +149 -0
  8. package/guardian.config.json +54 -0
  9. package/guardian.policy.json +12 -0
  10. package/guardian.profile.docs.yaml +18 -0
  11. package/guardian.profile.ecommerce.yaml +17 -0
  12. package/guardian.profile.marketing.yaml +18 -0
  13. package/guardian.profile.saas.yaml +21 -0
  14. package/package.json +69 -0
  15. package/policies/enterprise.json +12 -0
  16. package/policies/saas.json +12 -0
  17. package/policies/startup.json +12 -0
  18. package/src/guardian/attempt-engine.js +454 -0
  19. package/src/guardian/attempt-registry.js +227 -0
  20. package/src/guardian/attempt-reporter.js +507 -0
  21. package/src/guardian/attempt.js +227 -0
  22. package/src/guardian/auto-attempt-builder.js +283 -0
  23. package/src/guardian/baseline-reporter.js +143 -0
  24. package/src/guardian/baseline-storage.js +285 -0
  25. package/src/guardian/baseline.js +492 -0
  26. package/src/guardian/behavioral-signals.js +261 -0
  27. package/src/guardian/breakage-intelligence.js +223 -0
  28. package/src/guardian/browser.js +92 -0
  29. package/src/guardian/cli-summary.js +141 -0
  30. package/src/guardian/crawler.js +142 -0
  31. package/src/guardian/discovery-engine.js +661 -0
  32. package/src/guardian/enhanced-html-reporter.js +305 -0
  33. package/src/guardian/failure-taxonomy.js +169 -0
  34. package/src/guardian/flow-executor.js +374 -0
  35. package/src/guardian/flow-registry.js +67 -0
  36. package/src/guardian/html-reporter.js +414 -0
  37. package/src/guardian/index.js +218 -0
  38. package/src/guardian/init-command.js +139 -0
  39. package/src/guardian/junit-reporter.js +264 -0
  40. package/src/guardian/market-criticality.js +335 -0
  41. package/src/guardian/market-reporter.js +305 -0
  42. package/src/guardian/network-trace.js +178 -0
  43. package/src/guardian/policy.js +357 -0
  44. package/src/guardian/preset-loader.js +148 -0
  45. package/src/guardian/reality.js +547 -0
  46. package/src/guardian/reporter.js +181 -0
  47. package/src/guardian/root-cause-analysis.js +171 -0
  48. package/src/guardian/safety.js +248 -0
  49. package/src/guardian/scan-presets.js +60 -0
  50. package/src/guardian/screenshot.js +152 -0
  51. package/src/guardian/sitemap.js +225 -0
  52. package/src/guardian/snapshot-schema.js +266 -0
  53. package/src/guardian/snapshot.js +327 -0
  54. package/src/guardian/validators.js +323 -0
  55. package/src/guardian/visual-diff.js +247 -0
  56. package/src/guardian/webhook.js +206 -0
@@ -0,0 +1,36 @@
1
+ {
2
+ "id": "example-login-flow",
3
+ "name": "User Login Flow",
4
+ "description": "Test the login functionality - navigate to login page, fill credentials, and verify success",
5
+ "steps": [
6
+ {
7
+ "type": "navigate",
8
+ "target": "/login"
9
+ },
10
+ {
11
+ "type": "waitFor",
12
+ "target": "input[name='email']",
13
+ "timeout": 5000
14
+ },
15
+ {
16
+ "type": "type",
17
+ "target": "input[name='email']",
18
+ "value": "test@example.com"
19
+ },
20
+ {
21
+ "type": "type",
22
+ "target": "input[name='password']",
23
+ "value": "test123"
24
+ },
25
+ {
26
+ "type": "click",
27
+ "target": "button[type='submit']",
28
+ "waitForNavigation": true
29
+ },
30
+ {
31
+ "type": "waitFor",
32
+ "target": "[data-testid='dashboard']",
33
+ "timeout": 5000
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "id": "example-signup-flow",
3
+ "name": "User Signup Flow",
4
+ "description": "Test the signup functionality - navigate to signup, fill form, submit, and verify confirmation",
5
+ "steps": [
6
+ {
7
+ "type": "navigate",
8
+ "target": "/signup"
9
+ },
10
+ {
11
+ "type": "waitFor",
12
+ "target": "form[data-testid='signup-form']",
13
+ "timeout": 5000
14
+ },
15
+ {
16
+ "type": "type",
17
+ "target": "input[name='name']",
18
+ "value": "Test User"
19
+ },
20
+ {
21
+ "type": "type",
22
+ "target": "input[name='email']",
23
+ "value": "newuser@example.com"
24
+ },
25
+ {
26
+ "type": "type",
27
+ "target": "input[name='password']",
28
+ "value": "securepass123"
29
+ },
30
+ {
31
+ "type": "click",
32
+ "target": "input[type='checkbox'][name='terms']"
33
+ },
34
+ {
35
+ "type": "submit",
36
+ "target": "form[data-testid='signup-form']"
37
+ },
38
+ {
39
+ "type": "waitFor",
40
+ "target": "[data-testid='signup-success']",
41
+ "timeout": 10000
42
+ }
43
+ ]
44
+ }
@@ -0,0 +1,149 @@
1
+ # ODAVL Guardian — Contract v1.0
2
+
3
+ Status: Active
4
+
5
+ Scope: Guardian MVP
6
+
7
+ Version: v1.0
8
+
9
+ Decision-Grade: Yes
10
+
11
+ ## 0) Purpose
12
+
13
+ This contract defines the canonical, non-negotiable rules and guarantees for ODAVL Guardian’s Market Reality Testing Engine at MVP scope. It specifies final decisions, confidence semantics, evidence requirements, flow execution rules, honesty constraints, prohibited behaviors, verifiability, and stability expectations. All implementations, outputs, and operator-facing UX must conform to this contract.
14
+
15
+ ## 1) Definition
16
+
17
+ ODAVL Guardian is a headless browser-based reality testing engine that:
18
+ - Launches a real browser (Playwright/Chromium) to inspect a site via crawl and/or execute predefined flows.
19
+ - Collects evidence artifacts (screenshots, logs, reports, traces, optional HAR) for verifiable outcomes.
20
+ - Computes coverage and behavior metrics, forms a conservative confidence judgment, and issues a final decision.
21
+ - Emits machine-readable `report.json`, human-readable `report.html`, `logs.txt`, and run directory with artifacts.
22
+
23
+ Terminology:
24
+ - "Coverage Confidence": Confidence derived from how much of the site was observed (depth/pages vs discovered).
25
+ - "Behavioral Confidence": Confidence derived from observed runtime stability and health (navigation/http/page/console errors).
26
+ - "Evidence Policy": The resolved set of required vs optional artifacts that must be present for a decision to be valid.
27
+ - "Flow": A predefined deterministic sequence of real user interactions (navigate/click/type/submit/waitFor).
28
+
29
+ ## 2) Final Decisions
30
+
31
+ Guardian issues exactly three decisions:
32
+ - READY — Site is acceptable for MVP launch given the evidence and confidence model.
33
+ - DO_NOT_LAUNCH — Launch is blocked due to critical failure or missing required evidence.
34
+ - INSUFFICIENT_CONFIDENCE — Evidence and/or behavior do not justify readiness.
35
+
36
+ Exit codes:
37
+ - READY → 0
38
+ - DO_NOT_LAUNCH → 1
39
+ - INSUFFICIENT_CONFIDENCE → 1
40
+ - TOOL ERROR → 2
41
+
42
+ Decision drivers:
43
+ - Any Flow FAIL → DO_NOT_LAUNCH.
44
+ - Required evidence missing per Evidence Policy → DO_NOT_LAUNCH.
45
+ - Overall confidence HIGH or MEDIUM → READY.
46
+ - Overall confidence LOW → INSUFFICIENT_CONFIDENCE.
47
+
48
+ ## 3) Confidence Model
49
+
50
+ Guardian separates confidence into two dimensions and a resolved overall level.
51
+
52
+ ### 3.1 Coverage Confidence
53
+ - HIGH: Sufficient coverage (e.g., deep exploration and/or high coverage percentage).
54
+ - MEDIUM: Moderate coverage.
55
+ - LOW: Limited coverage (e.g., very few pages visited).
56
+
57
+ ### 3.2 Behavioral Confidence
58
+ - HIGH: No critical runtime instability (no navigation failures, no page errors, no server 5xx), acceptable client logs.
59
+ - MEDIUM: Minor issues (e.g., 4xx or console errors) without critical failures.
60
+ - LOW: Critical instability (navigation failure, unhandled page errors, or server 5xx).
61
+
62
+ ### 3.3 Overall Confidence Resolution
63
+ - HIGH: Sufficient coverage OR a successful Flow with no critical errors.
64
+ - MEDIUM: Limited coverage BUT clean behavior (no page errors or critical failures); minor issues allowed.
65
+ - LOW: Insufficient coverage AND/OR unstable behavior (critical failures present).
66
+
67
+ Guardian must record a human-readable "reasoning" for the resolved confidence.
68
+
69
+ ## 4) Evidence Contract
70
+
71
+ Guardian enforces an explicit Evidence Policy defining required vs optional artifacts.
72
+
73
+ ### 4.1 Policy Modes
74
+ - normal (default):
75
+ - REQUIRED: screenshots (pages and flow steps), `report.json`, `report.html`.
76
+ - REQUIRED when enabled: `trace.zip`.
77
+ - OPTIONAL: `network.har`/`network.json`.
78
+ - strict:
79
+ - REQUIRED: screenshots, `report.json`, `report.html`.
80
+ - REQUIRED when enabled: `trace.zip` and `network.har`/`network.json`.
81
+ - custom (via CLI overrides):
82
+ - `--require-har` forces HAR required.
83
+ - `--optional-har` forces HAR optional.
84
+ - Precedence: `require-har` > `optional-har` > `--evidence`.
85
+
86
+ ### 4.2 Missing Evidence Handling
87
+ - Missing REQUIRED evidence → DO_NOT_LAUNCH.
88
+ - Missing OPTIONAL evidence → does not block READY; recorded as warnings and may reduce confidence.
89
+
90
+ ### 4.3 Evidence Reporting (report.json)
91
+ Guardian must include:
92
+ ```
93
+ evidence: {
94
+ policy: { mode: "normal|strict|custom", requirements: { screenshots: true, traceWhenEnabled: true, harWhenEnabled: true|false } },
95
+ present: { screenshots: true|false, trace: true|false|null, har: true|false|null },
96
+ requiredMissing: [ ... ],
97
+ optionalMissing: [ ... ],
98
+ warnings: [ { code, message } ]
99
+ }
100
+ ```
101
+
102
+ The HTML report must present the Evidence Policy, list required/optional missing items, and warnings.
103
+
104
+ ## 5) Flow Contract
105
+
106
+ Flows are executed as real interactions through the browser and must:
107
+ - Support step types: `navigate <url>`, `click <selector(s)>`, `type <selector> <value>`, `submit <selector>`, `waitFor <selector|url:pattern>`.
108
+ - Capture a full-page screenshot for each step with deterministic naming (`flow-XX-type.png`).
109
+ - Stop immediately on step failure; record `failedStepIndex`, the error, and mark Flow result FAIL.
110
+ - Treat any Flow FAIL as REVENUE-BLOCKING: the final decision must be DO_NOT_LAUNCH.
111
+ - Log step-by-step outcomes in `report.json` and `report.html`.
112
+
113
+ ## 6) Honesty & Transparency
114
+
115
+ Guardian must:
116
+ - Never overstate certainty; only issue READY when justified by the confidence model and evidence policy.
117
+ - Explicitly list reasons for final decisions and confidence (human-readable) in outputs.
118
+ - Disclose coverage limitations (e.g., LOW coverage warning) visibly in CLI and HTML.
119
+ - Preserve conservative defaults that favor truthful reporting.
120
+
121
+ ## 7) Prohibited Behaviors
122
+
123
+ Guardian must not:
124
+ - Ignore missing REQUIRED evidence.
125
+ - Fabricate or simulate evidence artifacts.
126
+ - Issue READY when overall confidence is LOW.
127
+ - Suppress critical errors (navigation failures, page errors, server 5xx) from decisions.
128
+ - Alter artifacts or reports after generation except for permitted `--clean` on PASS.
129
+
130
+ ## 8) Verifiability
131
+
132
+ Guardian must be verifiable via:
133
+ - Reproducible commands and exit codes (PowerShell examples in README).
134
+ - Stable artifact paths under `artifacts/run-YYYYMMDD-HHMMSS/` including `report.json`, `report.html`, `logs.txt`, screenshots, traces, and HAR/network when present.
135
+ - Machine-readable fields capturing coverage, behavior, evidence, flow results, blockers, and final decisions.
136
+
137
+ CLI must surface final decision, confidence summary (coverage + behavior + reasoning), evidence policy, and warnings.
138
+
139
+ ## 9) Stability Clause
140
+
141
+ Guardian aims for stable, repeatable outcomes under identical inputs:
142
+ - Flow runs must be deterministic with consistent PASS/FAIL given the same site state.
143
+ - Crawl outcomes may vary in timing, but decisions should remain consistent when behavior and evidence are unchanged.
144
+ - Evidence presence (trace/HAR) may vary by environment; the Evidence Policy governs whether such variance affects decisions.
145
+ - Any non-deterministic behavior should be logged; the final decision must remain conservative.
146
+
147
+ ## Final Seal / Closing Statement
148
+
149
+ This contract is canonical for ODAVL Guardian MVP. All implementations and outputs must adhere strictly to these rules. Operators rely on Guardian’s conservative, evidence-driven judgments; deviations from this contract are prohibited. Changes to this contract require explicit versioning and are not implied by code modifications.
@@ -0,0 +1,54 @@
1
+ {
2
+ "baseUrl": "https://example.com",
3
+ "mode": "SAFE",
4
+ "maxPages": 25,
5
+ "maxDepth": 3,
6
+ "timeoutMs": 20000,
7
+ "slowThresholdMs": 6000,
8
+ "traceEnabled": true,
9
+ "harEnabled": true,
10
+ "safety": {
11
+ "denyUrlPatterns": [
12
+ "logout",
13
+ "signout",
14
+ "sign-out",
15
+ "delete",
16
+ "remove",
17
+ "admin",
18
+ "unsubscribe",
19
+ "checkout/confirm",
20
+ "checkout/complete",
21
+ "order/confirm",
22
+ "payment/confirm",
23
+ "deactivate",
24
+ "destroy",
25
+ "purge",
26
+ "terminate",
27
+ "cancel"
28
+ ],
29
+ "denySelectors": [
30
+ "[data-danger]",
31
+ "[data-destructive]",
32
+ "button:has-text(\"Delete\")",
33
+ "button:has-text(\"Remove\")",
34
+ "button:has-text(\"Confirm Payment\")",
35
+ "button:has-text(\"Place Order\")",
36
+ "button:has-text(\"Complete Purchase\")",
37
+ "button:has-text(\"Unsubscribe\")",
38
+ "button:has-text(\"Deactivate\")",
39
+ "button:has-text(\"Cancel Account\")",
40
+ ".btn-danger",
41
+ ".btn-delete",
42
+ ".payment-submit",
43
+ ".checkout-submit"
44
+ ],
45
+ "allowUrlPatterns": [],
46
+ "allowSelectors": [],
47
+ "blockFormSubmitsByDefault": true,
48
+ "blockPaymentsByDefault": true
49
+ },
50
+ "artifacts": {
51
+ "artifactsDir": "artifacts",
52
+ "runIdStrategy": "timestamp"
53
+ }
54
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Startup Policy",
3
+ "description": "Permissive policy for fast-moving startups. Fail only on CRITICAL issues.",
4
+ "failOnSeverity": "CRITICAL",
5
+ "maxWarnings": 999,
6
+ "maxInfo": 999,
7
+ "maxTotalRisk": 999,
8
+ "failOnNewRegression": false,
9
+ "failOnSoftFailures": false,
10
+ "softFailureThreshold": 999,
11
+ "requireBaseline": false
12
+ }
@@ -0,0 +1,18 @@
1
+ # Guardian profile template: Docs
2
+ baseUrl: https://docs.example.com
3
+ profile: docs
4
+ mode: SAFE
5
+ maxPages: 40
6
+ maxDepth: 5
7
+ slowThresholdMs: 7000
8
+ traceEnabled: false
9
+ harEnabled: false
10
+ revenue:
11
+ enabled: false
12
+ auth:
13
+ enabled: false
14
+ regression:
15
+ enabled: true
16
+ maxScoreDrop: 12
17
+ maxCoverageDropPercent: 12
18
+ policyPack: trust-first
@@ -0,0 +1,17 @@
1
+ # Guardian profile template: E-commerce
2
+ baseUrl: https://shop.example.com
3
+ profile: ecommerce
4
+ mode: SAFE
5
+ maxPages: 35
6
+ maxDepth: 4
7
+ slowThresholdMs: 6000
8
+ traceEnabled: false
9
+ harEnabled: false
10
+ revenue:
11
+ enabled: true
12
+ pricingPath: /products
13
+ regression:
14
+ enabled: true
15
+ maxScoreDrop: 6
16
+ maxCoverageDropPercent: 8
17
+ policyPack: revenue-first
@@ -0,0 +1,18 @@
1
+ # Guardian profile template: Marketing
2
+ baseUrl: https://www.example.com
3
+ profile: marketing
4
+ mode: SAFE
5
+ maxPages: 20
6
+ maxDepth: 3
7
+ slowThresholdMs: 6000
8
+ traceEnabled: false
9
+ harEnabled: false
10
+ revenue:
11
+ enabled: false
12
+ auth:
13
+ enabled: false
14
+ regression:
15
+ enabled: true
16
+ maxScoreDrop: 10
17
+ maxCoverageDropPercent: 12
18
+ policyPack: trust-first
@@ -0,0 +1,21 @@
1
+ # Guardian profile template: SaaS
2
+ baseUrl: https://app.example.com
3
+ profile: saas
4
+ mode: SAFE
5
+ maxPages: 25
6
+ maxDepth: 3
7
+ slowThresholdMs: 6000
8
+ traceEnabled: false
9
+ harEnabled: false
10
+ auth:
11
+ enabled: true
12
+ email: ${GUARDIAN_AUTH_EMAIL}
13
+ password: ${GUARDIAN_AUTH_PASSWORD}
14
+ revenue:
15
+ enabled: true
16
+ pricingPath: /pricing
17
+ regression:
18
+ enabled: true
19
+ maxScoreDrop: 8
20
+ maxCoverageDropPercent: 10
21
+ policyPack: revenue-first
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@odavl/guardian",
3
+ "version": "0.1.0-rc1",
4
+ "description": "ODAVL Guardian — Market Reality Testing Engine with Visual Diffs, Behavioral Signals, Auto-Discovery, Intelligence, and CI/CD Integration",
5
+ "license": "MIT",
6
+ "author": "ODAVL",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/odavlstudio/odavlguardian"
10
+ },
11
+ "keywords": [
12
+ "testing",
13
+ "browser-testing",
14
+ "reality-testing",
15
+ "playwright",
16
+ "cli",
17
+ "guardian",
18
+ "market-testing",
19
+ "quality-assurance"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ },
24
+ "bin": {
25
+ "guardian": "bin/guardian.js"
26
+ },
27
+ "files": [
28
+ "bin/",
29
+ "src/",
30
+ "flows/",
31
+ "policies/",
32
+ "guardian.config.json",
33
+ "guardian.policy.json",
34
+ "guardian.profile.docs.yaml",
35
+ "guardian.profile.ecommerce.yaml",
36
+ "guardian.profile.marketing.yaml",
37
+ "guardian.profile.saas.yaml",
38
+ "guardian-contract-v1.md",
39
+ "README.md",
40
+ "LICENSE",
41
+ "CHANGELOG.md"
42
+ ],
43
+ "scripts": {
44
+ "test": "node test/mvp.test.js",
45
+ "test:phase0": "node test/phase0-reality-lock.test.js",
46
+ "test:phase1": "node test/phase1-baseline-expansion.test.js",
47
+ "test:phase2": "node test/phase2-auto-attempts.test.js",
48
+ "test:phase2-old": "node test/phase2.test.js",
49
+ "test:attempt": "node test/attempt.test.js",
50
+ "test:reality": "node test/reality.test.js",
51
+ "test:baseline": "node test/baseline.test.js",
52
+ "test:baseline:junit": "node test/baseline-junit.test.js",
53
+ "test:snapshot": "node test/snapshot.test.js",
54
+ "test:soft-failures": "node test/soft-failures.test.js",
55
+ "test:criticality": "node test/market-criticality.test.js",
56
+ "test:discovery": "node test/discovery.test.js",
57
+ "test:phase5": "node test/phase5.test.js",
58
+ "test:phase5:visual": "node test/phase5-visual.test.js",
59
+ "test:phase5:evidence": "node test/phase5-evidence-run.test.js",
60
+ "test:phase5:all": "node test/phase5-visual.test.js && node test/phase5-evidence-run.test.js",
61
+ "test:phase6": "node test/phase6.test.js && node test/phase6-product.test.js",
62
+ "test:all": "node test/phase0-reality-lock.test.js && node test/mvp.test.js && node test/phase2.test.js && node test/attempt.test.js && node test/reality.test.js && node test/baseline.test.js && node test/baseline-junit.test.js && node test/snapshot.test.js && node test/soft-failures.test.js && node test/market-criticality.test.js && node test/discovery.test.js && node test/phase5.test.js && node test/phase5-visual.test.js && node test/phase5-evidence-run.test.js && node test/phase6.test.js",
63
+ "start": "node bin/guardian.js"
64
+ },
65
+ "dependencies": {
66
+ "express": "^5.2.1",
67
+ "playwright": "^1.48.2"
68
+ }
69
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Enterprise Policy",
3
+ "description": "Strict policy for enterprise deployments. Zero tolerance for CRITICAL or WARNING issues.",
4
+ "failOnSeverity": "WARNING",
5
+ "maxWarnings": 0,
6
+ "maxInfo": 0,
7
+ "maxTotalRisk": 0,
8
+ "failOnNewRegression": true,
9
+ "failOnSoftFailures": true,
10
+ "softFailureThreshold": 0,
11
+ "requireBaseline": true
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "SaaS Policy",
3
+ "description": "Balanced policy for SaaS products. Fail on CRITICAL and detect regressions.",
4
+ "failOnSeverity": "CRITICAL",
5
+ "maxWarnings": 1,
6
+ "maxInfo": 999,
7
+ "maxTotalRisk": 999,
8
+ "failOnNewRegression": true,
9
+ "failOnSoftFailures": false,
10
+ "softFailureThreshold": 5,
11
+ "requireBaseline": false
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Startup Policy",
3
+ "description": "Permissive policy for fast-moving startups. Fail only on CRITICAL issues.",
4
+ "failOnSeverity": "CRITICAL",
5
+ "maxWarnings": 999,
6
+ "maxInfo": 999,
7
+ "maxTotalRisk": 999,
8
+ "failOnNewRegression": false,
9
+ "failOnSoftFailures": false,
10
+ "softFailureThreshold": 999,
11
+ "requireBaseline": false
12
+ }