[CLAUDE] Docs: S151 closeout — bootstrap + trio-AUTO đầu tiên + gói 3-máy vá sống + bookend DEEP trả nợ JUMP (tally #53=53, AS-17 promote)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m38s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-07-25 20:13:25 +07:00
parent 398d343403
commit 1b85713bb6
54 changed files with 2422 additions and 95 deletions

View File

@ -352,7 +352,15 @@ if ($null -eq $maxGotcha -or $gotchaAnchors.Count -eq 0) {
}
else {
# Match "gotcha #N", "gotcha N", and bare "#N" tokens.
$refRx = '(?:gotcha[s]?\s*#?(\d+))|(?<![A-Za-z0-9])#(\d+)'
# S151 fix (FP #111, H1 F-6 + ring1 confirm): the word-branch used to swallow
# "gotchas 111.616B" (a BYTE-SIZE, thousands-separator) and flag a phantom #111.
# Guard: the digits must NOT be followed by a decimal/thousands separator + digit
# (111.616 / 111,616) nor glued to a letter (111B) - real refs ("#57", "gotcha 81-EXT",
# "gotcha 57,") are unaffected. Word-boundary before 'gotcha' kills mid-word hits.
# (?!\d) pins the capture to the FULL digit-run first - without it the engine
# backtracks THROUGH the guard ("gotchas 111.616B" -> retries as "11" and matches
# a phantom #11; caught by fault-inject S151). Then the separator guard applies.
$refRx = '(?:\bgotcha[s]?\s*#?(\d+)(?!\d)(?![.,]\d|[A-Za-z]))|(?<![A-Za-z0-9])#(\d+)'
foreach ($f in $GovMd) {
$lines = Get-Content -Path $f.FullName -Encoding UTF8
for ($i = 0; $i -lt $lines.Count; $i++) {
@ -872,7 +880,16 @@ if (-not (Test-Path $handoffPath)) {
else {
$raw = Get-Content -Path $handoffPath -Raw -Encoding UTF8
# "NEXT anh" / "NEXT em" are pure ASCII (no diacritics) -> safe as a literal here.
$marks = [regex]::Matches($raw, 'NEXT\s+(?:anh|em)')
# S151 fix (lead-gap FLAG-1 HIGH, ring2 re-implemented + confirmed): the unanchored
# literal cut a segment at EVERY occurrence of the phrase - including MID-PROSE
# mentions (HANDOFF item (20) contains "NEXT anh #11" inside a sentence), which
# split the current segment so carryLines[0] shared nothing with carryLines[1] and
# every streak broke at 1 => the carry-age net went silent while printing [ok].
# Anchor to REAL segment headers only: line-start bold "**NEXT anh/em" with an
# optional emoji marker (e.g. the red dot). The marker is matched as "any run of
# non-ASCII chars" [^\x00-\x7F]+ so this .ps1 source stays pure-ASCII (gotcha #30)
# and survives a future marker-emoji change; \xNN is interpreted by .NET at match time.
$marks = [regex]::Matches($raw, '(?m)^\*\*(?:[^\x00-\x7F]+\s*)?NEXT\s+(?:anh|em)\b')
$segs = @()
for ($i = 0; $i -lt $marks.Count; $i++) {
$start = $marks[$i].Index

View File

@ -98,6 +98,22 @@ function Replace-LineOnce([string]$text, [string]$pattern, [string]$newLine, [st
return $rx.Replace($text, $ev, 1)
}
# Style-preserving field replace (fix S151 format-fork): the S150 signal-write re-serialized
# this file via ConvertTo-Json (BOM + CRLF + two-space after colon), so the fixed-string
# replacer above stopped matching (0 match => exit 7 every session after every bookend).
# This variant's pattern carries TWO capture groups (prefix)(suffix); the matched prefix and
# suffix are kept verbatim, so whichever spacing/EOL shape the file has SURVIVES the write.
# Same exactly-one-match fail-loud as Replace-LineOnce (shape-drift still refuses to write).
function Replace-FieldOnce([string]$text, [string]$pattern, [string]$valueLiteral, [string]$what) {
$rx = New-Object System.Text.RegularExpressions.Regex($pattern, [System.Text.RegularExpressions.RegexOptions]::Multiline)
$n = $rx.Matches($text).Count
if ($n -ne 1) {
Fail-Loud "surgical replace '$what' expected exactly 1 match, found $n - counter-file shape drift; refusing to write." 7
}
$ev = [System.Text.RegularExpressions.MatchEvaluator]({ param($m) $m.Groups[1].Value + $valueLiteral + $m.Groups[2].Value }.GetNewClosure())
return $rx.Replace($text, $ev, 1)
}
function Json-Escape([string]$s) {
# Minimal JSON string escaping. Event text is authored quote/backslash-free, but stay safe.
$s = $s -replace '\\', '\\'
@ -210,25 +226,33 @@ else {
}
$eventJson = Json-Escape $event
# ---- surgical edits on the raw text (preserve formatting / emoji / LF byte-exact) ----
# ---- surgical edits on the raw text (style-preserving: tolerate BOTH the original
# ---- surgical shape (LF / one-space) AND the ConvertTo-Json shape (CRLF / two-space) ----
$new = $rawText
$new = Replace-LineOnce $new '^ "counter": \d+,$' (' "counter": ' + $newCounter + ',') 'counter'
$new = Replace-LineOnce $new '^ "last_ticked_session": "[^"]*",$' (' "last_ticked_session": "' + $Session + '",') 'last_ticked_session'
$new = Replace-LineOnce $new '^ "last_ticked_head": "[^"]*",$' (' "last_ticked_head": "' + $headSha + '",') 'last_ticked_head'
$new = Replace-LineOnce $new '^ "last_ticked_at": "[^"]*",$' (' "last_ticked_at": "' + $tickDate + '",') 'last_ticked_at'
$new = Replace-FieldOnce $new '^(\s{4}"counter":\s+)\d+(,\r?)$' ("$newCounter") 'counter'
$new = Replace-FieldOnce $new '^(\s{4}"last_ticked_session":\s+")[^"]*(",\r?)$' $Session 'last_ticked_session'
$new = Replace-FieldOnce $new '^(\s{4}"last_ticked_head":\s+")[^"]*(",\r?)$' $headSha 'last_ticked_head'
$new = Replace-FieldOnce $new '^(\s{4}"last_ticked_at":\s+")[^"]*(",\r?)$' $tickDate 'last_ticked_at'
# ---- append ONE history entry: insert before the array close (anchored at EOF, exactly once) ----
$entry = " {`n" +
" `"at`": `"$tickDate`",`n" +
" `"session`": `"$Session`",`n" +
" `"event`": `"$eventJson`"`n" +
" }"
$histRx = New-Object System.Text.RegularExpressions.Regex('(\n \})(\n \]\n\}\n?)$', [System.Text.RegularExpressions.RegexOptions]::Singleline)
# ---- append ONE history entry: insert before the array close (anchored at EOF, exactly once).
# Shape-tolerant (fix S151 format-fork): match ANY indent + CRLF-or-LF at EOF; the inserted
# entry reuses the file's own EOL and the LAST entry's own indent, so both shapes stay intact.
$histRx = New-Object System.Text.RegularExpressions.Regex('(\r?\n)([ \t]+)\}([ \t]*)(\r?\n[ \t]*\][ \t]*\r?\n\}[ \t]*\r?\n?)$', [System.Text.RegularExpressions.RegexOptions]::Singleline)
$histN = $histRx.Matches($new).Count
if ($histN -ne 1) {
Fail-Loud "history array-close anchor expected exactly 1 match at EOF, found $histN - counter-file shape drift; refusing to write." 7
}
$histEv = [System.Text.RegularExpressions.MatchEvaluator]({ param($m) $m.Groups[1].Value + ",`n" + $entry + $m.Groups[2].Value }.GetNewClosure())
$histEv = [System.Text.RegularExpressions.MatchEvaluator]({ param($m)
$eol = $m.Groups[1].Value
$ind = $m.Groups[2].Value # indent of the LAST entry's closing brace
$fld = $ind + ' ' # field indent = one level deeper
$entry = $ind + '{' + $eol +
$fld + '"at": "' + $tickDate + '",' + $eol +
$fld + '"session": "' + $Session + '",' + $eol +
$fld + '"event": "' + $eventJson + '"' + $eol +
$ind + '}'
$m.Groups[1].Value + $m.Groups[2].Value + '}' + $m.Groups[3].Value + ',' + $eol + $entry + $m.Groups[4].Value
}.GetNewClosure())
$new = $histRx.Replace($new, $histEv, 1)
# ---- validate the result is still parseable BEFORE we touch disk ----

View File

@ -32,8 +32,9 @@
promise the next spawn stays on the expected version. This is exactly why H23 section 2(4)
makes it informational, not enforcement.
(ii) PRECEDENCE vs a frontmatter HARD-PIN - MEASURED at SE 2026-07-16 (S126), after S124
re-pinned all 14 agents THEN-EXISTING to 'model: opus' (ALIAS pin; roster is 17 as of
S141 - this measurement was taken when N was 14 and was NOT re-run for the 3 new ones):
re-pinned all 14 agents THEN-EXISTING to 'model: opus' (ALIAS pin; roster is 20 as of
S145 - measurement taken when N was 14; NOT re-run for the 6 added since = 3 trio S141
+ 3 ring S145. Count fixed S151 per H1 F-5 - the old note said "3 new ones"):
spawn param 'fable' on agentType
reviewer (pin 'opus') RESOLVED claude-fable-5 (run wf_f960dae2-fa0, 3 records); a
control lane with NO override resolved claude-opus-4-8 under lead=Fable => the pin