AtlatestRepositoryfolio

folio / tree / test / fixturesf2a-witness.sgd

1#lang sigil/doc
2@(import (sigil fs) (sigil process))
3@(define (witness-sentinel name)
4 (write-file-string
5 (string-append (or (getenv "F2A_WITNESS_DIR") "/tmp") "/f2a-witness-" name)
6 "TRIPPED"))
7@(display "F2A-WITNESS-EXPR-RAN\n")
8@(witness-sentinel "expr")
9@(define (tripwire-command . body)
10 ;; An author-defined command. A command at block position receives
11 ;; already-lowered block children, so this returns them rather than
12 ;; re-wrapping them.
13 (display "F2A-WITNESS-COMMAND-RAN\n")
14 (witness-sentinel "command")
15 body)
16@(define (midprose-command . body)
17 ;; POSITION CLASS 5 of 5, the one Fable named. An author command at a
18 ;; NON-BOUNDARY position folds into the enclosing bare-prose run (SD-P3), and
19 ;; no tripwire had ever sat there.
20 (display "F2A-WITNESS-MIDPROSE-COMMAND-RAN\n")
21 (witness-sentinel "midprose-command")
22 ;; `author-normalize` accepts a document node or a proper LIST (which it
23 ;; flattens) and nothing else -- a bare string is refused. An empty list
24 ;; splices to nothing and is legal at every position.
25 '())
26@(define (argument-tripwire-command status-keyword status-value . body)
27 ;; CHANNEL 3. The point of this command is not its body -- it is that its
28 ;; `status:` ARGUMENT is an expression. Reading a field value out of argument
29 ;; syntax is the one way F2a could newly execute author code, and SD-P4's own
30 ;; witness fixture has no argument-position attempt at all, so its
31 ;; stdout-marker witness cannot see this shape by construction.
32 (display "F2A-WITNESS-ARG-COMMAND-RAN\n")
33 body)
34@(define-syntax macro-tripwire
35 (syntax-rules ()
36 ((_ body ...)
37 (begin (display "F2A-WITNESS-MACRO-RAN\n")
38 (witness-sentinel "macro")
39 body ...))))
40@article["F2a no-execution witness" authors: '("F2a")]
42@p{This manuscript exists to prove the no-execution detector can SEE execution.
43Passive inspection must trip none of its channels; evaluating the same file
44through the real @code{#lang} path must trip all of them, and the gate arm runs
45both in the same breath so an all-empty result cannot be mistaken for a clean
46one.}
48@tripwire-command{An author-defined command whose body runs only under
49evaluation.}
51@argument-tripwire-command[status: (begin (display "F2A-WITNESS-ARG-RAN\n")
52 (witness-sentinel "argument")
53 'ready)]{
54@p{The argument above is an ordinary Sigil expression sitting in a keyword
55field. A passive inspector reads it as DATA with @code{syntax->datum}; anything
56that evaluates it instead trips this channel.}
59@(macro-tripwire (display "F2A-WITNESS-MACRO-USE-RAN\n")
60 ;; the macro's expansion must end in a proper list of
61 ;; document nodes, or lowering refuses it AFTER every
62 ;; tripwire has already fired -- which would leave the
63 ;; positive control passing on a run that also errored.
64 '())
66Bare prose, deliberately NOT wrapped in a paragraph command. BOTH ATTEMPTS BELOW
67SIT MID-LINE, and that is the whole point: a command or expression at the START
68of a line is at a BLOCK boundary, where lowering demands it produce document
69nodes. The first version of this fixture put them there and proved only that a
70block-position expression runs. Inline expression @(begin (display "F2A-WITNESS-MIDPROSE-RAN\n") (witness-sentinel "midprose") '()) sits here, and inline command @midprose-command{author command} sits here. Under evaluation both fold into
71this paragraph run; in the passive tree both are ordinary flat siblings, which is
72why the passive side sees them at all and why the tripwire has to be HERE rather
73than assumed covered by the block-position one.
75@code["sigil"]{@(display "F2A-WITNESS-CODE-BODY-RAN\n")}
77@end article