starkernel: REPL scrollback, ~1000 lines (FABRIC.md item 4.4q)

Scope decided with Captain Bob before implementation: ring buffer +
recall on today's full-screen vt100 grid, not also confining REPL text
to the 4.4o 640x480 box (that confinement stays open as its own future
item, not a third silent deferral). No keyboard input path exists yet
(M8 unstarted), so the trigger is two new FORTH words, SCROLL-BACK
( n -- ) / SCROLL-FWD ( n -- ), exercised via serial injection.

vt100.c gains a text-only 1000-line ring buffer (kmalloc'd, tens of KB
-- not pixel snapshots, which would be ~1000x larger for no benefit)
plus a shadow buffer mirroring the current screen. scroll_up() now
pushes evicted rows into the ring before the pixel scroll. History is
one continuous sequence (ring then shadow); scrolling always redraws
from that sequence -- no separate pixel-scroll path for scrollback,
decided up front to avoid retrofitting later.

New src/word_source/scroll_words.c (Module 31), thin wrappers over
console_fb_scroll_back()/_fwd() -> vt100_scroll_back()/_fwd(). Bug
caught during live testing: both words initially used an off-by-one
underflow check (dsp < 1) copied from a different, older dsp
convention elsewhere in this codebase; vm_pop() (which these words
actually call) uses dsp as a 0-based top-of-stack index, so the check
rejected every legitimate single-argument call. Fixed by removing the
separate precheck and relying on vm_pop()'s own guard.

Live-verified on all three architectures (exceeds this item's
amd64-minimum bar): generated 50+ lines via a FORTH loop, confirmed
SCROLL-BACK recovers correctly older content, and on amd64 confirmed
SCROLL-FWD returns to genuinely live state (not a frozen snapshot) by
showing the injected commands' own echo. Known limitation confirmed by
direct pixel measurement: redrawn lines lose their original SGR color
(not stored per-cell) -- text recovers exactly, color does not.

