WEBVTT

1
00:00:00.000 --> 00:00:01.935
An agent is fixing a parser.

2
00:00:01.935 --> 00:00:06.356
The repository has an instruction file, and one rule in it says:

3
00:00:06.356 --> 00:00:09.811
do not change dependency files in a parser change.

4
00:00:10.150 --> 00:00:12.046
Suppose the agent is in a hurry.

5
00:00:12.046 --> 00:00:15.601
It stages the parser, and the lockfile with it, and commits.

6
00:00:15.950 --> 00:00:19.963
The rule was written down, and the commit went through anyway.

7
00:00:19.963 --> 00:00:24.041
So for every rule you write, ask: is this a request, or a gate?

8
00:00:25.082 --> 00:00:28.115
Start from a failure, then write the rule.

9
00:00:28.115 --> 00:00:31.798
"Be careful" is a request with no observable check.

10
00:00:31.798 --> 00:00:37.213
Write the rule as a sentence an agent can act on, and a person can inspect.

11
00:00:37.549 --> 00:00:41.665
A useful rule predicts a failure, and names evidence that can check it.

12
00:00:41.665 --> 00:00:45.433
The failure: a commit changes the lockfile while fixing a parser.

13
00:00:45.433 --> 00:00:48.274
The rule: no dependency files in a parser change.

14
00:00:48.274 --> 00:00:51.520
The evidence: the staged path list contains no lockfile.

15
00:00:51.866 --> 00:00:53.445
Two more from the notes.

16
00:00:53.445 --> 00:00:58.579
The command changes without its regression test; so for every behavior change,

17
00:00:58.579 --> 00:01:01.080
name the test that tells old from new.

18
00:01:01.080 --> 00:01:04.503
And a generated command writes outside the checkout;

19
00:01:04.503 --> 00:01:09.637
so stay below the repository root, and stop and ask when a path is outside it.

20
00:01:10.682 --> 00:01:14.761
Rules like these go in an instruction file at the repository root.

21
00:01:14.761 --> 00:01:19.272
A good entry names the scope, the allowed command, the expected evidence,

22
00:01:19.272 --> 00:01:20.693
and the stop condition.

23
00:01:21.032 --> 00:01:23.572
Now read it the way a hurried agent would.

24
00:01:23.572 --> 00:01:26.656
The request to run the parser tests can be skipped.

25
00:01:26.656 --> 00:01:29.257
The stop rule can be checked by a reviewer,

26
00:01:29.257 --> 00:01:32.643
but it is still an instruction until a gate enforces it.

27
00:01:32.982 --> 00:01:37.126
An instruction file gives context, and a decision procedure.

28
00:01:37.126 --> 00:01:41.753
By itself, it does not make the filesystem or Git refuse an action.

29
00:01:42.799 --> 00:01:47.607
A request is a message to the agent: run the focused test, and report the output.

30
00:01:47.607 --> 00:01:49.210
The agent may leave it out.

31
00:01:49.549 --> 00:01:54.212
A gate is attached to an event the repository controls: before a commit,

32
00:01:54.212 --> 00:01:57.385
refuse staged Python files with an unused import.

33
00:01:57.385 --> 00:02:01.400
Git invokes the hook, even when the agent forgets the request.

34
00:02:01.749 --> 00:02:04.061
So a hook is a narrow invariant.

35
00:02:04.061 --> 00:02:07.600
It is not a replacement for tests, or for review.

36
00:02:08.648 --> 00:02:11.154
The course hook is a short Python file.

37
00:02:11.154 --> 00:02:12.824
Read it before you use it.

38
00:02:12.824 --> 00:02:18.219
A small wrapper in the Git hooks folder hands it the staged path list, as one event.

39
00:02:18.565 --> 00:02:20.002
It checks two things.

40
00:02:20.002 --> 00:02:24.448
No protected file may be staged, and the lockfile is one of them.

41
00:02:24.448 --> 00:02:28.416
And no staged Python file may import a name it never uses.

42
00:02:28.765 --> 00:02:31.013
It reads and parses each file.

43
00:02:31.013 --> 00:02:33.186
It never imports or runs one.

44
00:02:33.186 --> 00:02:38.656
For a finding it exits with two, and for a clean list it exits with zero.

45
00:02:39.698 --> 00:02:44.047
Now try the gate, in a disposable copy of your repository,

46
00:02:44.047 --> 00:02:47.271
with no credentials or employer data in it.

47
00:02:47.271 --> 00:02:53.269
The generated proposal: add an import the file never uses, stage it, and commit.

48
00:02:53.615 --> 00:02:54.541
Predict first.

49
00:02:54.541 --> 00:02:58.706
The hook should stop this commit, because the import is unused.

50
00:02:59.048 --> 00:03:00.530
In our run, it does.

51
00:03:00.530 --> 00:03:05.938
The hook names the file, the line and the unused import, and prints stop.

52
00:03:05.938 --> 00:03:11.419
It exits with two, Git reports a nonzero status, and no commit is created.

53
00:03:11.765 --> 00:03:14.408
Save that output as your blocked record.

54
00:03:14.408 --> 00:03:16.720
And if the commit had gone through?

55
00:03:16.720 --> 00:03:19.033
Then stop, and inspect the wrapper.

56
00:03:19.033 --> 00:03:22.336
Do not rewrite the record to make it look blocked.

57
00:03:23.381 --> 00:03:24.151
Now verify.

58
00:03:24.151 --> 00:03:29.472
Read the hook's output, remove the import, stage the file again, and commit.

59
00:03:29.814 --> 00:03:33.167
This time the hook prints pass, and exits with zero.

60
00:03:33.167 --> 00:03:34.585
The commit is created.

61
00:03:34.931 --> 00:03:37.350
Save that as your passing record.

