Skip to content

Commit 76fa5c6

Browse files
KSemenenkoclaude
andcommitted
Stop hashing and re-verifying ZoneTree-owned full-text files
ZoneTree owns the bytes of a text generation's runtime files and rewrites its own index1/0.json metadata on a clean reopen (ZoneTree issue 209). KeyLoad SHA256-hashed every engine file, compared the hashes and lengths on each acquisition, and re-verified them on every selected-text search, so reopened generations were refused as "The execution text projection is corrupt." - TextFile records only the owned relative path and its publication length. The SHA256 field, TextDigest and the HashBufferBytes option are deleted. - Inventory verification at publication, settlement and cleanup checks the owned file set only, never file content or length. - A selected-text search and a repeated generation acquisition no longer enumerate or re-read generation files. - The tests' retained-file oracles check the owned file set. The manifest-damage case changes a recorded path instead of a digest. - The coverage inventory drops four cases removed in the previous checkpoint and refreshes the changed source hashes. - The full-text docs and ADR-078 describe engine-owned files. Verification (local, Debug, macOS arm64): - dotnet build KeyLoad.slnx -warnaserror: 0 warnings, 0 errors. - dotnet format --verify-no-changes and the governance script pass. - FunctionalTests.Search: 375 of 377. The two failures were the old length oracle, which now passes: TextCapturedPublicOperationTests and TextProviderAuditTests pass 12 of 12. - RequestCqrsTextMaintenanceTests, the text incremental and online process recovery cases and ConnectionCloseAdmissionTests pass 19 of 19. - Cluster tests were not run locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 190ff88 commit 76fa5c6

17 files changed

Lines changed: 56 additions & 246 deletions

File tree

‎docs/ADR/ADR-078-full-text-projection.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ manifest binds the exact scope and ordered identity/revision metadata, format1,
118118
tokenizer/hash versions and completed source cut. Its generated contracts
119119
use stable aliases/IDs and an SHA256 payload checksum; no internal JSON fallback.
120120
Manifest Id5 adds a bounded ordered file inventory. Each generated
121-
`keyload.server.text.file` record fixes Id0 normalized relative path,
122-
Id1 byte length and Id2 SHA256. Capture actual files after synchronous
123-
flush and handle settlement before complete publication; no static guessed
124-
filename allowlist is used. Restart validates the exact bounded regular
125-
path/length/digest inventory before cleanup. Reopening a completed generation
121+
`keyload.server.text.file` record fixes Id0 normalized relative path and
122+
Id1 byte length at publication. ZoneTree owns the content of these files and
123+
rewrites its own metadata, so KeyLoad records and checks the owned file set,
124+
never file content. Capture actual files after synchronous flush and handle
125+
settlement before complete publication; no static guessed filename allowlist
126+
is used. Restart validates the exact owned path inventory before cleanup.
127+
Searches do not re-enumerate or re-read generation files. Reopening a completed generation
126128
must preserve or atomically refresh its recognized inventory at settlement.
127129
An owner receipt alone cannot authorize arbitrary recursive deletion. A completed
128130
generation requires both an exact tracked layout and a verified closed inventory.

‎docs/Features/Search/FullTextProjection.md‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,14 @@ and producer-settlement observations while their signed child identity is bound.
9191
The original child Task and observations join before identity, cancellation and
9292
owned payload cleanup; observation failures preserve the original operation failure.
9393

