src/guards
Module summary
Module src/guards
Exports
| Name | Kind | Default |
|---|---|---|
DOC_RATIO_THRESHOLD | variable | no |
HallucinationGuardError | class | no |
SNAPSHOT_UPDATE_SIGNAL | variable | no |
SOURCE_RATIO_THRESHOLD | variable | no |
checkHallucination | function | no |
main | function | no |
Detail
DOC_RATIO_THRESHOLD
DOC_RATIO_THRESHOLDParams
None.
Returns
None.
Examples
None.
HallucinationGuardError
HallucinationGuardErrorParams
None.
Returns
None.
Examples
None.
SNAPSHOT_UPDATE_SIGNAL
SNAPSHOT_UPDATE_SIGNALParams
None.
Returns
None.
Examples
None.
SOURCE_RATIO_THRESHOLD
SOURCE_RATIO_THRESHOLDParams
None.
Returns
None.
Examples
None.
checkHallucination
checkHallucination(opts): objectRun the hallucination guard for one doc/source pair.
Decision table:
- doc-ratio > 0.20 AND source-ratio < 0.05 -> BLOCK, unless the
[snapshot-update]signal is present, in which case the doc change is accepted and the golden snapshot is refreshed. - any other combination -> PASS. When the doc differs from its golden snapshot and the signal is present, the snapshot is refreshed.
Params
opts = {}
Returns
object
Examples
None.
main
main(argv, io): numberCLI entrypoint. Returns the process exit code instead of calling
process.exit so it stays unit-testable.
node hallucination_guard.js
—doc
[—repo-dir
Exit codes: 0 = pass, 1 = blocked (hallucination), 2 = usage / runtime error.
Params
argv = process.argv.slice(2)io = {}
Returns
number
Examples
None.