Test: TypeScript writes a record under an older schema id, C# declares it and rewrites it

The C# interop note declares a compatible id and the peer gains a rewrite mode; the TypeScript
cross-runtime test has TS write a record under that id and another schema name, C# open and
rewrite it, and C#, TypeScript, Rust and Python open the result.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 11:32:47 +02:00
commit da0315e69e
2 changed files with 76 additions and 2 deletions

View file

@ -16,7 +16,7 @@ static async Task<int> ProgramMainAsync(string[] args)
{
if (args.Length == 0)
{
throw new InvalidOperationException("Expected mode: write | read | write-routed <catalog.cc> <run.cc>");
throw new InvalidOperationException("Expected mode: write | read | rewrite | write-routed <catalog.cc> <run.cc>");
}
var mode = args[0];
@ -38,6 +38,9 @@ static async Task<int> ProgramMainAsync(string[] args)
case "read":
await ReadAsync(file);
return 0;
case "rewrite":
await RewriteAsync(file);
return 0;
case "write-deck":
await WriteDeckAsync(file);
return 0;
@ -83,6 +86,17 @@ static async Task ReadAsync(string file)
WriteJsonLine(note);
}
// Puts the stored note back: the cache stamps it with the registered schema id, whatever id it was stored under.
static async Task RewriteAsync(string file)
{
var cache = BuildCache(file);
await cache.PullAllBackingStoresAsync();
var note = cache.AllEntries.OfType<CultCacheInteropNote>().Single();
await cache.UpsertAsync(note, new CultRecordHandle<CultCacheInteropNote>(new CultRecordKey(note.DocumentId)));
cache.FlushAllBackingStores();
WriteJsonLine(note);
}
// A record with an object list: the cache mints each mark's element id, and every runtime reads it as an ordinary member.
static async Task WriteDeckAsync(string file)
{
@ -186,7 +200,7 @@ static void WriteJsonLine(CultCacheInteropNote note)
}));
}
[CultDocument("cultcache.interop-note", "cultcache.interop_note.v1")]
[CultDocument("cultcache.interop-note", "cultcache.interop_note.v1", CompatibleSchemaIds = new[] { "cultcache.interop-note.legacy-id" })]
[MessagePackObject]
public sealed class CultCacheInteropNote
{