Three-arch verified: Failed: 0, dict-hashes identical across all
three (values changed correctly from prior items -- two new words
were added).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-11 21:23:25 -04:00
co-authored by Claude Sonnet 5
parent 277845e3bf
commit 1f3ec3554e
27 changed files with 73487 additions and 112 deletions
+32 -32
View File
@@ -20,8 +20,8 @@ tick_number,elapsed_ns,tick_interval_ns,cache_hits_delta,bucket_hits_delta,word_
19,190000,10000,0,0,154,35,40,731,731,0,0,0,65536,0,0,65536,0,0
20,200000,10000,0,0,154,35,38,567,567,0,0,0,65536,0,0,65536,0,0
21,210000,10000,0,0,153,38,37,4096,0,0,0,0,65536,0,0,65536,0,0
22,220000,10000,0,0,167,38,38,582,582,0,0,0,65536,0,0,65536,0,0
23,230000,10000,0,0,176,12,40,685,685,0,0,0,65536,0,0,65536,0,0
22,220000,10000,0,0,167,39,38,582,582,0,0,0,65536,0,0,65536,0,0
23,230000,10000,0,0,176,14,39,685,685,0,0,0,65536,0,0,65536,0,0
24,240000,10000,0,0,175,10,25,731,731,0,0,0,65536,0,0,65536,0,0
25,250000,10000,0,0,196,11,23,731,731,0,0,0,65536,0,0,65536,0,0
26,260000,10000,0,0,192,14,24,4096,0,0,0,0,65536,0,0,65536,0,0
@@ -73,38 +73,38 @@ tick_number,elapsed_ns,tick_interval_ns,cache_hits_delta,bucket_hits_delta,word_
72,720000,10000,0,0,130,24,27,4096,1757,0,0,0,65536,0,0,65536,0,0
73,730000,10000,0,0,134,26,21,4096,1757,0,0,0,65536,0,0,65536,0,0
1,10000,18446744073708831616,0,0,117,4,4,4096,0,0,4895412794951728796,10,65536,0,0,65536,0,0
2,20000,10000,0,0,78,10,7,4096,0,0,0,12,65536,0,0,65536,0,0
2,20000,10000,0,0,78,10,7,4096,0,0,0,13,65536,0,0,65536,0,0
3,30000,10000,0,0,101,13,7,4096,0,0,0,15,65536,0,0,65536,0,0
4,40000,10000,0,0,63,19,8,4096,0,0,0,17,65536,0,0,65536,0,0
5,50000,10000,0,0,92,25,8,4096,2,0,0,21,65536,0,0,65536,0,0
6,60000,10000,0,0,64,27,8,4096,2,0,0,24,65536,0,0,65536,0,0
7,70000,10000,0,0,228,32,8,4096,210,0,0,69,65536,0,0,65536,0,0
8,80000,10000,0,0,256,34,9,4096,466,0,0,124,65536,0,0,65536,0,0
9,90000,10000,0,0,256,36,10,4096,722,0,0,178,65536,0,0,65536,0,0
10,100000,10000,0,0,256,36,11,4096,978,0,0,234,65536,0,0,65536,0,0
11,110000,10000,0,0,256,36,11,4096,1234,0,0,288,65536,0,0,65536,0,0
12,120000,10000,0,0,256,36,12,4096,1490,0,0,342,65536,0,0,65536,0,0
13,130000,10000,0,0,256,37,12,4096,1746,0,0,394,65536,0,0,65536,0,0
14,140000,10000,0,0,230,39,12,4096,1949,0,0,439,65536,0,0,65536,0,0
15,150000,10000,0,0,256,39,13,4096,2204,0,0,494,65536,0,0,65536,0,0
16,160000,10000,0,0,256,39,14,4096,2459,0,0,544,65536,0,0,65536,0,0
17,170000,10000,0,0,256,39,15,4096,2713,0,0,597,65536,0,0,65536,0,0
18,180000,10000,0,0,256,39,15,4096,2969,0,0,652,65536,0,0,65536,0,0
19,190000,10000,0,0,256,39,16,4096,3224,0,0,704,65536,0,1,65536,0,0
20,200000,10000,0,0,256,41,17,4096,3480,0,0,758,65536,0,1,65536,0,0
21,210000,10000,0,0,256,41,17,4096,3736,0,0,814,65536,0,1,65536,0,0
22,220000,10000,0,0,256,41,18,4096,3992,0,0,867,65536,0,1,65536,0,0
23,230000,10000,0,0,256,41,19,4096,4096,0,0,922,65536,0,1,65536,0,0
24,240000,10000,0,0,256,41,20,4096,4096,0,0,976,65536,0,1,65536,0,0
25,250000,10000,0,0,256,43,20,2048,2048,0,0,1031,65536,0,1,65536,0,0
26,260000,10000,0,0,256,45,21,2048,2048,0,0,1085,65536,0,1,65536,0,0
27,270000,10000,0,0,256,45,22,1024,1024,0,0,1140,65536,0,1,65536,0,0
28,280000,10000,0,0,256,45,23,1024,1024,0,0,1194,65536,0,1,65536,0,0
29,290000,10000,0,0,256,45,24,512,512,0,0,1250,65536,0,1,65536,0,0
30,300000,10000,0,0,256,45,24,512,512,0,0,1304,65536,0,1,65536,0,0
31,310000,10000,0,0,256,45,25,256,256,0,0,1359,65536,0,1,65536,0,0
32,320000,10000,0,0,255,45,26,256,256,0,0,1411,65536,0,1,65536,0,0
33,330000,10000,0,0,256,45,27,256,256,0,0,1467,65536,0,1,65536,0,0
34,340000,10000,0,0,256,45,27,256,256,0,0,1521,65536,0,1,65536,0,0
35,350000,10000,0,0,256,45,28,256,256,0,0,1573,65536,0,1,65536,0,0
36,360000,10000,0,0,256,45,29,256,256,0,0,1627,65536,0,1,65536,0,0
8,80000,10000,0,0,256,34,9,4096,466,0,0,126,65536,0,0,65536,0,0
9,90000,10000,0,0,256,36,10,4096,722,0,0,180,65536,0,0,65536,0,0
10,100000,10000,0,0,256,36,11,4096,978,0,0,233,65536,0,0,65536,0,0
11,110000,10000,0,0,256,36,11,4096,1234,0,0,290,65536,0,0,65536,0,0
12,120000,10000,0,0,256,36,12,4096,1490,0,0,346,65536,0,0,65536,0,0
13,130000,10000,0,0,256,37,12,4096,1746,0,0,398,65536,0,0,65536,0,0
14,140000,10000,0,0,230,39,12,4096,1949,0,0,442,65536,0,0,65536,0,0
15,150000,10000,0,0,256,39,13,4096,2204,0,0,499,65536,0,0,65536,0,0
16,160000,10000,0,0,256,39,14,4096,2459,0,0,554,65536,0,0,65536,0,0
17,170000,10000,0,0,256,39,15,4096,2713,0,0,611,65536,0,0,65536,0,0
18,180000,10000,0,0,256,39,15,4096,2969,0,0,664,65536,0,0,65536,0,0
19,190000,10000,0,0,256,39,16,4096,3224,0,0,718,65536,0,1,65536,0,0
20,200000,10000,0,0,256,41,17,4096,3480,0,0,771,65536,0,1,65536,0,0
21,210000,10000,0,0,256,41,17,4096,3736,0,0,824,65536,0,1,65536,0,0
22,220000,10000,0,0,256,41,18,4096,3992,0,0,881,65536,0,1,65536,0,0
23,230000,10000,0,0,256,41,19,4096,4096,0,0,932,65536,0,1,65536,0,0
24,240000,10000,0,0,256,41,20,4096,4096,0,0,987,65536,0,1,65536,0,0
25,250000,10000,0,0,256,43,20,2048,2048,0,0,1043,65536,0,1,65536,0,0
26,260000,10000,0,0,256,45,21,2048,2048,0,0,1097,65536,0,1,65536,0,0
27,270000,10000,0,0,256,45,22,1024,1024,0,0,1147,65536,0,1,65536,0,0
28,280000,10000,0,0,256,45,23,1024,1024,0,0,1201,65536,0,1,65536,0,0
29,290000,10000,0,0,256,45,24,512,512,0,0,1257,65536,0,1,65536,0,0
30,300000,10000,0,0,256,45,24,512,512,0,0,1313,65536,0,1,65536,0,0
31,310000,10000,0,0,256,45,25,256,256,0,0,1370,65536,0,1,65536,0,0
32,320000,10000,0,0,255,45,26,256,256,0,0,1425,65536,0,1,65536,0,0
33,330000,10000,0,0,256,45,27,256,256,0,0,1481,65536,0,1,65536,0,0
34,340000,10000,0,0,256,45,27,256,256,0,0,1536,65536,0,1,65536,0,0
35,350000,10000,0,0,256,45,28,256,256,0,0,1588,65536,0,1,65536,0,0
36,360000,10000,0,0,256,45,29,256,256,0,0,1644,65536,0,1,65536,0,0
1 tick_number elapsed_ns tick_interval_ns cache_hits_delta bucket_hits_delta word_executions_delta hot_word_count avg_word_heat_q48 window_width actual_window_size predicted_label_hits jitter_bits apic_ticks time_trust_q48 variance_q48 vm_call_depth_max hera_heat_q48 hermes_heat_q48 artemis_heat_q48
20 19 190000 10000 0 0 154 35 40 731 731 0 0 0 65536 0 0 65536 0 0
21 20 200000 10000 0 0 154 35 38 567 567 0 0 0 65536 0 0 65536 0 0
22 21 210000 10000 0 0 153 38 37 4096 0 0 0 0 65536 0 0 65536 0 0
23 22 220000 10000 0 0 167 38 39 38 582 582 0 0 0 65536 0 0 65536 0 0
24 23 230000 10000 0 0 176 12 14 40 39 685 685 0 0 0 65536 0 0 65536 0 0
25 24 240000 10000 0 0 175 10 25 731 731 0 0 0 65536 0 0 65536 0 0
26 25 250000 10000 0 0 196 11 23 731 731 0 0 0 65536 0 0 65536 0 0
27 26 260000 10000 0 0 192 14 24 4096 0 0 0 0 65536 0 0 65536 0 0
73 72 720000 10000 0 0 130 24 27 4096 1757 0 0 0 65536 0 0 65536 0 0
74 73 730000 10000 0 0 134 26 21 4096 1757 0 0 0 65536 0 0 65536 0 0
75 1 10000 18446744073708831616 0 0 117 4 4 4096 0 0 4895412794951728796 10 65536 0 0 65536 0 0
76 2 20000 10000 0 0 78 10 7 4096 0 0 0 12 13 65536 0 0 65536 0 0
77 3 30000 10000 0 0 101 13 7 4096 0 0 0 15 65536 0 0 65536 0 0
78 4 40000 10000 0 0 63 19 8 4096 0 0 0 17 65536 0 0 65536 0 0
79 5 50000 10000 0 0 92 25 8 4096 2 0 0 21 65536 0 0 65536 0 0
80 6 60000 10000 0 0 64 27 8 4096 2 0 0 24 65536 0 0 65536 0 0
81 7 70000 10000 0 0 228 32 8 4096 210 0 0 69 65536 0 0 65536 0 0
82 8 80000 10000 0 0 256 34 9 4096 466 0 0 124 126 65536 0 0 65536 0 0
83 9 90000 10000 0 0 256 36 10 4096 722 0 0 178 180 65536 0 0 65536 0 0
84 10 100000 10000 0 0 256 36 11 4096 978 0 0 234 233 65536 0 0 65536 0 0
85 11 110000 10000 0 0 256 36 11 4096 1234 0 0 288 290 65536 0 0 65536 0 0
86 12 120000 10000 0 0 256 36 12 4096 1490 0 0 342 346 65536 0 0 65536 0 0
87 13 130000 10000 0 0 256 37 12 4096 1746 0 0 394 398 65536 0 0 65536 0 0
88 14 140000 10000 0 0 230 39 12 4096 1949 0 0 439 442 65536 0 0 65536 0 0
89 15 150000 10000 0 0 256 39 13 4096 2204 0 0 494 499 65536 0 0 65536 0 0
90 16 160000 10000 0 0 256 39 14 4096 2459 0 0 544 554 65536 0 0 65536 0 0
91 17 170000 10000 0 0 256 39 15 4096 2713 0 0 597 611 65536 0 0 65536 0 0
92 18 180000 10000 0 0 256 39 15 4096 2969 0 0 652 664 65536 0 0 65536 0 0
93 19 190000 10000 0 0 256 39 16 4096 3224 0 0 704 718 65536 0 1 65536 0 0
94 20 200000 10000 0 0 256 41 17 4096 3480 0 0 758 771 65536 0 1 65536 0 0
95 21 210000 10000 0 0 256 41 17 4096 3736 0 0 814 824 65536 0 1 65536 0 0
96 22 220000 10000 0 0 256 41 18 4096 3992 0 0 867 881 65536 0 1 65536 0 0
97 23 230000 10000 0 0 256 41 19 4096 4096 0 0 922 932 65536 0 1 65536 0 0
98 24 240000 10000 0 0 256 41 20 4096 4096 0 0 976 987 65536 0 1 65536 0 0
99 25 250000 10000 0 0 256 43 20 2048 2048 0 0 1031 1043 65536 0 1 65536 0 0
100 26 260000 10000 0 0 256 45 21 2048 2048 0 0 1085 1097 65536 0 1 65536 0 0
101 27 270000 10000 0 0 256 45 22 1024 1024 0 0 1140 1147 65536 0 1 65536 0 0
102 28 280000 10000 0 0 256 45 23 1024 1024 0 0 1194 1201 65536 0 1 65536 0 0
103 29 290000 10000 0 0 256 45 24 512 512 0 0 1250 1257 65536 0 1 65536 0 0
104 30 300000 10000 0 0 256 45 24 512 512 0 0 1304 1313 65536 0 1 65536 0 0
105 31 310000 10000 0 0 256 45 25 256 256 0 0 1359 1370 65536 0 1 65536 0 0
106 32 320000 10000 0 0 255 45 26 256 256 0 0 1411 1425 65536 0 1 65536 0 0
107 33 330000 10000 0 0 256 45 27 256 256 0 0 1467 1481 65536 0 1 65536 0 0
108 34 340000 10000 0 0 256 45 27 256 256 0 0 1521 1536 65536 0 1 65536 0 0
109 35 350000 10000 0 0 256 45 28 256 256 0 0 1573 1588 65536 0 1 65536 0 0
110 36 360000 10000 0 0 256 45 29 256 256 0 0 1627 1644 65536 0 1 65536 0 0