WEBVTT

1
00:00:00.000 --> 00:00:02.519
We have a capstone contract
that can be checked.

2
00:00:02.798 --> 00:00:06.617
Now we will implement it in small
slices and review the resulting changes.

3
00:00:07.000 --> 00:00:10.065
Start from your preserved
checkpoint-eight baseline and the plan

4
00:00:10.135 --> 00:00:11.377
from the previous lesson.

5
00:00:11.818 --> 00:00:15.243
The final checkpoint-nine solution
is available for reference,

6
00:00:15.568 --> 00:00:18.680
but your task is to understand
and verify the change

7
00:00:18.924 --> 00:00:21.385
rather than simply copy
a finished directory.

8
00:00:21.989 --> 00:00:25.831
Begin with shared policy. Add the
alert state, default threshold,

9
00:00:25.855 --> 00:00:29.465
and hysteresis constant where
the policy owns configuration.

10
00:00:29.907 --> 00:00:32.205
Preserve the existing missing, nonfinite,

11
00:00:32.229 --> 00:00:34.771
and stale checks before
accepting a sample.

12
00:00:35.212 --> 00:00:37.198
Preserve the two-sample recovery gate.

13
00:00:37.581 --> 00:00:40.889
New functionality should fit around
those established rules instead

14
00:00:40.924 --> 00:00:43.815
of replacing them with one
broad temperature comparison.

15
00:00:44.418 --> 00:00:46.682
Read the three state paths separately.

16
00:00:47.008 --> 00:00:51.640
In fault, a first fresh valid sample
stays in fault with a recovering error,

17
00:00:51.849 --> 00:00:55.506
while the second permits classification
against the entry threshold.

18
00:00:55.889 --> 00:00:58.884
In alert, compare against
the lower clearing boundary.

19
00:00:59.326 --> 00:01:01.903
In normal, compare against
the entry threshold.

20
00:01:02.286 --> 00:01:06.001
The ordering carries the history
that makes hysteresis meaningful.

21
00:01:06.512 --> 00:01:09.925
Flattening the branches can
accidentally erase that behavior.

22
00:01:10.366 --> 00:01:13.292
Implement the demonstrated
equality case first.

23
00:01:13.536 --> 00:01:16.880
Establish normal with two fresh
readings below the threshold,

24
00:01:17.089 --> 00:01:21.315
then supply exactly twenty-eight
degrees. The expected state is alert.

25
00:01:21.593 --> 00:01:24.089
Add a companion case
just below the boundary.

26
00:01:24.414 --> 00:01:28.606
Review the source and assertion together,
but derive the expected outcome

27
00:01:28.641 --> 00:01:33.064
from the written requirement rather than
copying the implementation's operator.

28
00:01:33.505 --> 00:01:36.640
Now complete clearing
equality and band retention.

29
00:01:37.023 --> 00:01:41.678
From alert, twenty-seven clears;
twenty-seven point five retains alert.

30
00:01:42.062 --> 00:01:45.533
From normal, twenty-seven
point five retains normal.

31
00:01:45.916 --> 00:01:48.981
Include boundary jitter
and recovery after a fault.

32
00:01:49.364 --> 00:01:52.569
The recovered state should use
the fresh entry threshold, not

33
00:01:52.615 --> 00:01:54.844
the alert state remembered
before the fault.

34
00:01:55.285 --> 00:01:59.674
Keep injected timestamps ordered so
the test asks the intended question.

35
00:01:59.999 --> 00:02:04.085
Add a validated threshold setter.
It must reject nonfinite

36
00:02:04.120 --> 00:02:07.801
and out-of-range values before
changing stored configuration.

37
00:02:08.184 --> 00:02:12.003
A valid value re-evaluates a
current non-faulted reading,

38
00:02:12.177 --> 00:02:16.369
but it cannot clear fault or count
toward recovery. Inspect the callers

39
00:02:16.416 --> 00:02:20.026
to ensure time is polled before
the setting uses a cached reading.

40
00:02:20.409 --> 00:02:24.380
Local correctness is not enough
if integration ignores freshness.

41
00:02:24.821 --> 00:02:29.675
Next, build the command collector. It
stores a bounded line until line feed.

42
00:02:30.000 --> 00:02:34.110
The optional final carriage return
belongs to the allowed byte count.

43
00:02:34.435 --> 00:02:36.246
Once the line exceeds the limit,

44
00:02:36.455 --> 00:02:39.764
drain input to the next line
feed and report too long.

45
00:02:40.147 --> 00:02:43.537
Do not reinterpret the remaining
tail as a second command.

46
00:02:43.862 --> 00:02:48.505
Reset the collector at the boundary so
the next valid line can be processed.

47
00:02:48.947 --> 00:02:52.000
Validate the entire number
grammar before conversion.

48
00:02:52.383 --> 00:02:56.331
The command threshold twenty-eight
followed by junk must be rejected,

49
00:02:56.714 --> 00:03:00.592
even if a standard conversion routine
returns twenty-eight from its prefix.

50
00:03:00.917 --> 00:03:03.657
Check the optional sign,
required integer digits,

51
00:03:03.773 --> 00:03:05.828
optional fraction, and end of token.

52
00:03:06.153 --> 00:03:10.286
If a decimal point is present, at least
one fractional digit must follow it.

53
00:03:10.727 --> 00:03:14.257
Reject extra whitespace,
exponents, nonfinite words,

54
00:03:14.338 --> 00:03:16.962
and trailing characters
according to the contract.

55
00:03:17.287 --> 00:03:20.886
Validate the wider numeric
value before narrowing to float.

56
00:03:21.211 --> 00:03:23.638
A value just above the maximum must not

