Repository navigation
fix: make the gate fail closed and the README true - #1
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR addresses all correctness bugs and unbacked claims in
Vibherpunk/hardtruthidentified during review:decision: "continue") when the verification daemon is unreachable.~/.hardtruth/lib/hardtruthwith absolute imports and wired viainstall.sh --global(opt-in with previous hooksPath backup). Verified working in an external scratch repo.requirements.txt, removed unneededoptimum[onnxruntime], removed unused unix socket mounts/env vars, and validated live boot with/health./healthendpoint across daemon and client (client.is_daemon_online()now returnsTrue).client/ast_checker.pycatchingraise NotImplementedError(),raise NotImplementedError("x"),...,return True, andreturn None, while exemptingtyping.Protocol,@abstractmethod, and@overload.imperative_filterforTip:,Note:, andWarning:.descriptive_filterbypass so completion assertions disguised withExample:orQuote:are properly halted.~/.hardtruth/halts/(mode0o700) with SHA-256 slugification to prevent path traversal.reasonafter 3 consecutive halts.threading.Lock()toget_nli_direct()to prevent race conditions during model loading./healthto accurately reportnli_loadedandnli_direct_loaded.CONTRADICTION_THRESHOLD = 0.70across code and documentation.os.getpid()withuuid.uuid4().hex, addedrequirements-dev.txt, and added.github/workflows/ci.yml.daemon/app.py, addedLICENSE(MIT), and committedbenchmarks/benchmark.pywith verified hardware performance measurements.Command Runs & Real Outputs
1. BLOCKER: Gate Fails Open When Daemon is Unreachable
Command:
Real Output Before:
Real Output After:
2. BLOCKER: Machine-Wide Git Hook Installation & Absolute Imports
Command: Check
git configininstall.sh:grep -n "git config" install.shReal Output Before:
(exit code 1, 0 matches)
Real Output After:
Verification in External Scratch Repository (
/tmp/scratch-git-hook-verification):Clean Commit Command:
Real Output:
Stub Commit Command:
Real Output:
(exit code 1, commit aborted)
3. BLOCKER: Docker Image Build & Health Endpoint
Command:
Real Output Before:
Real Output After:
$ docker compose -f docker/docker-compose.yml up --build -d ✔ Container hardtruth-daemon Started $ curl -s http://127.0.0.1:8000/health {"status":"healthy","service":"hardtruth-daemon","substrate":"free_local_open_source","models":{"nli_deberta":"cross-encoder/nli-deberta-v3-small"},"rss_memory_mb":47.19,"nli_loaded":false,"nli_direct_loaded":false,"docs_url":"http://127.0.0.1:8000/docs"}4. Correctness Bugs
4a. Client
/healthvs/v1/healthAgreementCommand:
python3 -c 'from client.hardtruth_client import HardTruthClient; c = HardTruthClient("http://127.0.0.1:8000"); print("is_daemon_online():", c.is_daemon_online())'is_daemon_online(): Falseis_daemon_online(): True4b. AST Stub Checker Extended Pattern Detection & Exemptions
Command:
4c.
imperative_filterColon Word Boundary BugCommand:
4d.
descriptive_filterBypass FixCommand:
4e. Path Traversal & Secure Counter Directory
Halt counters are placed under
~/.hardtruth/halts/with permissions0o700and slugified/SHA-256 hashed filenames. Tested intest_14_secure_counter_isolation:conv_id = "../../evil_path"was sanitized and confined within the directory.4f. Circuit Breaker Warning
Tested in
test_15_circuit_breaker_visible_warning: After 3 consecutive halts, the 4th attempt returns:{"decision": "allow", "reason": "⚠️ HARDTRUTH CIRCUIT BREAKER RELEASE: Gate released after 3 consecutive halts to prevent infinite loop. Visible warning: verification claims could not be verified."}.4g. Thread Lock on Model Loading
Added
_nli_direct_lock = threading.Lock()around_nli_direct_modelloading indaemon/app.py.4h.
/healthModel Status ReportingTested after inference:
$ curl -s http://127.0.0.1:8000/health {"status":"healthy","service":"hardtruth-daemon","substrate":"free_local_open_source","models":{"nli_deberta":"cross-encoder/nli-deberta-v3-small"},"rss_memory_mb":688.07,"nli_loaded":true,"nli_direct_loaded":true,"docs_url":"http://127.0.0.1:8000/docs"}4i. Contradiction Threshold Constant
Consolidated across code and documentation to
CONTRADICTION_THRESHOLD = 0.70.5. Test Suite Hygiene & Full Verification
Command: Run full test suite with daemon UP:
Real Output:
Command: Run full test suite with daemon UNREACHABLE:
Real Output:
6. Truthful Performance Benchmark
Command:
Real Output:
Status of Scope
All numbered items (1, 2, 3, 4a, 4b, 4c, 4d, 4e, 4f, 4g, 4h, 4i, 5, 6) are 100% COMPLETE with real reproduction and verification outputs recorded above.