94-
## Open selected-generation qualification
95-
96-
The current embedded selected-generation flow fails its second lookup after a
97-
successful first lookup. A bounded before/after inventory observed a change only
98-
to the native `execution/index1/0.json` metadata file. The protected physical
99-
inventory then refuses the changed digest. This also reproduces without Orleans;
100-
it is not evidence of corrupted document or posting data.
101-
102-
[ZoneTree issue 209](https://github.com/ZoneTree/ZoneTree/issues/209) retains the
103-
published package/source identity, original operation flow and the clean-reopen
104-
metadata rewrite attribution. The existing integrity assertions remain active.
94+
## Engine-owned generation files
95+
96+
ZoneTree owns the bytes of a generation's runtime files. A clean reopen rewrites
97+
the native `execution/index1/0.json` metadata file
98+
([ZoneTree issue 209](https://github.com/ZoneTree/ZoneTree/issues/209) tracks the
99+
unconditional rewrite as a performance issue). KeyLoad therefore records only the
100+
owned relative paths and publication lengths. It validates the owned path set at
101+
publication, settlement and cleanup, and never hashes or compares file content.
102+
A search acquires a published generation without re-enumerating its files.
105103
Selected-generation recovery, release and performance qualification remain open;
106104
the issue report is not a delivered repair.

‎scripts/Features/CodeQuality/functional-coverage.unit-test-inventory.json‎

Lines changed: 24 additions & 107 deletions
Large diffs are not rendered by default.

‎src/KeyLoad/Search/Admission/TextSelectedSourceAdmission.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ internal static (string Leaf, TextIncrementalManifest Manifest) Capture(Database
5454
new(selection.Consumer, selection.Generation, request.Collection, request.TextField!, node, enrollment.Placement), budget);
5555
TextIncrementalSourceValidation.Authority(manifest, maintenance, source, budget);
5656
TextIncrementalSourceValidation.CompleteCorpus(manifest, source, budget);
57-
var owner = TextOwnerFiles.ReadOwner(Path.Combine(generationPath, TextProtocol.OwnerFile),
58-
root, selected, node, options);
59-
TextInventory.Verify(generationPath, owner.OwnedPaths, manifest.Files, options, budget);
6057
budget.Check();
6158
return (selected, manifest);
6259
}

‎src/KeyLoad/Search/Configuration/TextExecutionOptions.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ internal sealed class TextExecutionOptions
1313
private const int MaximumDepthCeiling = 8;
1414
private const long MaximumDiskByteCeiling = 268_435_456;
1515
private const int MaximumMutableSegmentItemCeiling = 4_096;
16-
private const int MaximumHashBufferByteCeiling = 65_536;
1716
private const int MaximumFileBufferByteCeiling = 4_096;
1817
private const int MaximumGenerationCeiling = 3;
1918
private const int MaximumOwnerReceiptByteCeiling = 65_536;
@@ -24,7 +23,6 @@ internal sealed class TextExecutionOptions
2423
public int MaximumDepth { get; set; } = MaximumDepthCeiling;
2524
public long MaximumDiskBytes { get; set; } = MaximumDiskByteCeiling;
2625
public int MutableSegmentMaximumItems { get; set; } = MaximumMutableSegmentItemCeiling;
27-
public int HashBufferBytes { get; set; } = MaximumHashBufferByteCeiling;
2826
public int FileBufferBytes { get; set; } = MaximumFileBufferByteCeiling;
2927
public int MaximumGenerations { get; set; } = MaximumGenerationCeiling;
3028
public int MaximumOwnerReceiptBytes { get; set; } = MaximumOwnerReceiptByteCeiling;
@@ -36,7 +34,6 @@ internal bool IsValid() => MaximumFiles is >= 1 and <= MaximumFileCeiling
3634
&& MaximumDepth is >= 1 and <= MaximumDepthCeiling
3735
&& MaximumDiskBytes is >= 1 and <= MaximumDiskByteCeiling
3836
&& MutableSegmentMaximumItems is >= 1 and <= MaximumMutableSegmentItemCeiling
39-
&& HashBufferBytes is >= 1 and <= MaximumHashBufferByteCeiling
4037
&& FileBufferBytes is >= 1 and <= MaximumFileBufferByteCeiling
4138
&& MaximumGenerations is >= 1 and <= MaximumGenerationCeiling
4239
&& MaximumOwnerReceiptBytes is >= 1 and <= MaximumOwnerReceiptByteCeiling

‎src/KeyLoad/Search/Serialization/FullText/TextDigest.cs‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎src/KeyLoad/Search/Serialization/FullText/TextFile.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ namespace KeyLoad.Server.Search;
44
[global::Orleans.Alias(TextProtocol.FileAlias)]
55
internal sealed record TextFile(
66
[property: global::Orleans.Id(0)] string RelativePath,
7-
[property: global::Orleans.Id(1)] long Length,
8-
[property: global::Orleans.Id(2)] byte[] Sha256);
7+
[property: global::Orleans.Id(1)] long Length);

