Merge commit 'cd80745'
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 16:45:46 +01:00
3 changed files with 201 additions and 1 deletions
@@ -99,5 +99,42 @@ class PublicProfileContract(unittest.TestCase):
with self.assertRaises(GuardError):t.read(path,limit=1) with self.assertRaises(GuardError):t.read(path,limit=1)
class OriginalPartialDiagnosticContract(unittest.TestCase):
def test_closed_reader_cannot_publish_or_repair(self):
source=t.partial_reader()
self.assertIn('time-profile-'+t.PARTIAL_ID,source)
self.assertIn('time-attestation.candidate.json',source)
self.assertIn('old_move_hresult_unknown=$true',source)
for forbidden in ('[IO.File]::Move','Set-Acl','WriteBytes','WriteNew','Start-Service','Stop-Service','CreateDirectory'):
self.assertNotIn(forbidden,source)
def test_diagnostic_executes_bound_reader_without_legacy_load_or_target_success(self):
import datetime as dt
from unittest.mock import Mock
manifest={'id':t.PARTIAL_ID,'generator_sha256':t.PARTIAL_GENERATOR_SHA,
'script_sha256':t.PARTIAL_SCRIPT_SHA,'request':{'config_sha256':t.PARTIAL_CONFIG_SHA}}
result={'id':t.PARTIAL_ID,'read_only':True,'retry_authorized':False,
'installation_verified':False,'clock_runtime_qualified':False}
access=Mock();access.powershell.return_value=result
expiry=(dt.datetime.now(dt.timezone.utc)+dt.timedelta(hours=1)).isoformat()
with tempfile.TemporaryDirectory() as root,patch.object(t,'ROOT',Path(root)), \
patch.object(t,'read',side_effect=[(b'original',manifest),(b'staged',None)]), \
patch.object(t,'load_case',side_effect=AssertionError('original case must not adopt new generator')), \
patch.object(t.raw_capture,'CaptureAccess',return_value=access), \
patch.object(t.prior.cb.contract,'protected_json',return_value={'expires_at':expiry}):
t.diagnose_partial()
call=access.powershell.call_args
executed=base64.b64decode(call.args[1]['source_base64'])
self.assertIn(t.sha(executed),call.args[0])
cases=list((Path(root)/'devstate/windows-time-profile-diagnostics').iterdir())
self.assertEqual(len(cases),1)
intent=json.loads((cases[0]/'intent.json').read_bytes())
receipt=json.loads((cases[0]/'receipt.json').read_bytes())
self.assertEqual(intent['reader_sha256'],t.sha(executed))
self.assertEqual(receipt['reader_sha256'],t.sha(executed))
self.assertTrue(receipt['old_move_hresult_unknown'])
self.assertEqual((cases[0]/'reader.ps1').read_bytes(),executed)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
+83 -1
View File
@@ -524,8 +524,90 @@ def target(action,ident):
write(output,canonical(result)) write(output,canonical(result))
print(json.dumps({'id':ident,'action':action,'reply_sha256':sha(canonical(result)),'clock_runtime_qualified':False})) print(json.dumps({'id':ident,'action':action,'reply_sha256':sha(canonical(result)),'clock_runtime_qualified':False}))
# Dedicated read-only path for the already attempted original case. It never
# passes through load_case(): changing the generator must not rewrite or adopt
# the original staged controller/intent hash binding.
PARTIAL_ID = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'
PARTIAL_MANIFEST_SHA = '0c9a3ffeed490757f7bd8c63d7e2ec28156212945094621f511e20679ce0b3b0'
PARTIAL_GENERATOR_SHA = 'a8d55b60d413c1d68f568c173e6ea32727cef8645e61eb772d24f98e22b0b10a'
PARTIAL_SCRIPT_SHA = 'd8b4fd4fd9ca5310cc1591ce3c2ccae5bd72a2ade43b21a8187cfdfb960b3427'
PARTIAL_CONFIG_SHA = '2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'
PARTIAL_CASE = ROOT.parent/'rust-discovery-agent-updater'/'devstate/windows-time-profile-config'/PARTIAL_ID
def partial_reader():
"""Fixed file/ACL/marker observation only; no service or publication code."""
require(sha(Path(prior.__file__).read_bytes())=='e466576673a0e5c332cfc1613ae88a62f5b526015ced76b1d22473e292a995e0'
and sha(Path(prior.u.__file__).read_bytes())=='f8dc1c8fbc064e253b1fbe130fb628afef58cf45c2bafb6837d6716125b42d38',
'exact original metadata-only primitive sources')
source = prior.u.SCRIPT
functions = []
for name in ('Check','BytesHash','Hash','AclHash','CheckControl'):
start=source.index('function '+name+'(');end=source.find('\nfunction ',start+1)
require(end>start,'closed original read-only function');functions.append(source[start:end])
native=prior.NATIVE.split('function FileIdentity(',1)[0]
identity='function FileIdentity('+prior.NATIVE.split('function FileIdentity(',1)[1].split('function Kernel(',1)[0]
header=r'''$ErrorActionPreference='Stop';$inputRecord=$global:RmmPartialReaderInput
if((($inputRecord.PSObject.Properties.Name|Sort-Object)-join',')-cne'kind'-or$inputRecord.kind-cne'original-public-time-profile-ad9-readonly'){throw 'Fixed original partial profile observation'}
$sys='S-1-5-18';$admin='S-1-5-32-544';$agentSid=(New-Object Security.Principal.NTAccount('NT SERVICE','RmmDiscoveryWindows')).Translate([Security.Principal.SecurityIdentifier]).Value;$helperSid=(New-Object Security.Principal.NTAccount('NT SERVICE','RmmDiscoverySystemHelper')).Translate([Security.Principal.SecurityIdentifier]).Value
$folder='C:\ProgramData\RustDiscoveryBootstrap\time-profile-ad9fd154-b2be-4f5d-9e17-65abb721ceaf';$root='C:\ProgramData\RustDiscoverySystem';$active='C:\ProgramData\RustDiscoveryBootstrap\time-profile-initial-active.json'
'''
body=r'''function ErrorNumber($errorRecord){$ex=$errorRecord.Exception.GetBaseException();$h=[int64]$ex.HResult-band0xffffffffL;$win32=$null;if(($h-band0xffff0000L)-eq0x80070000L){$win32=$h-band0xffffL};return @{exception_type=$ex.GetType().FullName;hresult_hex=('0x{0:x8}'-f$h);win32_code=$win32}}
function ObservePublic($path){
if(!(Test-Path -LiteralPath $path)){return @{present=$false}}
try{Check $path $false;$item=Get-Item -LiteralPath $path -Force;if($item.Length-gt16384){throw 'Bounded public profile only'};$identity=FileIdentity $path;return @{present=$true;identity=$identity;attributes=[int64]$item.Attributes;creation_filetime=$item.CreationTimeUtc.ToFileTimeUtc().ToString();last_write_filetime=$item.LastWriteTimeUtc.ToFileTimeUtc().ToString();expected_hash=($identity.sha256-ceq'2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b')}}catch{return @{present=$true;observation_failed=$true;error=(ErrorNumber $_)}}
}
CheckControl $folder $true;Check $root $true
$records=[ordered]@{};foreach($name in @('intent.json','directory-acl-intent.json','directory-acl-done.json','publish-intent.json','publish-failure.json','result.json')){$path=Join-Path $folder $name;if(!(Test-Path -LiteralPath $path)){$records[$name]=@{present=$false};continue};CheckControl $path $false;$item=Get-Item -LiteralPath $path -Force;if($item.Length-gt2097152){throw 'Bounded original marker'};$value=Get-Content -LiteralPath $path -Raw|ConvertFrom-Json
$record=@{present=$true;sha256=(Hash $path);bytes=$item.Length}
if($name-ceq'intent.json'){if($value.id-cne'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'-or$value.request.config_sha256-cne'2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'-or$value.request.script_sha256-cne'd8b4fd4fd9ca5310cc1591ce3c2ccae5bd72a2ade43b21a8187cfdfb960b3427'){throw 'Original intent binding'};$record.install_not_before=$value.install_not_before;$record.no_retry=$value.no_retry}
if($name-ceq'publish-intent.json'){if($value.config_sha256-cne'2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'-or$value.create_once-ne$true){throw 'Original publication binding'};$record.staged=$value.staged}
if($name-ceq'directory-acl-intent.json'){$record.old_sddl=$value.old_sddl};if($name-ceq'directory-acl-done.json'){$record.sddl=$value.sddl}
if($name-ceq'publish-failure.json'){$record.failure=@{exception_type=$value.exception_type;hresult_hex=$value.hresult_hex;win32_code=$value.win32_code}}
$records[$name]=$record
}
$activeRecord=@{present=$false};if(Test-Path -LiteralPath $active){CheckControl $active $false;if((Get-Item -LiteralPath $active).Length-gt8192){throw 'Bounded active original marker'};$a=Get-Content -LiteralPath $active -Raw|ConvertFrom-Json;if($a.id-cne'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'-or$a.config_sha256-cne'2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'-or$a.script_sha256-cne'd8b4fd4fd9ca5310cc1591ce3c2ccae5bd72a2ade43b21a8187cfdfb960b3427'){throw 'Original active binding'};$activeRecord=@{present=$true;sha256=(Hash $active);id=$a.id;config_sha256=$a.config_sha256;script_sha256=$a.script_sha256}}
@{id='ad9fd154-b2be-4f5d-9e17-65abb721ceaf';read_only=$true;candidate=(ObservePublic (Join-Path $folder 'time-attestation.candidate.json'));target=(ObservePublic (Join-Path $root 'time-attestation.json'));records=$records;active=$activeRecord;root_sddl=(Get-Acl -LiteralPath $root).Sddl;old_move_hresult_unknown=$true;retry_authorized=$false;installation_verified=$false;clock_runtime_qualified=$false;private_key_read=$false;service_action=$false}|ConvertTo-Json -Depth 20 -Compress
'''
reader=header+'\n'+'\n'.join(functions)+'\n'+native+identity+'\n'+body
require(all(token not in reader for token in ('[IO.File]::Move','Set-Acl','WriteBytes','WriteNew','Start-Service','Stop-Service','CreateDirectory','function State','function Probe')),'read-only original partial observer')
return reader
def diagnose_partial():
# Only a future explicitly authorized maintenance window may call this.
# The original install/read code and original markers stay untouched.
import datetime as dt
import subprocess
raw,manifest=read(PARTIAL_CASE/'manifest.json',PARTIAL_MANIFEST_SHA)
require(manifest['id']==PARTIAL_ID and manifest['generator_sha256']==PARTIAL_GENERATOR_SHA
and manifest['script_sha256']==PARTIAL_SCRIPT_SHA
and manifest['request']['config_sha256']==PARTIAL_CONFIG_SHA,'fixed original failed installation only')
read(PARTIAL_CASE/'InstallPublicTimeProfile.ps1',PARTIAL_SCRIPT_SHA,decode=False)
access=raw_capture.CaptureAccess(MAIN)
grant=prior.cb.contract.protected_json(MAIN/'credentials/windows-dev-access.json')
expiry=dt.datetime.fromisoformat(grant['expires_at'].replace('Z','+00:00'))
require((expiry-dt.datetime.now(dt.timezone.utc)).total_seconds()>=60,'current confirmed access window required for read')
source=partial_reader();digest=sha(source.encode());root=ROOT/'devstate/windows-time-profile-diagnostics';root.mkdir(mode=0o700,parents=True,exist_ok=True)
folder=root/str(uuid.uuid4());folder.mkdir(mode=0o700)
write(folder/'intent.json',canonical({'id':folder.name,'original_case':PARTIAL_ID,'original_manifest_sha256':PARTIAL_MANIFEST_SHA,'reader_sha256':digest,'read_only':True,'no_retry':True}))
# A small launcher avoids Windows' command-line limit. The source hash is
# generated from this closed reader, never accepted from a caller.
launcher=r'''$ErrorActionPreference='Stop';$q=([Console]::In.ReadLine()|ConvertFrom-Json);$raw=[Convert]::FromBase64String($q.source_base64);$h=[Security.Cryptography.SHA256]::Create();try{$s=([BitConverter]::ToString($h.ComputeHash($raw))).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()};if($s-cne'READER_SHA'){throw 'Exact original partial reader'};$global:RmmPartialReaderInput=$q.input_record;&([scriptblock]::Create([Text.Encoding]::UTF8.GetString($raw)))'''.replace('READER_SHA',digest)
write(folder/'reader.ps1',source.encode())
try:result=access.powershell(launcher,{'source_base64':base64.b64encode(source.encode()).decode(),'input_record':{'kind':'original-public-time-profile-ad9-readonly'}},timeout=45)
except subprocess.TimeoutExpired:
write(folder/'timeout.json',canonical({'read_only':True,'timeout_seconds':45,'old_move_hresult_unknown':True}));raise RuntimeError('original diagnostic read timed out; no publication attempted') from None
write(folder/'reply.json',canonical(result))
require(result['id']==PARTIAL_ID and result['read_only'] is True and result['retry_authorized'] is False
and result['installation_verified'] is False and result['clock_runtime_qualified'] is False,'diagnostic observation is no installation success or authority')
write(folder/'receipt.json',canonical({'id':folder.name,'original_case':PARTIAL_ID,'reader_sha256':digest,'original_manifest_sha256':PARTIAL_MANIFEST_SHA,'reply_sha256':sha(canonical(result)),'read_only':True,'old_move_hresult_unknown':True}))
print(json.dumps({'id':folder.name,'original_case':PARTIAL_ID,'read_only':True,'receipt_sha256':sha((folder/'receipt.json').read_bytes())}))
if __name__=='__main__': if __name__=='__main__':
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('action',choices=('guards','prepare','stage','install','read'));parser.add_argument('--case');arguments=parser.parse_args() parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('action',choices=('guards','prepare','stage','install','read','diagnose-partial'));parser.add_argument('--case');arguments=parser.parse_args()
if arguments.action=='guards': guards();print('PASS closed public-profile source guards; no target action') if arguments.action=='guards': guards();print('PASS closed public-profile source guards; no target action')
elif arguments.action=='prepare': prepare() elif arguments.action=='prepare': prepare()
elif arguments.action=='diagnose-partial':
require(arguments.case is None,'diagnostic is fixed to the original ad9 case');diagnose_partial()
else: target(arguments.action,arguments.case) else: target(arguments.action,arguments.case)
+81
View File
@@ -179,3 +179,84 @@ anschließend frische Heartbeats/ACKs sowie echte signierte Zeitbelege bleiben
getrennt zu prüfen. Eine spätere Fortsetzung benötigt zuerst eine lesende getrennt zu prüfen. Eine spätere Fortsetzung benötigt zuerst eine lesende
Ursachenklärung und einen konkret geprüften Vertrag für den ursprünglichen Ursachenklärung und einen konkret geprüften Vertrag für den ursprünglichen
Teilfall; ein neuer Fall darf diesen Marker nicht umgehen. Teilfall; ein neuer Fall darf diesen Marker nicht umgehen.
## Unabhängiger lokaler Review des Move-Fehlers und fester Diagnosepfad
Der nachfolgende Review liest ausschließlich Quellen und vorhandene öffentliche
Originalbelege auf dem Entwicklungsrechner. Kein Gast-/Serverzugriff, keine
Installation, kein Retry und keine Freigabe wurden dabei ausgeführt.
Belegt ist der Ablauf bis zum Publish-Intent mit Kandidathash
`2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b`,
1177Bytes, Volume9815088561147542064 und FileID6d990300000003000000000000000000.
Der spätere originale Read93143fc0… belegt das fehlende Ziel und fehlendes Resultat.
Er fragt jedoch die Kandidatdatei selbst nicht ab. Ihr aktueller Bestand ist
somit **nicht** nachgewiesen. Original-rootSDDL im Intent, ACL-done-SDDL und spätere
rootSDDL sind bytegleich: die ACL-Phase wurde ausgeführt, ohne effektive Rechte
zu ändern. Bestehende NoRetry-Marker bleiben bestehen.
Die genaue Ursache der IOException ist mit diesen Belegen nicht bestimmbar.
Der alte Fehlerbeleg enthält weder HRESULT noch nativen Fehlercode. Die statisch
geprüften WriteBytes-, FileIdentity- und FileVolume-Handles werden in `finally`
geschlossen; ein eigener Handleleak ist daraus nicht belegt. Das rechtfertigt
weder eine Sharing-Lockerung noch Dienststopp, ACL-Änderung, Antivirusausnahme,
Copy/Delete-Fallback oder erneuten Move. Microsoft beschreibt für
[File.Move](https://learn.microsoft.com/en-us/dotnet/api/system.io.file.move)
mehrere IOException-Ursachen; die Regeln für vorhandene Handles stehen getrennt
in [CreateFile](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
Sharing, Defender oder ein konkreter Win32-Code bleiben hier ausdrücklich
Hypothesen. Der ursprüngliche HRESULT darf aus späteren Lesefehlern nicht
rückwirkend abgeleitet werden.
Der bestehende Pythonoperator hat deshalb einen **separaten, ausschließlich
lesenden** Originalfallpfad `diagnose-partial` erhalten. Er bindet ausschließlich
Fallad9fd154-b2be-4f5d-9e17-65abb721ceaf, dessen Manifest0c9a3ffe…,
Originalgeneratora8d55b60…, Originalcontrollerd8b4fd4f… und Konfigurationshash2b4a….
Die vorhandenen Marker und Originaldateien werden nicht geändert. `load_case`
wird absichtlich nicht verwendet: dessen Generatorbindung darf nicht auf die
neue Quelle umgedeutet werden. Ebenso wird keine neue Skript-SHA als ursprüngliche
`request.script_sha256` ausgegeben. Der neue Reader hat eine eigene Source-SHA,
die der kleine In-Memory-Launcher vor der Ausführung prüft; genau ausgeführte
Readerbytes, Intent, rohe Antwort und separater Receipt werden ausschließlich
in einem neuen lokalen700/600-Diagnosefall gespeichert.
Geplanter Aufruf, **hier nicht ausgeführt**, erst nach erneut ausdrücklich
bestätigtem Zugang und dessen erfolgreichem Readback:
```sh
python3 /home/kevin/Schreibtisch/Coding/rust-discovery-signed-clock/deploy/windows/time_profile_config.py diagnose-partial
```
Kein `--case`: der Reader akzeptiert keine andere Fall-ID oder frei wählbare
Pfade. Die lokalen Originalbelege liegen weiterhin im Agent-Updater-Worktree.
Die geschützte aktuelle Zugangskonfiguration muss noch mindestens60s zulassen;
sonst erfolgt kein SSHaufruf. Native PowerShell-AST-/VM-Ausführung dieses neuen
Readers sind noch offen. Er enthält keine Publish-/ACL-/Serviceoperation und
fragt weder Uhrqualität noch Dienst-Snapshot ab.
Der Reader liefert nur aktuelle Kandidat-/Zielidentität, Größe, Hash, DACLhash,
Attribute und Zeiten sowie feste Originalmarker/active-Bindung und Root-SDDL.
Aktuelle Lesefehler werden mit Exceptiontyp/HRESULT und nur bei passender
HRESULT-Facility mit Win32-Code aufgezeichnet, ohne freien Fehlertext. Diese
Nummern gehören ausschließlich zum **neuen Leseversuch**. Er setzt immer
`old_move_hresult_unknown=true`, `retry_authorized=false`,
`installation_verified=false` und `clock_runtime_qualified=false`.
Das Ergebnis ist Grundlage einer späteren Entscheidung, keine Retryerlaubnis:
- Kandidat unverändert und Ziel fehlt: Veröffentlichung weiterhin nicht erfolgt;
im nächsten aktiven Wartungsfenster anhand des Originalzustands mit einem
überprüften Finalisierungsbefehl fertigstellen. Das MVP-/Profilvorhaben ist
bereits beauftragt; dafür keine pauschale zusätzliche Chatgenehmigung verlangen.
- Ziel vorhanden: weder Move noch Install erneut aufrufen; zuerst Ziel-/Kandidat-
FileID-/Hash-/ACLbindung und tatsächliche Laufzeitwirkung getrennt beurteilen.
- Fehlender/veränderter Kandidat, widersprüchliche Marker, andere Dateiidentität
oder Lesefehler: Teilzustand erhalten, keine automatische Rekonstruktion,
Löschung oder Rechte-/Dienständerung.
Lokal tatsächlich bestanden: Pythoncompile, bestehende Sourceguards und acht
Vertragsfälle, davon zwei neue für den geschlossenen Reader und seine exakte
Source-/Intent-/Receiptbindung ohne Legacy-Hashadoption. Der Transport ist dabei
vollständig gemockt; dies ist kein nativer Befund. Die Kontrollbelege des alten
fehlgeschlagenen Installationsfalls bleiben bytegleich erhalten. Ein konkreter
Publikationsfix wurde mangels belegter nativer Fehlerursache nicht erfunden.