qualiow-exploratory-testing 2.2.1 → 2.3.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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { Command } from 'commander';
2
3
 
3
4
  /**
4
5
  * Core type definitions for Qualiow Exploratory Testing Skills.
@@ -87,6 +88,29 @@ interface SourceBranchConfig {
87
88
  base_branch?: string;
88
89
  components?: Record<string, string>;
89
90
  }
91
+ type TriageProvider = 'typesafe' | 'laya';
92
+ interface LayaTriageConfig {
93
+ endpoint?: string;
94
+ model?: string;
95
+ max_len?: number;
96
+ /** NAME of the env var holding the local server's key, only when it requires one. */
97
+ api_key_env?: string;
98
+ }
99
+ interface VerificationConfig {
100
+ /** `judge` (default): every candidate bug faces `qa-bug-judge` before it ships.
101
+ * `off`: drafts ship unverified, with no `verification/` directory.
102
+ * `triage-shadow`: the judge as in `judge`, plus an advisory decision-model
103
+ * triage of each claim recorded beside the verdict. */
104
+ mode?: 'judge' | 'off' | 'triage-shadow';
105
+ /** Single-provider shorthand. `laya` = a self-hosted, loopback-only server. */
106
+ triage_provider?: TriageProvider;
107
+ /** Several providers side by side, each recorded in its own file. */
108
+ triage_providers?: TriageProvider[];
109
+ /** NAME of the env var holding the TypeSafe API key (default TYPESAFE_API_KEY). */
110
+ triage_api_key_env?: string;
111
+ laya?: LayaTriageConfig;
112
+ evidence_max_lines?: number;
113
+ }
90
114
  interface TargetConfig {
91
115
  id: string;
92
116
  name: string;
@@ -96,6 +120,7 @@ interface TargetConfig {
96
120
  browser: BrowserConfig;
97
121
  scope: ScopeConfig;
98
122
  safety?: SafetyConfig;
123
+ verification?: VerificationConfig;
99
124
  environment?: EnvironmentConfig;
100
125
  backend?: BackendConfig;
101
126
  api?: ApiSurfaceConfig;
@@ -308,6 +333,39 @@ declare const SafetyConfigSchema: z.ZodObject<{
308
333
  no_file_upload: z.ZodOptional<z.ZodBoolean>;
309
334
  no_delete_actions: z.ZodOptional<z.ZodBoolean>;
310
335
  }, z.core.$strict>;
336
+ declare const TriageProviderSchema: z.ZodEnum<{
337
+ typesafe: "typesafe";
338
+ laya: "laya";
339
+ }>;
340
+ declare const LayaTriageConfigSchema: z.ZodObject<{
341
+ endpoint: z.ZodOptional<z.ZodString>;
342
+ model: z.ZodOptional<z.ZodString>;
343
+ max_len: z.ZodOptional<z.ZodNumber>;
344
+ api_key_env: z.ZodOptional<z.ZodString>;
345
+ }, z.core.$strict>;
346
+ declare const VerificationConfigSchema: z.ZodObject<{
347
+ mode: z.ZodDefault<z.ZodEnum<{
348
+ judge: "judge";
349
+ off: "off";
350
+ "triage-shadow": "triage-shadow";
351
+ }>>;
352
+ triage_provider: z.ZodOptional<z.ZodEnum<{
353
+ typesafe: "typesafe";
354
+ laya: "laya";
355
+ }>>;
356
+ triage_providers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
357
+ typesafe: "typesafe";
358
+ laya: "laya";
359
+ }>>>;
360
+ triage_api_key_env: z.ZodOptional<z.ZodString>;
361
+ laya: z.ZodOptional<z.ZodObject<{
362
+ endpoint: z.ZodOptional<z.ZodString>;
363
+ model: z.ZodOptional<z.ZodString>;
364
+ max_len: z.ZodOptional<z.ZodNumber>;
365
+ api_key_env: z.ZodOptional<z.ZodString>;
366
+ }, z.core.$strict>>;
367
+ evidence_max_lines: z.ZodOptional<z.ZodNumber>;
368
+ }, z.core.$strict>;
311
369
  declare const WebTargetConfigSchema: z.ZodObject<{
312
370
  id: z.ZodString;
313
371
  name: z.ZodString;
@@ -360,6 +418,29 @@ declare const WebTargetConfigSchema: z.ZodObject<{
360
418
  no_file_upload: z.ZodOptional<z.ZodBoolean>;
361
419
  no_delete_actions: z.ZodOptional<z.ZodBoolean>;
362
420
  }, z.core.$strict>>;
421
+ verification: z.ZodOptional<z.ZodObject<{
422
+ mode: z.ZodDefault<z.ZodEnum<{
423
+ judge: "judge";
424
+ off: "off";
425
+ "triage-shadow": "triage-shadow";
426
+ }>>;
427
+ triage_provider: z.ZodOptional<z.ZodEnum<{
428
+ typesafe: "typesafe";
429
+ laya: "laya";
430
+ }>>;
431
+ triage_providers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
432
+ typesafe: "typesafe";
433
+ laya: "laya";
434
+ }>>>;
435
+ triage_api_key_env: z.ZodOptional<z.ZodString>;
436
+ laya: z.ZodOptional<z.ZodObject<{
437
+ endpoint: z.ZodOptional<z.ZodString>;
438
+ model: z.ZodOptional<z.ZodString>;
439
+ max_len: z.ZodOptional<z.ZodNumber>;
440
+ api_key_env: z.ZodOptional<z.ZodString>;
441
+ }, z.core.$strict>>;
442
+ evidence_max_lines: z.ZodOptional<z.ZodNumber>;
443
+ }, z.core.$strict>>;
363
444
  environment: z.ZodOptional<z.ZodObject<{
364
445
  kind: z.ZodEnum<{
365
446
  dev: "dev";
@@ -538,6 +619,19 @@ declare const TargetConfigSchema: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
538
619
  no_file_upload?: boolean | undefined;
539
620
  no_delete_actions?: boolean | undefined;
540
621
  } | undefined;
622
+ verification?: {
623
+ mode: "judge" | "off" | "triage-shadow";
624
+ triage_provider?: "typesafe" | "laya" | undefined;
625
+ triage_providers?: ("typesafe" | "laya")[] | undefined;
626
+ triage_api_key_env?: string | undefined;
627
+ laya?: {
628
+ endpoint?: string | undefined;
629
+ model?: string | undefined;
630
+ max_len?: number | undefined;
631
+ api_key_env?: string | undefined;
632
+ } | undefined;
633
+ evidence_max_lines?: number | undefined;
634
+ } | undefined;
541
635
  environment?: {
542
636
  kind: "dev" | "ephemeral" | "staging" | "production";
543
637
  destroyed_automatically?: boolean | undefined;
@@ -1035,6 +1129,13 @@ declare function resolveTargetPath(cwd: string, name: string | undefined, pkgRoo
1035
1129
  declare function resolveDataDir(cwd: string, explicit?: string, pkgRoot?: string): string;
1036
1130
  /** Resolve a domain config, trying `<id>.yml` then `_<id>.yml`. */
1037
1131
  declare function resolveDomainPath(dataDir: string, id: string): string;
1132
+ /**
1133
+ * Read one credential by NAME in the order `paths.md` defines for the skills:
1134
+ * a variable already in the environment wins, then `<cwd>/qa/.env`, then
1135
+ * `<cwd>/.env`. Files never override the process environment, and the value
1136
+ * is returned to the caller only — never logged.
1137
+ */
1138
+ declare function readEnvVar(cwd: string, name: string): string | undefined;
1038
1139
 
1039
1140
  /**
1040
1141
  * Knowledge-base manifest synchronisation.
@@ -1117,6 +1218,16 @@ interface ParsedSession {
1117
1218
  content: string;
1118
1219
  }[];
1119
1220
  }
1221
+ /**
1222
+ * Extracts the content under a markdown heading that starts with the
1223
+ * given prefix. Searches for both ## and ### level headings.
1224
+ */
1225
+ declare function extractSection(content: string, headingPrefix: string): string;
1226
+ /**
1227
+ * Extracts numbered list items from markdown text.
1228
+ * Handles lines like "1. Navigate to ..." and continuation lines.
1229
+ */
1230
+ declare function extractNumberedList(text: string): string[];
1120
1231
  /**
1121
1232
  * Parses a single bug report markdown file into structured data.
1122
1233
  */
@@ -1316,4 +1427,470 @@ interface KbDigestOptions {
1316
1427
  */
1317
1428
  declare function runKbDigest(options: KbDigestOptions, cwd: string): string;
1318
1429
 
1319
- export { ALL_BUGS_COLUMNS, ALL_BUGS_MD_HEADER, type AnyTargetConfig, type AuthConfig, AuthConfigSchema, type BrowserConfig, BrowserConfigSchema, type BugReport, type BugSeverity, CONFIDENTIALITY_HEADER_MD, CONFIDENTIALITY_LINES, CONFIDENTIALITY_NOTICE, type CopyRecord, type CopyStatus, type CoverageEntry, type DiscoveredSessionDir, type DomainConfig, DomainConfigSchema, INDEX_COLUMNS, INDEX_MD_HEADER, type InitOptions, type InitResult, type Journey, JourneySchema, type KbDigestOptions, KnowledgeChangelogSchema, type KnowledgeEntry, type KnowledgeEntryContent, KnowledgeEntryContentSchema, KnowledgeEntrySchema, type KnowledgeManifest, type KnowledgeManifestEntry, KnowledgeManifestEntrySchema, KnowledgeManifestSchema, type KnowledgeManifestStats, KnowledgeManifestStatsSchema, KnowledgeReleaseSchema, LEGACY_SESSION_DIR_RE, type ListOptions, type LoadingStrategy, LoadingStrategySchema, type ManifestStats, type MobileAppConfig, MobileAppConfigSchema, type MobileDeviceConfig, MobileDeviceConfigSchema, type MobileScopeConfig, MobileScopeConfigSchema, type MobileTargetConfig, MobileTargetConfigSchema, type MobileWebConfig, MobileWebConfigSchema, type ParsedBug, type ParsedSession, type ParsedSessionDir, type ParsedTable, QUALIOW_GITIGNORE_ENTRIES, QUALIOW_GITIGNORE_HEADER, REDACTION_CATEGORIES, type RedactOptions, type RegistryEntry, type ReportMeta, type RiskRanking, SESSION_DIR_RE, SESSION_KINDS, type SafetyConfig, SafetyConfigSchema, type ScopeConfig, ScopeConfigSchema, type SessionKind, type SessionMetrics, SessionMetricsSchema, type SessionRow, type SeverityCounts, SeverityCountsSchema, type SourceRepoConfig, SourceRepoConfigSchema, type SyncResult, type TargetConfig, TargetConfigSchema, type ValidationError, type ValidationResult, WebTargetConfigSchema, appendSessionMetrics, appendSessionMetricsDeduped, buildManifestRegistry, buildTableRow, computeStats, containsSecrets, csvEscape, describeSessionDir, extractCoverage, extractListSection, extractReportMeta, generateHtmlReport, generateJiraExport, generateJsonReport, generateMarkdownSummary, getPackageRoot, getPackageVersion, hasConfidentialityHeader, headersMatchColumns, listReleaseDirs, loadSessionForOutput, mergeGitignore, missingColumns, parseBugReport, parseMarkdownTable, parseSession, parseSessionDirName, parseTimeBox, readAllMetrics, readSessionIndex, redact, resolveDataDir, resolveDomainPath, resolveSessionDir, resolveSkillsSource, resolveTargetPath, runExplore, runInit, runKb, runKbDigest, runList, runReport, runValidate, sessionDirName, sessionTimestamp, slugify, syncKnowledgeManifest, validateAllConfigs, validateDomainConfig, validateKnowledgeBase, validateKnowledgeEntry, validateTargetConfig };
1430
+ /**
1431
+ * Types for the opt-in decision-model triage of a candidate bug.
1432
+ *
1433
+ * A decision model answers narrow typed questions about text — a probability
1434
+ * (noul), a choice or a score — and nothing else: no reasoning, no prose. Both
1435
+ * providers speak the same `/v1/systemone` wire protocol: TypeSafe's hosted Jev
1436
+ * and a self-hosted Laya server. Everything in this file is a request/response
1437
+ * shape or the parsed form of a claim card; the judgement stays in the session,
1438
+ * and the prediction rule lives in `triage.ts`.
1439
+ */
1440
+ interface NoulQuestion {
1441
+ type: 'noul';
1442
+ instructions: string;
1443
+ criteria?: {
1444
+ true?: string;
1445
+ false?: string;
1446
+ };
1447
+ }
1448
+ interface ChoiceQuestion {
1449
+ type: 'choice';
1450
+ instructions: string;
1451
+ /** option key → description; the model picks one key. */
1452
+ criteria: Record<string, string>;
1453
+ }
1454
+ interface ScoreQuestion {
1455
+ type: 'score';
1456
+ instructions: string;
1457
+ /** Ordered level descriptions, low to high (2–10). */
1458
+ criteria: string[];
1459
+ }
1460
+ type TriageQuestion = NoulQuestion | ChoiceQuestion | ScoreQuestion;
1461
+ interface SystemOneRequest {
1462
+ state: unknown;
1463
+ model: string;
1464
+ questions: Record<string, TriageQuestion>;
1465
+ /** Laya only: per-call token budget (its default window would truncate a claim state). */
1466
+ max_len?: number;
1467
+ }
1468
+ interface NoulAnswer {
1469
+ type: 'noul';
1470
+ /** P(yes), 0–1. */
1471
+ noul: number;
1472
+ }
1473
+ interface ChoiceAnswer {
1474
+ type: 'choice';
1475
+ choice: string;
1476
+ probabilities: Record<string, number>;
1477
+ /** Concentration of the distribution, 0–1. */
1478
+ confidence: number;
1479
+ }
1480
+ interface ScoreAnswer {
1481
+ type: 'score';
1482
+ score: number;
1483
+ legend?: Record<string, unknown>;
1484
+ probabilities: Record<string, number>;
1485
+ confidence: number;
1486
+ }
1487
+ type TriageAnswer = NoulAnswer | ChoiceAnswer | ScoreAnswer;
1488
+ type TriageAnswers = Record<string, TriageAnswer>;
1489
+ interface TriageUsage {
1490
+ input_tokens: number;
1491
+ output_tokens: number;
1492
+ }
1493
+ interface SystemOneResponse {
1494
+ model: string;
1495
+ answers: TriageAnswers;
1496
+ usage: TriageUsage;
1497
+ }
1498
+ interface ParsedClaim {
1499
+ /** `CLAIM-NNN`, or '' when the heading is missing. */
1500
+ id: string;
1501
+ /** False for a stub card (no title, no actual behaviour or no steps). */
1502
+ complete: boolean;
1503
+ title: string;
1504
+ url: string;
1505
+ claimedSeverity: string;
1506
+ environment: string;
1507
+ reproductionRate: string;
1508
+ expected: string;
1509
+ actual: string;
1510
+ steps: string[];
1511
+ /** Raw bullet lines under `## Evidence`. */
1512
+ evidenceLines: string[];
1513
+ /** Path tokens found in those bullets, in order, deduplicated. */
1514
+ evidencePaths: string[];
1515
+ /** The bullets' prose once the path tokens are removed (console/network excerpts). */
1516
+ evidenceInline: string;
1517
+ }
1518
+ type JudgeVerdict = 'CONFIRMED' | 'CONFIRMED-ADJUSTED' | 'REFUTED' | 'UNREPRODUCIBLE' | 'UNVERIFIED';
1519
+ interface ParsedVerdict {
1520
+ verdict: JudgeVerdict | 'UNKNOWN';
1521
+ verdictRaw: string;
1522
+ /** True when the block was fenced; the one-line `VERDICT: UNVERIFIED (…)` form is not. */
1523
+ fenced: boolean;
1524
+ method?: string;
1525
+ confidence?: string;
1526
+ severityRaw?: string;
1527
+ /** Severity the judge settled on: `agree with claimed X` → X, `adjusted to Y` → Y, `n/a` → null. */
1528
+ severity?: string | null;
1529
+ reproResult?: string;
1530
+ reasoning?: string;
1531
+ falsePositivePattern?: string;
1532
+ }
1533
+ interface EvidenceFile {
1534
+ /** Basename only — never a full path. */
1535
+ file: string;
1536
+ lines: number;
1537
+ text: string;
1538
+ truncated_from?: number;
1539
+ }
1540
+ type EvidenceSkipReason = 'image' | 'missing' | 'type' | 'outside-session' | 'excluded' | 'budget';
1541
+ interface EvidenceSkipped {
1542
+ file: string;
1543
+ reason: EvidenceSkipReason;
1544
+ }
1545
+ interface CollectedEvidence {
1546
+ sent: EvidenceFile[];
1547
+ notSent: EvidenceSkipped[];
1548
+ }
1549
+ interface TriageState {
1550
+ claim: {
1551
+ id: string;
1552
+ title: string;
1553
+ url: string;
1554
+ claimed_severity: string;
1555
+ environment: string;
1556
+ reproduction_rate: string;
1557
+ expected: string;
1558
+ actual: string;
1559
+ steps: string[];
1560
+ };
1561
+ evidence_inline: string;
1562
+ evidence_files: Array<{
1563
+ file: string;
1564
+ lines: number;
1565
+ text: string;
1566
+ }>;
1567
+ note: string;
1568
+ }
1569
+ /**
1570
+ * The triage's reading of a claim, recorded beside the judge's verdict. A
1571
+ * prediction only: Phase 7 never orders, shortens or skips a judge run on it.
1572
+ */
1573
+ type Route = 'refute-risk' | 'unclear' | 'likely-confirmed';
1574
+ /** What the decision model predicts the judge will say — a prediction, never a verdict. */
1575
+ type PredictedVerdict = 'CONFIRMED' | 'CONFIRMED-ADJUSTED' | 'REFUTED' | 'UNREPRODUCIBLE';
1576
+ type SeverityName = 'Critical' | 'High' | 'Medium' | 'Low';
1577
+ interface RoutingThresholds {
1578
+ /** P(refuted) + P(unreproducible) at or above this → refute-risk. */
1579
+ refuteMass: number;
1580
+ /** Any false-positive pattern noul at or above this → refute-risk. */
1581
+ fpPattern: number;
1582
+ byDesign: number;
1583
+ altExplanation: number;
1584
+ /** predicted_verdict confidence needed for likely-confirmed. */
1585
+ confirmConfidence: number;
1586
+ confirmEvidence: number;
1587
+ confirmSteps: number;
1588
+ /** Every fp_* noul must stay below this for likely-confirmed. */
1589
+ confirmFpCeiling: number;
1590
+ }
1591
+ interface RouteDecision {
1592
+ route: Route;
1593
+ reasons: string[];
1594
+ predictedVerdict: PredictedVerdict;
1595
+ refuteMass: number;
1596
+ }
1597
+ type TriageMode = 'triage-shadow';
1598
+ interface TriageResult {
1599
+ claimId: string;
1600
+ mode: TriageMode;
1601
+ model: string;
1602
+ createdAt: string;
1603
+ request: {
1604
+ state: TriageState;
1605
+ questions: Record<string, TriageQuestion>;
1606
+ };
1607
+ response: SystemOneResponse | null;
1608
+ usage: TriageUsage | null;
1609
+ costUsd: number | null;
1610
+ ms: number | null;
1611
+ route: {
1612
+ route: Route;
1613
+ reasons: string[];
1614
+ thresholds: RoutingThresholds;
1615
+ } | null;
1616
+ evidence: {
1617
+ sent: Array<Omit<EvidenceFile, 'text'>>;
1618
+ not_sent: EvidenceSkipped[];
1619
+ };
1620
+ redactions: string[];
1621
+ /** Question id → pattern text (scrubbed), for the fp_* questions. */
1622
+ patterns: Record<string, string>;
1623
+ unavailable?: string;
1624
+ /** Set for providers other than typesafe (absent = the hosted provider). */
1625
+ provider?: 'laya';
1626
+ }
1627
+
1628
+ /**
1629
+ * `qualiow judge triage <claim-file>` — opt-in, advisory decision-model triage
1630
+ * of ONE claim card, run by Phase 7 of /qa-explore before the adversarial
1631
+ * judge. The judge still sees every claim and never reads what this writes.
1632
+ *
1633
+ * Off by default. A live run sends nothing unless the resolved target config
1634
+ * sets `verification.mode: triage-shadow` and lists the provider:
1635
+ * - `typesafe` (hosted) also needs its API key under the env var the config
1636
+ * names (default `TYPESAFE_API_KEY`, read from the environment, `qa/.env`,
1637
+ * then `.env`);
1638
+ * - `laya` (self-hosted) must point at a loopback endpoint.
1639
+ * `--provider` only narrows the target's own list; it can never add a provider
1640
+ * the target did not name. What leaves the machine is written verbatim to
1641
+ * `verification/<STEM>-NNN.json`; the human block goes to `<STEM>-NNN.md`.
1642
+ *
1643
+ * Exit codes: 0 triaged (or --dry-run) · 1 usage / unparseable card ·
1644
+ * 2 not enabled for this target or key missing (nothing sent) ·
1645
+ * 3 every provider unavailable after retries (files written with `UNAVAILABLE`).
1646
+ */
1647
+
1648
+ declare const EXIT_NOT_ENABLED = 2;
1649
+ declare const EXIT_UNAVAILABLE = 3;
1650
+ /** The target does not opt in, or the key is missing. Nothing was sent. */
1651
+ declare class TriageNotEnabledError extends Error {
1652
+ constructor(message: string);
1653
+ }
1654
+ interface JudgeTriageOptions {
1655
+ target?: string;
1656
+ out?: string;
1657
+ evidenceMaxLines?: number;
1658
+ dryRun?: boolean;
1659
+ mock?: string;
1660
+ /** Run only this one of the providers the target lists. Never adds a provider. */
1661
+ provider?: TriageProvider;
1662
+ /** Overrides `verification.laya.endpoint` (loopback only). */
1663
+ endpoint?: string;
1664
+ }
1665
+ interface JudgeTriageResult {
1666
+ ok: boolean;
1667
+ exitCode: 0 | typeof EXIT_UNAVAILABLE;
1668
+ claimId: string;
1669
+ mode: TriageMode;
1670
+ route: Route | null;
1671
+ predictedVerdict: string;
1672
+ block: string;
1673
+ /** What the command prints: the block and the `<STEM>_FILE:` line, or the dry-run summary. */
1674
+ stdout: string;
1675
+ mdPath?: string;
1676
+ jsonPath?: string;
1677
+ usage?: TriageUsage;
1678
+ costUsd?: number;
1679
+ ms?: number;
1680
+ evidenceSent: Array<Omit<EvidenceFile, 'text'>>;
1681
+ evidenceNotSent: EvidenceSkipped[];
1682
+ redactions: string[];
1683
+ stateChars: number;
1684
+ /** One entry per provider that ran (in config order); the top-level fields mirror the first that answered. */
1685
+ providers?: Array<{
1686
+ provider: TriageProvider;
1687
+ verdict: string;
1688
+ route: Route | null;
1689
+ mdPath: string;
1690
+ jsonPath: string;
1691
+ ms?: number;
1692
+ }>;
1693
+ /** Providers the config lists that could not run here, with the reason. */
1694
+ skipped?: Array<{
1695
+ provider: TriageProvider;
1696
+ reason: string;
1697
+ }>;
1698
+ }
1699
+ interface JudgeTriageContext {
1700
+ cwd: string;
1701
+ fetch?: typeof fetch;
1702
+ sleep?: (ms: number) => Promise<void>;
1703
+ now?: () => number;
1704
+ }
1705
+ declare function judgeCommand(): Command;
1706
+ /**
1707
+ * The providers the target lists (`triage_providers`, else `triage_provider`),
1708
+ * deduplicated, order kept. `--provider` narrows that list to one entry and is
1709
+ * refused when the target does not list it. Only a run that sends nothing
1710
+ * (`--dry-run`, `--mock`) with no list at all falls back to the flag or to
1711
+ * `typesafe`.
1712
+ */
1713
+ declare function resolveProviders(verification: VerificationConfig | undefined, forced?: TriageProvider): TriageProvider[];
1714
+ declare function runJudgeTriage(claimFileArg: string, options: JudgeTriageOptions, ctx: JudgeTriageContext): Promise<JudgeTriageResult>;
1715
+ /** The most cautious reading of the providers that answered. */
1716
+ declare function combineRoutes(routes: Route[]): Route;
1717
+
1718
+ /**
1719
+ * One POST to a `/v1/systemone` endpoint: TypeSafe's hosted API or a
1720
+ * self-hosted Laya server, which speak the same wire protocol.
1721
+ *
1722
+ * Kept dependency-free on purpose: the call is a bearer header and a JSON
1723
+ * body, and retrying 429/503/529 with backoff is a dozen lines. `fetch`,
1724
+ * `sleep` and the clock are injectable so the tests never touch the network.
1725
+ * Redirects are refused: a 307/308 would re-send the body to wherever the
1726
+ * server points, which defeats both the fixed hosted endpoint and the
1727
+ * loopback-only rule for Laya.
1728
+ */
1729
+
1730
+ declare const JEV_ENDPOINT = "https://api.typesafe.ai/v1/systemone";
1731
+ declare const JEV_MODEL = "jev-latest";
1732
+ /** USD per input token, from TypeSafe's published pricing ($0.042 per 1M). Output tokens are free. */
1733
+ declare const JEV_USD_PER_INPUT_TOKEN: number;
1734
+ declare class TriageApiError extends Error {
1735
+ readonly status?: number | undefined;
1736
+ readonly retryable: boolean;
1737
+ constructor(message: string, status?: number | undefined, retryable?: boolean);
1738
+ }
1739
+ interface CallOptions {
1740
+ /** Empty for a keyless local Laya server: no Authorization header is sent. */
1741
+ apiKey: string;
1742
+ fetch?: typeof fetch;
1743
+ sleep?: (ms: number) => Promise<void>;
1744
+ /** Retries on 429 / 503 / 529 / network failure (default 3). */
1745
+ retries?: number;
1746
+ /** Per-attempt timeout in milliseconds (default 15 000). */
1747
+ timeoutMs?: number;
1748
+ endpoint?: string;
1749
+ now?: () => number;
1750
+ }
1751
+ interface CallResult {
1752
+ response: SystemOneResponse;
1753
+ ms: number;
1754
+ attempts: number;
1755
+ }
1756
+ /** 500 ms, 1 s, 2 s … plus up to 250 ms of jitter. */
1757
+ declare function backoffMs(attempt: number, random?: () => number): number;
1758
+ declare function callSystemOne(req: SystemOneRequest, opts: CallOptions): Promise<CallResult>;
1759
+ /** Every requested question must be answered with the type it was asked as. */
1760
+ declare function assertResponse(json: unknown, questions: Record<string, TriageQuestion>): SystemOneResponse;
1761
+ declare const LAYA_DEFAULT_ENDPOINT = "http://127.0.0.1:8000/v1/systemone";
1762
+ declare const LAYA_DEFAULT_MODEL = "multilingual";
1763
+ /** The multilingual checkpoint reads up to 8,192 tokens; its shipped 1,024 cuts a claim state off. */
1764
+ declare const LAYA_DEFAULT_MAX_LEN = 8192;
1765
+ /**
1766
+ * True only for an http(s) endpoint on this machine — the only kind a Laya
1767
+ * provider may use: `localhost`, `::1`, or a dotted-quad 127.0.0.0/8 address.
1768
+ * A hostname that merely starts with `127.` (`127.evil.example`) is not one.
1769
+ */
1770
+ declare function isLoopbackEndpoint(endpoint: string): boolean;
1771
+ declare function estimateCostUsd(usage: Pick<TriageUsage, 'input_tokens'>): number;
1772
+
1773
+ /**
1774
+ * Parsers for the two Phase 7 verification artefacts: the claim card the judge
1775
+ * sees (`verification/claims/CLAIM-NNN.md`) and the verdict block it returns
1776
+ * (`verification/VERDICT-NNN.md`). Both formats are defined in
1777
+ * `.claude/skills/qa-explore/phases/07-reporting.md` and `qa-bug-judge.md`.
1778
+ */
1779
+
1780
+ declare function parseClaimCard(content: string): ParsedClaim;
1781
+ declare function normaliseJudgeVerdict(raw: string): JudgeVerdict | 'UNKNOWN';
1782
+ /** `agree with claimed High` → High; `adjusted to Medium — …` → Medium; `n/a` → null. */
1783
+ declare function parseSeverityField(raw: string | undefined): string | null | undefined;
1784
+ declare function parseVerdictBlock(content: string): ParsedVerdict;
1785
+
1786
+ /**
1787
+ * What may leave the machine.
1788
+ *
1789
+ * `redact()` is the pack's secret list and is shared with the write guard, so
1790
+ * it must not learn URL, host or path rules (`tests/unit/hooks.test.ts` pins
1791
+ * that parity). This module composes it: secrets first, then every URL is
1792
+ * reduced to its path, every dotted hostname to `[HOST]` and every absolute
1793
+ * path under a common root (`/Users`, `/home`, `/tmp`, `/srv`, `/workspace`, a
1794
+ * drive letter, …) to its basename. A path under any other root passes
1795
+ * through: a generic rule would also eat the `[URL /path]` tokens kept on
1796
+ * purpose. The path of a URL carries the signal a triage needs (which screen);
1797
+ * the host does not.
1798
+ *
1799
+ * Pattern-based, so it has gaps, and the docs state them: IP addresses,
1800
+ * single-label hostnames (`intranet`), URL paths (kept on purpose, and they can
1801
+ * name a customer or an internal service) and free-text product, company or
1802
+ * people names all pass through unchanged. The exact request is saved next to
1803
+ * the verdict so a human can see what was sent.
1804
+ */
1805
+ interface ScrubResult {
1806
+ text: string;
1807
+ /** `redact()` categories plus 'URL', 'Host' and 'Path' when they fired. */
1808
+ redactions: string[];
1809
+ }
1810
+ declare function scrubForTransmission(text: string): ScrubResult;
1811
+
1812
+ /**
1813
+ * The pure half of `qualiow judge triage`: evidence collection, the state that
1814
+ * leaves the machine, the question set, the prediction rule and the block that
1815
+ * is written next to the judge's verdict.
1816
+ *
1817
+ * Nothing here decides anything. `route()` turns probabilities into a recorded
1818
+ * reading of the claim (`refute-risk`, `unclear`, `likely-confirmed`) and the
1819
+ * predicted verdict is a guess at what the judge will say. Phase 7 still sends
1820
+ * every claim to the judge, never reads these files to order or shorten that
1821
+ * run, and keeps severity, business impact and whether a bug ships in the
1822
+ * session (`references/delegation-rules.md`).
1823
+ */
1824
+
1825
+ declare const DEFAULT_EVIDENCE_MAX_LINES = 120;
1826
+ /** ≈ 24k tokens at 4 chars/token — under the 32k-token state limit with margin. */
1827
+ declare const MAX_STATE_CHARS = 96000;
1828
+ declare const MAX_PATTERNS = 12;
1829
+ declare const EVIDENCE_NOTE: string;
1830
+ /** `verification/claims/CLAIM-NNN.md` → the session directory. */
1831
+ declare function sessionDirOfClaim(claimFile: string): string;
1832
+ declare function collectEvidence(claim: ParsedClaim, claimFile: string, maxLines?: number): CollectedEvidence;
1833
+ /**
1834
+ * The bold lead-ins of the "False Positive" sections of `learned-patterns.md`
1835
+ * (project copy first, then the resolved data dir) plus the session's own
1836
+ * `verification/proposed-patterns.md` bullets. Deduplicated, capped. Raw text:
1837
+ * `buildQuestionSet()` scrubs each one before it becomes part of a question.
1838
+ */
1839
+ declare function loadFalsePositivePatterns(cwd: string, sessionDir?: string): string[];
1840
+ declare function buildTriageState(claim: ParsedClaim, evidence: CollectedEvidence): {
1841
+ state: TriageState;
1842
+ redactions: string[];
1843
+ };
1844
+ /**
1845
+ * Keeps the serialised state under `maxChars`, halving the last evidence file
1846
+ * first and dropping it (reason `budget`) when it is down to a stub. Returns the
1847
+ * evidence metadata as it stands after the cut.
1848
+ */
1849
+ declare function fitStateToBudget(state: TriageState, evidence: CollectedEvidence, maxChars?: number): {
1850
+ sent: Array<Omit<EvidenceFile, 'text'>>;
1851
+ notSent: EvidenceSkipped[];
1852
+ };
1853
+ /** Verbatim from `references/severity-guide.md`. */
1854
+ declare const SEVERITY_CRITERIA: Record<'critical' | 'high' | 'medium' | 'low', string>;
1855
+ declare const VERDICT_CRITERIA: Record<'confirmed' | 'confirmed_adjusted' | 'refuted' | 'unreproducible', string>;
1856
+ /**
1857
+ * The fixed question set. Each false-positive pattern passes through
1858
+ * `scrubForTransmission()` before it is placed in a question, because the
1859
+ * question text leaves the machine with the state. `redactions` lists what
1860
+ * that scrub removed.
1861
+ */
1862
+ declare function buildQuestionSet(patterns: string[]): {
1863
+ questions: Record<string, TriageQuestion>;
1864
+ patternIds: Record<string, string>;
1865
+ redactions: string[];
1866
+ };
1867
+ declare const DEFAULT_THRESHOLDS: RoutingThresholds;
1868
+ declare function normaliseSeverity(raw: string): SeverityName | undefined;
1869
+ declare function toPredictedVerdict(choice: string): PredictedVerdict;
1870
+ /**
1871
+ * `refute-risk` when any refutation signal fires; otherwise `likely-confirmed`
1872
+ * when every confirmation condition holds; otherwise `unclear`. Recorded, never
1873
+ * acted on.
1874
+ */
1875
+ declare function route(answers: TriageAnswers, t?: RoutingThresholds): RouteDecision;
1876
+ interface TriageBlockInput {
1877
+ mode: TriageMode;
1878
+ /** First line's key: `JEV_VERDICT` (hosted) or `LAYA_VERDICT` (local). */
1879
+ verdictKey: string;
1880
+ claimedSeverity: string;
1881
+ answers: TriageAnswers | null;
1882
+ decision: RouteDecision | null;
1883
+ patternIds: Record<string, string>;
1884
+ evidenceSent: Array<Omit<EvidenceFile, 'text'>>;
1885
+ evidenceNotSent: EvidenceSkipped[];
1886
+ redactions: string[];
1887
+ usage: TriageUsage | null;
1888
+ costUsd: number | null;
1889
+ ms: number | null;
1890
+ model: string;
1891
+ unavailable?: string;
1892
+ }
1893
+ /** The fenced block written to `verification/JEV-NNN.md` / `LAYA-NNN.md` (without the fences). */
1894
+ declare function renderTriageBlock(input: TriageBlockInput): string;
1895
+
1896
+ export { ALL_BUGS_COLUMNS, ALL_BUGS_MD_HEADER, type AnyTargetConfig, type AuthConfig, AuthConfigSchema, type BrowserConfig, BrowserConfigSchema, type BugReport, type BugSeverity, CONFIDENTIALITY_HEADER_MD, CONFIDENTIALITY_LINES, CONFIDENTIALITY_NOTICE, type CallOptions, type CallResult, type ChoiceAnswer, type ChoiceQuestion, type CollectedEvidence, type CopyRecord, type CopyStatus, type CoverageEntry, DEFAULT_EVIDENCE_MAX_LINES, DEFAULT_THRESHOLDS, type DiscoveredSessionDir, type DomainConfig, DomainConfigSchema, EVIDENCE_NOTE, EXIT_NOT_ENABLED, EXIT_UNAVAILABLE, type EvidenceFile, type EvidenceSkipReason, type EvidenceSkipped, INDEX_COLUMNS, INDEX_MD_HEADER, type InitOptions, type InitResult, JEV_ENDPOINT, JEV_MODEL, JEV_USD_PER_INPUT_TOKEN, type Journey, JourneySchema, type JudgeTriageOptions, type JudgeTriageResult, type JudgeVerdict, type KbDigestOptions, KnowledgeChangelogSchema, type KnowledgeEntry, type KnowledgeEntryContent, KnowledgeEntryContentSchema, KnowledgeEntrySchema, type KnowledgeManifest, type KnowledgeManifestEntry, KnowledgeManifestEntrySchema, KnowledgeManifestSchema, type KnowledgeManifestStats, KnowledgeManifestStatsSchema, KnowledgeReleaseSchema, LAYA_DEFAULT_ENDPOINT, LAYA_DEFAULT_MAX_LEN, LAYA_DEFAULT_MODEL, LEGACY_SESSION_DIR_RE, type LayaTriageConfig, LayaTriageConfigSchema, type ListOptions, type LoadingStrategy, LoadingStrategySchema, MAX_PATTERNS, MAX_STATE_CHARS, type ManifestStats, type MobileAppConfig, MobileAppConfigSchema, type MobileDeviceConfig, MobileDeviceConfigSchema, type MobileScopeConfig, MobileScopeConfigSchema, type MobileTargetConfig, MobileTargetConfigSchema, type MobileWebConfig, MobileWebConfigSchema, type NoulAnswer, type NoulQuestion, type ParsedBug, type ParsedClaim, type ParsedSession, type ParsedSessionDir, type ParsedTable, type ParsedVerdict, type PredictedVerdict, QUALIOW_GITIGNORE_ENTRIES, QUALIOW_GITIGNORE_HEADER, REDACTION_CATEGORIES, type RedactOptions, type RegistryEntry, type ReportMeta, type RiskRanking, type Route, type RouteDecision, type RoutingThresholds, SESSION_DIR_RE, SESSION_KINDS, SEVERITY_CRITERIA, type SafetyConfig, SafetyConfigSchema, type ScopeConfig, ScopeConfigSchema, type ScoreAnswer, type ScoreQuestion, type ScrubResult, type SessionKind, type SessionMetrics, SessionMetricsSchema, type SessionRow, type SeverityCounts, SeverityCountsSchema, type SeverityName, type SourceRepoConfig, SourceRepoConfigSchema, type SyncResult, type SystemOneRequest, type SystemOneResponse, type TargetConfig, TargetConfigSchema, type TriageAnswer, type TriageAnswers, TriageApiError, type TriageBlockInput, type TriageMode, TriageNotEnabledError, type TriageProvider, TriageProviderSchema, type TriageQuestion, type TriageResult, type TriageState, type TriageUsage, VERDICT_CRITERIA, type ValidationError, type ValidationResult, type VerificationConfig, VerificationConfigSchema, WebTargetConfigSchema, appendSessionMetrics, appendSessionMetricsDeduped, assertResponse, backoffMs, buildManifestRegistry, buildQuestionSet, buildTableRow, buildTriageState, callSystemOne, collectEvidence, combineRoutes, computeStats, containsSecrets, csvEscape, describeSessionDir, estimateCostUsd, extractCoverage, extractListSection, extractNumberedList, extractReportMeta, extractSection, fitStateToBudget, generateHtmlReport, generateJiraExport, generateJsonReport, generateMarkdownSummary, getPackageRoot, getPackageVersion, hasConfidentialityHeader, headersMatchColumns, isLoopbackEndpoint, judgeCommand, listReleaseDirs, loadFalsePositivePatterns, loadSessionForOutput, mergeGitignore, missingColumns, normaliseJudgeVerdict, normaliseSeverity, parseBugReport, parseClaimCard, parseMarkdownTable, parseSession, parseSessionDirName, parseSeverityField, parseTimeBox, parseVerdictBlock, readAllMetrics, readEnvVar, readSessionIndex, redact, renderTriageBlock, resolveDataDir, resolveDomainPath, resolveProviders, resolveSessionDir, resolveSkillsSource, resolveTargetPath, route, runExplore, runInit, runJudgeTriage, runKb, runKbDigest, runList, runReport, runValidate, scrubForTransmission, sessionDirName, sessionDirOfClaim, sessionTimestamp, slugify, syncKnowledgeManifest, toPredictedVerdict, validateAllConfigs, validateDomainConfig, validateKnowledgeBase, validateKnowledgeEntry, validateTargetConfig };