‎src/KeyLoad/Search/Storage/FullText/Generations/TextGeneration.cs‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ internal sealed class TextGeneration
1515
internal TextResourceOwnership? Resources => resources;
1616
private List<TextRecord>? pendingRecords = [];
1717
private TextRecord[]? sealedRecords;
18-
private TextFile[]? openedFiles;
1918
private HashSet<EntityRef>? references = [];
2019

2120
internal TextGeneration(string root, string leaf, Guid sourceNodeId, TextProjectionScope scope, TextFileStreamProvider provider, IOptions<TextExecutionOptions> executionOptions, TextResourceOwnership? resources = null)
@@ -126,7 +125,6 @@ private void CloseIndex()
126125
if (failures.Count == failuresBeforeDispose)
127126
{
128127
CurrentIndex = null;
129-
openedFiles = null;
130128
}
131129
ServerFailureObserver.ThrowIfAny(failures);
132130
}
@@ -149,10 +147,6 @@ internal void OpenIndex(ReadExecutionBudget budget)
149147
budget.Check();
150148
if (CurrentIndex is not null)
151149
{
152-
TextLiveGenerationMetadata.Validate(this, Path, root, Leaf, sourceNodeId, executionOptions);
153-
var liveOwner = TextFiles.ReadOwnerForProvider(root, Leaf, sourceNodeId, executionOptions);
154-
TextInventory.Verify(Path, liveOwner.OwnedPaths, openedFiles ?? throw TextErrors.Corrupt(),
155-
executionOptions, budget);
156150
return;
157151
}
158152
var manifest = TextFiles.ValidatePublishedGeneration(root, Leaf, sourceNodeId, Scope, budget, executionOptions: executionOptions);
@@ -166,8 +160,6 @@ internal void OpenIndex(ReadExecutionBudget budget)
166160
resources: resources, allowReadOnlyInventory: true), executionOptions: executionOptions);
167161
CurrentIndex.IsReadOnly = true;
168162
CurrentIndex.WaitForBackgroundThreads();
169-
var owner = TextFiles.ReadOwnerForProvider(root, Leaf, sourceNodeId, executionOptions);
170-
openedFiles = TextInventory.Capture(Path, owner.OwnedPaths, executionOptions, budget);
171163
}
172164

173165
internal void MarkPublished()
@@ -185,7 +177,5 @@ internal void DisposeIndex()
185177
}
186178
current.Dispose();
187179
CurrentIndex = null;
188-
openedFiles = null;
189180
}
190-
191181
}

‎src/KeyLoad/Search/Validation/FullText/Live/TextLiveManifest.cs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ internal static bool Matches(TextGeneration generation, TextManifest manifest, R
2828
budget?.Check();
2929
var expected = files[index];
3030
var actual = manifest.Files[index];
31-
if (!StringComparer.Ordinal.Equals(expected.RelativePath, actual.RelativePath)
32-
|| expected.Length != actual.Length || expected.Sha256 is null || actual.Sha256 is null
33-
|| !System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(expected.Sha256, actual.Sha256))
31+
if (!StringComparer.Ordinal.Equals(expected.RelativePath, actual.RelativePath))
3432
{
3533
return false;
3634
}

‎src/KeyLoad/Search/Validation/FullText/TextInventory.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Security.Cryptography;
21
using KeyLoad.Core;
32
using Microsoft.Extensions.Options;
43

@@ -26,9 +25,8 @@ internal static void Verify(string generationPath, TextOwnedPath[] ownedPaths, T
2625
}
2726
for (var index = IndexInitialValue; index < actual.Length; index++)
2827
{
29-
if (actual[index].RelativePath != expected[index].RelativePath || actual[index].Length != expected[index].Length
30-
|| expected[index].Sha256 is null || expected[index].Sha256.Length != SHA256.HashSizeInBytes
31-
|| !CryptographicOperations.FixedTimeEquals(actual[index].Sha256, expected[index].Sha256))
28+
// ZoneTree owns the content of these files and rewrites its metadata; only the owned file set is checked.
29+
if (actual[index].RelativePath != expected[index].RelativePath)
3230
{
3331
throw TextErrors.Corrupt();
3432
}

0 commit comments

Comments
 (0)