57
00:03:23.708 --> 00:03:26.238
round into the permitted
range during conversion.

58
00:03:26.564 --> 00:03:31.115
This is a useful example of why parsing
and policy checks need to agree.

59
00:03:31.394 --> 00:03:34.459
Test range endpoints
and values outside them,

60
00:03:34.668 --> 00:03:39.509
and verify that every rejected command
leaves the previous threshold intact.

61
00:03:39.892 --> 00:03:42.179
Handle partial lines deliberately.

62
00:03:42.504 --> 00:03:47.508
At host end-of-input, a partial command
returns truncated and changes nothing.

63
00:03:47.949 --> 00:03:51.026
Firmware waits for line feed
without blocking its loop.

64
00:03:51.351 --> 00:03:55.287
The project does not invent a serial
timeout or a persistence feature.

65
00:03:55.728 --> 00:03:59.188
Keep work per loop bounded so
command processing does not

66
00:03:59.234 --> 00:04:03.169
consume the whole iteration before
acquisition can be considered.

67
00:04:03.494 --> 00:04:06.176
Integrate the parser
into both build paths.

68
00:04:06.501 --> 00:04:09.868
The host and firmware must
compile the same shared policy,

69
00:04:10.042 --> 00:04:13.897
parser, and output files.
Update the maintained source

70
00:04:13.943 --> 00:04:17.844
lists and adapters rather than
creating a test-only parser.

71
00:04:18.169 --> 00:04:22.372
Add alert formatting and threshold
configuration output while preserving

72
00:04:22.419 --> 00:04:26.645
the synthetic label. Unavailable
temperatures remain JSON null,

73
00:04:26.819 --> 00:04:30.650
and recovering values retain their
distinct current-but-fault meaning.

74
00:04:31.091 --> 00:04:33.332
Run appropriate checks after each slice.

75
00:04:33.657 --> 00:04:36.780
A small policy change needs
its relevant assertions;

76
00:04:37.105 --> 00:04:40.820
adapter integration needs
replay and firmware compilation.

77
00:04:41.203 --> 00:04:45.731
If a command fails, preserve the result
and investigate the demonstrated cause.

78
00:04:46.172 --> 00:04:48.819
Do not continue stacking
new features on a baseline

79
00:04:48.842 --> 00:04:50.863
whose state you no longer understand.

80
00:04:51.374 --> 00:04:54.950
The final integrated run comes
after the last relevant change.

81
00:04:55.553 --> 00:04:58.572
Review the diff with the bounded
firmware-review procedure.

82
00:04:59.083 --> 00:05:02.810
Findings should name a trigger,
consequence, and supporting evidence.

83
00:05:03.320 --> 00:05:07.546
Reject unrelated redesign that makes
the capstone harder to inspect.

84
00:05:07.930 --> 00:05:10.507
A clean slice does not
need invented defects,

85
00:05:10.751 --> 00:05:13.317
but missing verification
should remain visible.

86
00:05:13.700 --> 00:05:19.098
Keep review and repair as distinct actions
when the task requested inspection only.

87
00:05:19.702 --> 00:05:22.419
Review output-buffer
handling during integration.

88
00:05:22.663 --> 00:05:25.577
The formatter reports whether
a complete record fits;

89
00:05:25.855 --> 00:05:30.174
callers must not present an incomplete
JSON fragment as a valid record.

90
00:05:30.557 --> 00:05:34.168
Existing small-buffer tests
provide a useful regression case.

91
00:05:34.493 --> 00:05:38.045
Keep the stable field meanings and
unavailable-value representation

92
00:05:38.138 --> 00:05:41.772
intact while adding the new
alert and configuration output,

93
00:05:41.981 --> 00:05:45.429
so consumers can distinguish data
state from formatting failure.

94
00:05:45.871 --> 00:05:48.901
Your exercise is to complete
the four planned slices

95
00:05:48.959 --> 00:05:51.443
with coherent commits or reviewed diffs.

96
00:05:51.884 --> 00:05:56.110
Submit the requirement-to-change map,
source, tests, and actual receipts.

97
00:05:56.493 --> 00:05:59.628
Demonstrate inclusive entry
first, then finish clearing,

98
00:05:59.675 --> 00:06:02.147
parser, integration,
and regression checks.

99
00:06:02.658 --> 00:06:05.329
If a generated patch
expands beyond the request,

100
00:06:05.607 --> 00:06:08.800
preserve useful work and narrow
the change before proceeding.

101
00:06:09.241 --> 00:06:11.981
Pause here to implement and
inspect your own version.

102
00:06:12.364 --> 00:06:15.592
Use the reference solution to
answer a specific uncertainty

103
00:06:15.870 --> 00:06:19.284
after attempting the task, and
compare behavior rather than

104
00:06:19.353 --> 00:06:23.521
formatting. If your implementation takes
a different clear approach while meeting

105
00:06:23.568 --> 00:06:27.561
the same contract and evidence
requirements, that can be a valid result.

106
00:06:28.258 --> 00:06:31.114
Explain the choices so a
reviewer can assess them.

107
00:06:31.497 --> 00:06:34.760
The outcome of this lesson is
a reviewable implementation,

108
00:06:35.085 --> 00:06:38.161
not yet a finished release.
In the next lesson,

109
00:06:38.208 --> 00:06:42.608
we will exercise the complete behavior,
prove meaningful defect rejection,

110
00:06:42.782 --> 00:06:45.360
and reproduce the candidate
from a fresh checkout.

111
00:06:45.743 --> 00:06:49.400
Keeping that boundary visible
prevents a convincing patch from being

112
00:06:49.446 --> 00:06:53.638
mistaken for verified delivery
before the required evidence exists.