62
00:03:37.350 --> 00:03:42.262
Then ask Git to show the commit, to confirm which files entered it.

63
00:03:43.297 --> 00:03:46.372
Keep both records, and label what each one proves.

64
00:03:46.372 --> 00:03:50.923
The blocked run proves that Git presented these staged paths to this hook,

65
00:03:50.923 --> 00:03:53.628
and that the hook returned a nonzero status.

66
00:03:53.964 --> 00:03:56.380
That is evidence that the gate fired.

67
00:03:56.380 --> 00:03:59.775
It is not evidence that the final change is correct.

68
00:04:00.114 --> 00:04:05.958
The passing run proves only that this input satisfied the hook's narrow checks.

69
00:04:05.958 --> 00:04:09.435
The application's behavior is still unverified.

70
00:04:09.435 --> 00:04:13.725
So run the focused test, and inspect the diff, separately.

71
00:04:14.064 --> 00:04:17.841
A common mistake is to record only the passing commit.

72
00:04:17.841 --> 00:04:21.408
The first record shows the gate stopped that input.

73
00:04:21.408 --> 00:04:24.136
The second shows the clean path passed.

74
00:04:24.136 --> 00:04:24.835
Keep both.

75
00:04:25.881 --> 00:04:28.288
So where does that leave the instruction file?

76
00:04:28.288 --> 00:04:31.532
Treating an instruction as a permission boundary is a mistake.

77
00:04:31.881 --> 00:04:35.643
For an invariant, add a testable hook, or a human review step.

78
00:04:35.643 --> 00:04:38.132
And keep the request, for useful context.

79
00:04:39.181 --> 00:04:41.049
Here is our way to choose.

80
00:04:41.049 --> 00:04:45.072
For each rule, ask what happens when the agent skips it.

81
00:04:45.414 --> 00:04:47.795
If that is acceptable, leave it as a request.

82
00:04:47.795 --> 00:04:49.647
If it is not, give the rule a gate,

83
00:04:49.647 --> 00:04:52.345
and keep one blocked and one passing record for it.

84
00:04:53.381 --> 00:04:57.571
The same thinking applies when you hand work to a subagent.

85
00:04:57.571 --> 00:05:00.768
A role is more than a label such as reviewer.

86
00:05:00.768 --> 00:05:06.592
Give the subagent its own instruction, its own tools, and its own output contract.

87
00:05:06.931 --> 00:05:10.165
For a bounded parser change, the notes use three roles.

88
00:05:10.165 --> 00:05:14.223
A researcher locates the parser and its callers, and changes nothing.

89
00:05:14.223 --> 00:05:16.987
An implementer changes only the named function.

90
00:05:16.987 --> 00:05:21.222
A reviewer judges the issue, the diff and the evidence, without editing.

91
00:05:21.564 --> 00:05:26.176
After each hand-back, the parent agent, or a person, chooses whether to continue.

92
00:05:26.176 --> 00:05:30.275
The subagent cannot enlarge its allowlist, declare its own work correct,

93
00:05:30.275 --> 00:05:32.495
or silently replace a missing artifact.

94
00:05:33.531 --> 00:05:36.971
And a generated hand-back is still a proposal.

95
00:05:36.971 --> 00:05:39.663
Ask a researcher to find the parser.

96
00:05:39.663 --> 00:05:44.001
If the hand-back names no file and no function, reject it.

97
00:05:44.001 --> 00:05:47.142
Ask for the bounded report again, or stop.

98
00:05:47.481 --> 00:05:52.600
If it does name them, open every cited location, run the stated check,

99
00:05:52.600 --> 00:05:55.892
and record what the check does not establish.

100
00:05:56.231 --> 00:06:00.127
A hand-back is evidence only for the fields it names.

101
00:06:00.127 --> 00:06:03.875
Mark each claim confirmed, refuted, or cannot tell.

102
00:06:03.875 --> 00:06:06.522
An unsupported claim is cannot tell.

103
00:06:07.564 --> 00:06:10.157
Then pass on only what the next role needs.

104
00:06:10.157 --> 00:06:13.775
The implementer gets the research note, and the named files.

105
00:06:14.114 --> 00:06:19.084
The reviewer gets the issue, the diff and the test evidence, in a fresh context.

106
00:06:19.084 --> 00:06:23.805
So it can check the contract, instead of trusting the implementer's summary.

107
00:06:24.147 --> 00:06:27.306
A fresh context makes the contract visible.

108
00:06:27.306 --> 00:06:30.318
It does not make the reviewer infallible.

109
00:06:31.363 --> 00:06:34.742
So: write each rule from the failure it prevents.

110
00:06:34.742 --> 00:06:36.466
A request can be skipped.

111
00:06:36.466 --> 00:06:39.776
A gate sits on an event the repository controls,

112
00:06:39.776 --> 00:06:44.534
and you keep the record of it blocking, and the record of it passing.

113
00:06:44.880 --> 00:06:49.843
End your record with one decision line: accept, narrow, recheck or stop,

114
00:06:49.843 --> 00:06:51.566
with the evidence for it.

115
00:06:51.566 --> 00:06:56.047
A clean hook run can support accepting the staged-path invariant.

116
00:06:56.047 --> 00:07:00.045
It cannot support accepting untested application behavior.

117
00:07:00.045 --> 00:07:03.836
And bring the same instruction file, and the same gate,

118
00:07:03.836 --> 00:07:06.731
to your project's technical specification.

119
00:07:07.080 --> 00:07:08.542
One question to try.

120
00:07:08.542 --> 00:07:11.831
A hook prints a finding, but exits with zero.

121
00:07:11.831 --> 00:07:13.512
Did it gate the commit?

122
00:07:13.512 --> 00:07:15.851
And what observation settles it?
