AtlatestRepositoryfolio
1
;;; f3b-corrupt-temp-driver.sgl -- construct the UNPROVABLE recovery state2
;;; (a validated manifest whose staged temp was corrupted after the crash)3
;;; and prove the next transaction REFUSES TO A HUMAN and touches nothing.4
;;; Used by gate-f3b.sh arm 5; sabotage-f3b.sh's recovery-tolerates plant5
;;; makes this driver's refusal vanish, which is that leg's red.6
(import (sigil core) (sigil io) (sigil fs) (sigil string) (sigil path)7
(folio doc revision) (folio doc bounded) (folio doc service)8
(folio doc manifest) (folio doc coordinator) (folio doc transaction)9
(folio doc structural))10
(define root (or (getenv "F3B_ROOT") (begin (println "DRIVER ERROR no root") (exit 3))))11
(define lib-dir (or (getenv "F3B_LIB") "build/dev/lib"))12
(define src-dir (or (getenv "F3B_SRC") "src"))13
(define (rooted n) (path-join root n))15
(define target (rooted "ref-one.sgd"))16
(define pre-rev (revision-of-file target))17
(define good-post (string-replace (read-file-string target) "one site" "one FINISHED site"))18
(define temp ".folio-staging-ref-one.sgd.corrupt")19
(define backup ".folio-backup-ref-one.sgd.corrupt")20
(write-file-string (rooted temp) good-post)21
(write-file-bytes (rooted backup) (read-file-bytes target))22
(define post-rev (revision-of-file (rooted temp)))23
(write-transaction-manifest! root "corrupttest" "probe-op"24
(list (mentry "ref-one.sgd" pre-rev temp post-rev post-rev backup pre-rev)))25
;; NOW corrupt the temp -- the state recovery cannot prove safe to finish.26
(write-file-string (rooted temp) "garbage that matches no recorded hash")28
(define coord (make-coordinator root29
(make-service (default-worker-argv lib-dir src-dir)30
default-limits)))31
(define raised32
(guard (e (#t (if (exception? e) (exception-message e) "raised")))33
(folio-insert-node! coord (rooted "dest.sgd") "incoming" 'update34
(revision-of-file (rooted "dest.sgd"))35
timestamp: "2026-08-25" id: "u-corrupt")36
#f))37
(cond38
((and (string? raised)39
(string-contains? raised "human")40
(equal? (revision-of-file target) pre-rev)41
(file-exists? (rooted ".folio-transaction-manifest")))42
(println "CORRUPT_TEMP_REFUSED_TO_HUMAN"))43
((string? raised)44
(println "RAISED_BUT_WRONG_SHAPE: ~a (target-moved=~a manifest-gone=~a)"45
raised46
(not (equal? (revision-of-file target) pre-rev))47
(not (file-exists? (rooted ".folio-transaction-manifest")))))48
(else49
(println "PROCEEDED_OVER_UNPROVABLE_STATE (target-rev=~a)"50
(revision-of-file target))))