security(experiences): single-writer JSON authority, durable recovery safeguards (#155)
* security(experiences): enforce exclusive single-writer lease and fail-closed durable JSON commits * test(experiences): verify exclusive writers, durable reload, corruption refusal, and crash-temp recovery * security(experiences): reject unsupported cluster storage and enforce single-authority startup * config(experiences): document explicit single-writer JSON backend and clustering limit * config(experiences): document explicit single-writer JSON backend and clustering limit * config(experiences): document explicit single-writer JSON backend and clustering limit * ci(experiences): assert single-authority startup, fail-closed commits and recovery regressions * fix(ci): reuse existing regression and config source variables * docs(experiences): single-writer JSON runbook, failure recovery and real RC1 gates * docs(release): mark single-writer JSON hardening as partial while keeping persistence gate open * docs(release): clarify single-writer versus unsupported distributed Experience failover
This commit is contained in:
1 parent
eefe1dd219
commit
a6778c98ac
10 files changed
+341
-22
No files matched your search
@@ -219,7 +219,7 @@ namespace NexVerse.Core.Experiences
|
||||
public List<NexExperienceLogEntry> Logs { get; set; } = new List<NexExperienceLogEntry>();
|
||||
}
|
||||
|
||||
public sealed class NexExperienceStore
|
||||
public sealed class NexExperienceStore : IDisposable
|
||||
{
|
||||
public const int CurrentSchemaVersion = 1;
|
||||
public const int MaxKeyLength = 1011;
|
||||
@@ -230,6 +230,12 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
private readonly object m_Sync = new object();
|
||||
private readonly string m_Path;
|
||||
// FileShare.None is held for the entire lifetime of the authoritative
|
||||
// Robust store. The file is deliberately not unlinked on release:
|
||||
// deleting the inode would permit another writer to lock a new file.
|
||||
private readonly FileStream m_WriterLease;
|
||||
private bool m_Disposed;
|
||||
private bool m_PersistenceFailed;
|
||||
private readonly JsonSerializerOptions m_Json =
|
||||
new JsonSerializerOptions { WriteIndented = true };
|
||||
private NexExperienceSnapshot m_State;
|
||||
@@ -240,7 +246,53 @@ namespace NexVerse.Core.Experiences
|
||||
throw new ArgumentException("Experience store path is required.", nameof(path));
|
||||
|
||||
m_Path = Path.GetFullPath(path);
|
||||
m_State = Load();
|
||||
string directory = Path.GetDirectoryName(m_Path);
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
try
|
||||
{
|
||||
// This prevents a second Robust writer on the same local
|
||||
// filesystem, including a second store in this process.
|
||||
// It is NOT a distributed lease or an NFS/SMB fencing token.
|
||||
m_WriterLease = new FileStream(m_Path + ".writer.lock",
|
||||
FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
|
||||
}
|
||||
catch (IOException error)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"NexExperiences JSON store already has a writer or its lock is unavailable. " +
|
||||
"Start only one Robust authority per local store; do not use shared-file active/active.",
|
||||
error);
|
||||
}
|
||||
try
|
||||
{
|
||||
m_State = Load();
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_WriterLease.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
if (m_Disposed) return;
|
||||
m_Disposed = true;
|
||||
m_WriterLease.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureActive()
|
||||
{
|
||||
if (m_Disposed)
|
||||
throw new ObjectDisposedException(nameof(NexExperienceStore));
|
||||
if (m_PersistenceFailed)
|
||||
throw new InvalidOperationException(
|
||||
"NexExperiences persistence failed. Stop this Robust authority and restore or restart " +
|
||||
"after checking the JSON store; do not continue with potentially uncommitted permissions.");
|
||||
}
|
||||
|
||||
public NexExperience Create(
|
||||
@@ -259,6 +311,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
if (m_State.Experiences.Any(x =>
|
||||
string.Equals(x.Name, normalizedName, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
@@ -292,7 +345,10 @@ namespace NexVerse.Core.Experiences
|
||||
public NexExperience Get(Guid experienceId)
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
return Clone(Find(experienceId));
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<NexExperience> Search(string query, int offset, int limit)
|
||||
@@ -306,6 +362,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
IEnumerable<NexExperience> result =
|
||||
m_State.Experiences.Where(x => x.Enabled);
|
||||
|
||||
@@ -337,6 +394,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = RequireManage(experienceId, actorId);
|
||||
string normalizedName = NormalizeName(name);
|
||||
|
||||
@@ -363,6 +421,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = Find(experienceId) ??
|
||||
throw new KeyNotFoundException("Experience was not found.");
|
||||
|
||||
@@ -397,6 +456,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = RequireManage(experienceId, actorId);
|
||||
HashSet<Guid> target;
|
||||
|
||||
@@ -425,6 +485,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = Find(experienceId);
|
||||
if (experience == null || !experience.Enabled)
|
||||
return NexExperiencePermissionStatus.None;
|
||||
@@ -456,6 +517,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = RequireManage(experienceId, actorId);
|
||||
experience.AllowedResidents.Remove(residentId);
|
||||
experience.BlockedResidents.Remove(residentId);
|
||||
@@ -489,6 +551,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = Find(experienceId);
|
||||
if (experience == null)
|
||||
throw new KeyNotFoundException("Experience was not found.");
|
||||
@@ -524,6 +587,7 @@ namespace NexVerse.Core.Experiences
|
||||
throw new ArgumentException("Resident ID is required.", nameof(residentId));
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience[] active = m_State.Experiences
|
||||
.Where(x => x.Enabled).ToArray();
|
||||
return (
|
||||
@@ -549,9 +613,12 @@ namespace NexVerse.Core.Experiences
|
||||
if (groupId == Guid.Empty)
|
||||
throw new ArgumentException("Group UUID is required.", nameof(groupId));
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
return m_State.Experiences
|
||||
.Where(x => x.Enabled && x.GroupId == groupId)
|
||||
.Select(x => x.ExperienceId).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public NexExperience SetLocationPolicy(
|
||||
@@ -568,6 +635,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = RequireManage(experienceId, actorId);
|
||||
HashSet<Guid> allow;
|
||||
HashSet<Guid> block;
|
||||
@@ -613,6 +681,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
NexExperience experience = Find(experienceId);
|
||||
if (experience == null || !experience.Enabled)
|
||||
return false;
|
||||
@@ -649,6 +718,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireManage(experienceId, actorId);
|
||||
m_State.ScriptBindings[scriptItemId] = experienceId;
|
||||
AddLog(experienceId, actor, "experience.script.bind", scriptItemId.ToString("D"));
|
||||
@@ -659,9 +729,12 @@ namespace NexVerse.Core.Experiences
|
||||
public Guid ResolveScript(Guid scriptItemId)
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
return m_State.ScriptBindings.TryGetValue(scriptItemId, out Guid id)
|
||||
? id
|
||||
: Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateKeyValue(
|
||||
@@ -672,6 +745,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
NexExperience experience = Find(experienceId);
|
||||
string normalized = ValidateKey(key);
|
||||
@@ -704,6 +778,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
NexExperience experience = Find(experienceId);
|
||||
return experience.KeyValues.TryGetValue(ValidateKey(key), out value);
|
||||
@@ -721,6 +796,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
NexExperience experience = Find(experienceId);
|
||||
string normalized = ValidateKey(key);
|
||||
@@ -776,6 +852,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
return Find(experienceId).KeyValues.Count;
|
||||
}
|
||||
@@ -794,6 +871,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
return Find(experienceId).KeyValues.Keys
|
||||
.OrderBy(x => x, StringComparer.Ordinal)
|
||||
@@ -809,6 +887,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
return GetStoreBytes(Find(experienceId));
|
||||
}
|
||||
@@ -835,6 +914,7 @@ namespace NexVerse.Core.Experiences
|
||||
{
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
RequireBoundScript(experienceId, scriptItemId);
|
||||
NexExperience experience = Find(experienceId);
|
||||
bool removed = experience.KeyValues.Remove(ValidateKey(key));
|
||||
@@ -859,6 +939,7 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
lock (m_Sync)
|
||||
{
|
||||
EnsureActive();
|
||||
return m_State.Logs
|
||||
.Where(x => x.ExperienceId == experienceId)
|
||||
.OrderByDescending(x => x.Timestamp)
|
||||
@@ -951,13 +1032,22 @@ namespace NexVerse.Core.Experiences
|
||||
private NexExperienceSnapshot Load()
|
||||
{
|
||||
if (!File.Exists(m_Path))
|
||||
{
|
||||
// A crash during the first commit can leave only a temp file.
|
||||
// Never silently recreate an empty authority in that state.
|
||||
if (File.Exists(m_Path + ".tmp"))
|
||||
throw new InvalidOperationException(
|
||||
"Incomplete NexExperiences initial commit: snapshot missing but .tmp exists. " +
|
||||
"Investigate/restore manually; no automatic empty-store reset.");
|
||||
return new NexExperienceSnapshot { SchemaVersion = CurrentSchemaVersion };
|
||||
}
|
||||
|
||||
NexExperienceSnapshot state =
|
||||
JsonSerializer.Deserialize<NexExperienceSnapshot>(
|
||||
File.ReadAllText(m_Path),
|
||||
m_Json) ??
|
||||
new NexExperienceSnapshot();
|
||||
throw new InvalidOperationException(
|
||||
"NexExperiences JSON snapshot is null. Refusing to reset resident permissions.");
|
||||
|
||||
if (state.SchemaVersion != CurrentSchemaVersion)
|
||||
throw new InvalidOperationException("Unsupported experience store schema version.");
|
||||
@@ -984,13 +1074,31 @@ namespace NexVerse.Core.Experiences
|
||||
|
||||
private void Save()
|
||||
{
|
||||
string directory = Path.GetDirectoryName(m_Path);
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
EnsureActive();
|
||||
string temp = m_Path + ".tmp";
|
||||
File.WriteAllText(temp, JsonSerializer.Serialize(m_State, m_Json));
|
||||
File.Move(temp, m_Path, true);
|
||||
try
|
||||
{
|
||||
// Commit on the SAME filesystem. Flush file data before
|
||||
// atomically replacing the primary snapshot. A stale temp is
|
||||
// never auto-promoted and must not override a valid snapshot.
|
||||
byte[] payload = JsonSerializer.SerializeToUtf8Bytes(m_State, m_Json);
|
||||
using (FileStream output = new FileStream(
|
||||
temp, FileMode.Create, FileAccess.Write, FileShare.None,
|
||||
64 * 1024, FileOptions.WriteThrough))
|
||||
{
|
||||
output.Write(payload, 0, payload.Length);
|
||||
output.Flush(flushToDisk: true);
|
||||
}
|
||||
File.Move(temp, m_Path, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// The in-memory state was already mutated by the operation.
|
||||
// Fail closed until the process restarts and reloads the last
|
||||
// committed snapshot instead of serving an uncommitted grant.
|
||||
m_PersistenceFailed = true;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static NexExperience Clone(NexExperience source)
|
||||
|
||||
@@ -596,15 +596,33 @@ namespace NexVerse.Server.Api
|
||||
IConfig experiencesConfig =
|
||||
config.Configs["NexExperiences"];
|
||||
|
||||
// JSON remains a single-authority backend. Do not silently
|
||||
// accept a requested SQL/cluster backend that does not exist.
|
||||
string experienceBackend = experiencesConfig?.GetString(
|
||||
"StoreBackend", "SingleWriterJson")?.Trim();
|
||||
if (!string.Equals(experienceBackend, "SingleWriterJson",
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
throw new InvalidOperationException(
|
||||
"Unsupported [NexExperiences] StoreBackend: only " +
|
||||
"SingleWriterJson is implemented. Active/active Robust " +
|
||||
"requires a future transactional distributed backend.");
|
||||
|
||||
string experienceStorePath =
|
||||
experiencesConfig?.GetString(
|
||||
"StorePath",
|
||||
"data/nexverse-experiences.json") ??
|
||||
"data/nexverse-experiences.json";
|
||||
|
||||
// The constructor acquires the local writer lease BEFORE
|
||||
// loading resident grants and script/KV state. A second
|
||||
// authority sharing this file refuses to start.
|
||||
NexExperienceStore experienceStore =
|
||||
new NexExperienceStore(
|
||||
experienceStorePath);
|
||||
AppDomain.CurrentDomain.ProcessExit +=
|
||||
(_, __) => experienceStore.Dispose();
|
||||
m_Log.Info("[NEX-EXPERIENCES]: SingleWriterJson authority acquired. " +
|
||||
"One Robust writer only; no cross-host shared-file failover.");
|
||||
|
||||
NexExperiencesApi experiencesApi =
|
||||
new NexExperiencesApi(
|
||||
|
||||
@@ -288,6 +288,11 @@
|
||||
Enabled = true
|
||||
|
||||
[NexExperiences]
|
||||
; Persistent store: only one local Robust writer is supported.
|
||||
; Separate hosts must NOT share this file over NFS/SMB as active/active.
|
||||
; Keep the writer lock file alongside the JSON; do not delete it to
|
||||
; force a second writer. SQL/cluster storage is not implemented yet.
|
||||
StoreBackend = "SingleWriterJson"
|
||||
; Native OpenGenesisLINK Experience authority.
|
||||
StorePath = "data/nexverse-experiences.json"
|
||||
|
||||
|
||||
@@ -280,6 +280,11 @@
|
||||
Enabled = true
|
||||
|
||||
[NexExperiences]
|
||||
; Persistent store: only one local Robust writer is supported.
|
||||
; Separate hosts must NOT share this file over NFS/SMB as active/active.
|
||||
; Keep the writer lock file alongside the JSON; do not delete it to
|
||||
; force a second writer. SQL/cluster storage is not implemented yet.
|
||||
StoreBackend = "SingleWriterJson"
|
||||
; Native OpenGenesisLINK Experience authority used by World API and LSL adapters.
|
||||
; This file is server-owned and must be writable by the Robust process.
|
||||
StorePath = "data/nexverse-experiences.json"
|
||||
|
||||
@@ -228,6 +228,11 @@
|
||||
Enabled = false
|
||||
|
||||
[NexExperiences]
|
||||
; Persistent store: only one local Robust writer is supported.
|
||||
; Separate hosts must NOT share this file over NFS/SMB as active/active.
|
||||
; Keep the writer lock file alongside the JSON; do not delete it to
|
||||
; force a second writer. SQL/cluster storage is not implemented yet.
|
||||
StoreBackend = "SingleWriterJson"
|
||||
; Native OpenGenesisLINK Experience authority used by World API and LSL adapters.
|
||||
; This file is server-owned and must be writable by the Robust process.
|
||||
StorePath = "data/nexverse-experiences.json"
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# NexExperiences – SingleWriterJson Betrieb (OpenGenesisLINK 0.9.3.10 Dev)
|
||||
|
||||
**Stand 11.10.2026.** Der bisherige JSON-Store bleibt die autoritative
|
||||
Experience-Verwaltung, aber ist **kein transaktionales Multi-Writer-/SQL-Backend**.
|
||||
Dieser Härtungsschritt verhindert konkurrierende Writer auf **demselben
|
||||
lokalen Dateisystem** und sichert Snapshot-Commits ab. Firestorm-Consent und
|
||||
Multi-Simulator-E2E-Tests bleiben vor RC1 offen.
|
||||
|
||||
## Architektur und Grenzen
|
||||
|
||||
* Ein Robust-Prozess hält die Datei `<StorePath>.writer.lock` während der
|
||||
gesamten Store-Lebenszeit über einen exklusiven offenen `FileStream`
|
||||
(`FileShare.None`). Bereits beim Start eines zweiten Writers mit
|
||||
**demselben lokalen Pfad** wird ein Fehler ausgelöst und die betreffende
|
||||
World-API-Initialisierung verweigert. Das `.writer.lock`-Dateiobjekt
|
||||
**bleibt auch nach dem Prozessende bestehen**; entscheidend ist der
|
||||
offene Handle, nicht eine gelöschte/verwaiste Dateimarke.
|
||||
* Alle öffentlichen Store-Operationen prüfen, dass der Store nicht
|
||||
disposed oder nach fehlgeschlagener Speicherung inkonsistent ist.
|
||||
* Änderungen werden zunächst in `<StorePath>.tmp` geschrieben,
|
||||
einschließlich Flush auf das Dateisystem, dann auf demselben Volume
|
||||
per `File.Move(temp, primary, overwrite: true)` ersetzt. Die letzte
|
||||
gültige Primärdatei bleibt bei einem Abbruch *vor dem Rename* erhalten.
|
||||
Ein alter `.tmp` ersetzt sie beim Neustart **niemals automatisch**.
|
||||
* Bei fehlgeschlagenem Commit wird der Store bis zum Prozessneustart
|
||||
**fail-closed**. Dies ist ausdrücklich keine automatische Transaktion:
|
||||
nach Disk-/I/O-Fehlern gilt die Anfrage als fehlgeschlagen, Robust
|
||||
muss gestoppt und der letzte bestätigte Snapshot geprüft werden.
|
||||
* Fehlende Primärdatei **mit** vorhandenem `.tmp`, invalide JSON-Daten
|
||||
und eine JSON-`null`-Root verhindern die Inbetriebnahme statt einer
|
||||
stillen leeren Experience-Verwaltung. Bei einer noch nie verwendeten
|
||||
Installation ohne Primärdatei oder `.tmp` ist ein leerer Start zulässig.
|
||||
* Der Lock ist **kein** verteiltes Fencing, hat keine Leader-Election,
|
||||
garantiert keine atomaren NFS-/SMB-Locks und kann keine Netzwerkpartition
|
||||
erkennen. Auch Flush/Rename ersetzt weder Datenbanktransaktionen noch
|
||||
getestete Stromausfallsicherheit einschließlich Directory-Fsync.
|
||||
|
||||
## Konfiguration
|
||||
|
||||
In Robust.ini bzw. Robust.HG.ini:
|
||||
|
||||
```ini
|
||||
[NexExperiences]
|
||||
StoreBackend = "SingleWriterJson"
|
||||
StorePath = "data/nexverse-experiences.json"
|
||||
```
|
||||
|
||||
`StoreBackend` ist absichtlich restriktiv. Nicht unterstützte Werte wie
|
||||
`Sql`, `Distributed` oder `ActiveActive` müssen einen **Startfehler**
|
||||
auslösen – keine vorgetäuschte SQL-Implementierung. Bereits laufende
|
||||
Installationen ohne `StoreBackend` verwenden automatisch SingleWriterJson.
|
||||
Simulatoren verwenden weiterhin den authentifizierten zentralen World-API
|
||||
Dienst, nicht direkte JSON-/SQL-Dateizugriffe.
|
||||
|
||||
Für zwei oder mehr Simulatoren darf **ein** zentraler Robust die
|
||||
Experience-Autorität anbieten. Für mehrere Robust-Prozesse dieselbe JSON
|
||||
Datei *nicht* per NFS/SMB freigeben. Ein Load-Balancer mit mehreren aktiven
|
||||
unabhängigen JSON-Stores ist **nicht zulässig**, weil Berechtigungen,
|
||||
Scriptbindungen und K/V auseinanderlaufen würden. Für echte aktive
|
||||
Redundanz ist ein gesonderter SQL-Transaktionsstore mit CAS-/Migration-/
|
||||
Failover-/Fencing-Tests nötig; diese Aufgabe ist weiterhin offen.
|
||||
|
||||
## Sichere Wartung und Wiederherstellung
|
||||
|
||||
1. Vor Änderungen StorePath und zugehörige Konfiguration identifizieren,
|
||||
alle Secrets aus Logs heraushalten. Nur einen Robust-Writer betreiben.
|
||||
2. Für **konsistente Backups** Schreiboperationen anhalten, Robust sauber
|
||||
stoppen, die Primärdatei samt Version/Prüfsumme sichern. Die Lock-Datei
|
||||
darf bestehen bleiben; niemals zum Erzwingen einer zweiten Instanz
|
||||
löschen. Ein `.tmp` ist *nicht* automatisch der gültige Snapshot.
|
||||
3. Backup testweise auf einem isolierten Robust-Prozess mit **eigenem**
|
||||
lokalem Pfad laden. Erfahrungen, K/V, Scriptbindungen, Allow/Block/Forget
|
||||
und Rollback mit zwei Avataren überprüfen.
|
||||
4. Bei I/O-Fehlern World API nicht weiter beschreiben; Robust stoppen,
|
||||
Datenträger und `.json` prüfen, erfolgreich bestätigtes Backup
|
||||
kontrollieren. Keine `null`-, leere oder beschädigte Datei durch
|
||||
blindes Löschen ersetzen.
|
||||
5. Für einen geplanten Wechsel auf einen zweiten Robust zuerst den
|
||||
bisherigen Autoritätsprozess beenden, dann die nachweislich gleiche
|
||||
bestätigte Snapshotversion zum **lokalen** Datenpfad des zweiten
|
||||
Robust übertragen, und erst dort starten. Kein automatisches Failover.
|
||||
|
||||
## Tests / Stable Gate
|
||||
|
||||
CI testet:
|
||||
- Exklusiven Writer-Lock und Ablehnung eines zweiten Stores
|
||||
- Freigabe des Locks erst nach Dispose; alter Store kann danach nichts lesen
|
||||
- Persistierung und Wiederöffnung durch die nachfolgende Store-Instanz
|
||||
- Ablehnung `null` und defekter JSON-Dateien sowie unterbrochener Erstanlage
|
||||
- Schutz der gültigen Primärdatei gegen eine veraltete `.tmp`
|
||||
- Bestehende Experience-ACL-/KV-/CAS-/Rollen-/LSL-Regressionen
|
||||
|
||||
**Nicht damit bestanden:** Zwei-Avatar-Firestorm-Allow/Block/Forget,
|
||||
Regionswechsel, gleichzeitige K/V-CAS-Anfragen aus mehreren Simulatoren,
|
||||
Multi-Host-Redundanz, Restore-Probe oder harte Last-/IO-Störungstests.
|
||||
Siehe [RC1_OPERATOR_ACCEPTANCE_09310.md](RC1_OPERATOR_ACCEPTANCE_09310.md).
|
||||
|
||||
**Freigabestatus: Dev; keine 0.9.3.10 RC1/Stable-Aussage.**
|
||||
@@ -104,7 +104,7 @@ berechtigt zugeordnet sein. Ein zweiter Bewohner darf keine Admin-Rechte haben.
|
||||
| EXP07 | Zwei gleichzeitige Scripts und zwei Avatare | Deny, Timeout, Allow sind script-/avatar-isoliert |
|
||||
| EXP08 | Unbefugter Avatar/HG-Gast, gesperrte Parzelle, deaktivierte Experience | Verweigerung trotz alter URLs und Script-Bindung |
|
||||
| EXP09 | K/V create/read/update-CAS/delete nach Restart von Robust und Simulatoren | Korrekte Werte, Ausfall-/Backup-/Wiederherstellungsnachweis |
|
||||
| EXP10 | Zwei Robust-Instanzen bzw. produktive zentralisierte Topologie | Nachweis eines einzigen autoritativen Writers bzw. transaktionalen Stores – **nicht** aufgrund JSON-Datei allein behaupten |
|
||||
| EXP10 | Zwei Robust-Instanzen bzw. produktive zentralisierte Topologie | Auf demselben lokalen Store blockiert die exklusive `.writer.lock` den zweiten Robust; aktive Multi-Host-JSON-Instanzen sind **nicht** unterstützt. Nachweis des einen aktiven Writers plus dokumentierter Recovery-/Wiederanlaufplan, **keine** behauptete SQL-/Active-Active-Freigabe |
|
||||
|
||||
EXP01–EXP10 gelten erst als **PASS**, wenn HTTP-/Viewer- und LSL-Ergebnis,
|
||||
Persistenz nach Re-Login, Berechtigungskontrolle sowie saubere Logs
|
||||
|
||||
@@ -112,7 +112,7 @@ Der A*-Rasterkern ist **nur die erste Navigationsgrundlage**, keine vollständig
|
||||
- [x] **Teilfunktion: explizit freizugebende, wartende LSL-Einwilligung:** Optionales `ScriptPendingConsent=false` standardmaessig; Script-Anfragen mit Berechtigungsstatus `none` werden nur bei aktivem Agent und passender Parcel-/Scriptbindung zeitlich begrenzt zwischengespeichert. Nach ausdruecklichem Allow/Block ueber die bereits vorhandene Firestorm-`ExperiencePreferences`-CAP erfolgt zentrale Neupruefung und das passende LSL-Ereignis. Timeout, Quoten, Region-Shutdown und getrennte Bewohner sind abgesichert. Bei `NativeExperiencePrompt=true` kann der Server mittlerweile den echten optionalen Firestorm-`ScriptQuestionExperience`-Prompt senden; **ein Viewer-`ScriptAnswerYes` ohne authentifizierte `ExperiencePreferences`-Persistierung ist niemals ein Allow**. Ohne native Transport-Unterstuetzung bleibt der Hinweis rein informativ. Echte Firestorm-Tests sind offen.
|
||||
- [ ] **Echte Einwilligung (Live-Abnahme offen):** Die native opt-in `ScriptQuestionExperience`-Transportschicht, avatar-gebundene `ExperiencePreferences`-Persistierung, `experience_permissions(_denied)`, CAP-Lease-Revoke und Script-Reset-/Relog-Cleanup sind im Dev-Code implementiert und CI-getestet. **Noch kein bestaetigter durchgehender Firestorm-Allow/Block/Forget-Ablauf mit zwei realen Avataren**; keine automatische Berechtigung unbekannter Residents.
|
||||
- [ ] **Vollstaendige LSL-Paritaet:** Experience-KV-`dataserver`-Events, `llGetExperienceDetails`, `llAgentInExperience`, XP_ERROR-Codes, Ratenlimits, Scriptidentitaet/-besitzer, deaktivierte Experiences, Fehler/Timeouts und Landrechte im echten YEngine-/Viewer-Test.
|
||||
- [ ] **Persistenz/Betrieb:** Der bestehende JSON-Store ist nicht als transaktionaler Multi-Robust-Cluster belegt. Migrations-/Single-Writer- oder SQL-Konzept, konsistente K/V-Updates und Restart-/Backup-/Recovery-Test fuer produktiven Grid-Betrieb.
|
||||
- [ ] **Persistenz/Betrieb – Teilsicherung implementiert, Live-Gate offen:** Der bestehende JSON-Store wird nun lokal durch einen exklusiven Writer-Lease und Flush-then-Rename-Commits gegen gleichzeitige Robust-Writer abgesichert; beschädigte oder unvollständige Snapshots werden fail-closed abgelehnt. Siehe `EXPERIENCES_SINGLE_WRITER_09310.md`. **Das ist kein SQL-/transaktionaler Active-Active-Store.** Zwei-Robust-/Multi-Host-Strategie, Migrations-/Recovery- und echte Backup-/Restart-/K/V-CAS-Failover-Abnahme sind weiterhin offen; kein Stable-Nachweis.
|
||||
- [ ] **E2E-Abnahme:** Zwei Residents, eine Besitzer-Experience, ein fremdes Objekt, Allow/Block/Forget, disabled/revoked, Parcel-/Estate-Limits, gruppenbasierte Rollen, HG-Gast, Viewer-Floater, Script-Dataserver und Neustarts auf mehreren Simulatoren.
|
||||
- Referenz: `doc/NexVerse/PATHFINDING_EXPERIENCES_FULL_PARITY_09310.md`.
|
||||
- Operator-Abnahmematrix (alle Live-Tests anfangs NOT RUN): `doc/NexVerse/RC1_OPERATOR_ACCEPTANCE_09310.md`.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using NexVerse.Core.Experiences;
|
||||
|
||||
internal static class Program
|
||||
@@ -39,6 +40,14 @@ internal static class Program
|
||||
NexExperienceStore store =
|
||||
new NexExperienceStore(path);
|
||||
|
||||
// A second Robust process must never acquire the writer lease,
|
||||
// even when it is running on the same machine.
|
||||
bool secondWriterRejected = false;
|
||||
try { using var secondWriter = new NexExperienceStore(path); }
|
||||
catch (InvalidOperationException) { secondWriterRejected = true; }
|
||||
Require(secondWriterRejected,
|
||||
"multiple active Robust writers could corrupt the JSON authority");
|
||||
|
||||
NexExperience created =
|
||||
store.Create(
|
||||
owner,
|
||||
@@ -132,10 +141,13 @@ internal static class Program
|
||||
"Firestorm ExperiencePreferences block/allow isolation");
|
||||
Require(!store.GetResidentLists(resident).Blocked.Contains(created.ExperienceId),
|
||||
"one resident's block leaked to another");
|
||||
NexExperienceStore reloadedViewer = new NexExperienceStore(path);
|
||||
Require(reloadedViewer.GetResidentPermission(created.ExperienceId, viewerResident) ==
|
||||
NexExperiencePermissionStatus.Blocked,
|
||||
"Firestorm permission did not survive store reload");
|
||||
// Read the persisted bytes without opening another writer instance:
|
||||
// an independent second writer must always be rejected.
|
||||
NexExperienceSnapshot persistedViewer = JsonSerializer.Deserialize<NexExperienceSnapshot>(
|
||||
File.ReadAllText(path));
|
||||
Require(persistedViewer.Experiences.Single(x => x.ExperienceId == created.ExperienceId)
|
||||
.BlockedResidents.Contains(viewerResident),
|
||||
"Firestorm permission did not reach the durable snapshot");
|
||||
store.SetOwnResidentPermission(created.ExperienceId, viewerResident,
|
||||
NexExperiencePermissionStatus.None, "viewer");
|
||||
Require(store.GetResidentPermission(created.ExperienceId, viewerResident) ==
|
||||
@@ -251,13 +263,10 @@ internal static class Program
|
||||
"missing-checked",
|
||||
out _),
|
||||
"failed checked update must not create a key");
|
||||
NexExperienceStore reloadedAfterCas = new NexExperienceStore(path);
|
||||
Require(
|
||||
!reloadedAfterCas.TryReadKeyValue(
|
||||
created.ExperienceId,
|
||||
script,
|
||||
"missing-checked",
|
||||
out _),
|
||||
NexExperienceSnapshot persistedAfterCas = JsonSerializer.Deserialize<NexExperienceSnapshot>(
|
||||
File.ReadAllText(path));
|
||||
Require(!persistedAfterCas.Experiences.Single(
|
||||
x => x.ExperienceId == created.ExperienceId).KeyValues.ContainsKey("missing-checked"),
|
||||
"failed checked update must not persist a phantom key");
|
||||
Require(
|
||||
store.UpdateKeyValue(
|
||||
@@ -309,6 +318,15 @@ internal static class Program
|
||||
100).Count >= 6,
|
||||
"Experience audit log history missing");
|
||||
|
||||
store.Dispose();
|
||||
bool disposedWriterRejected = false;
|
||||
try { store.Get(created.ExperienceId); }
|
||||
catch (ObjectDisposedException) { disposedWriterRejected = true; }
|
||||
Require(disposedWriterRejected,
|
||||
"released authority must reject stale reads and writes");
|
||||
|
||||
// Explicit stop/restart is required before another Robust writer
|
||||
// is allowed to load the persisted committed data.
|
||||
NexExperienceStore reopened =
|
||||
new NexExperienceStore(path);
|
||||
|
||||
@@ -547,6 +565,42 @@ internal static class Program
|
||||
catch (ArgumentException) { invalidLeaseRejected = true; }
|
||||
Require(invalidLeaseRejected, "empty region must not issue a capability");
|
||||
|
||||
reopened.Dispose();
|
||||
|
||||
// Invalid JSON and an interrupted *initial* write must fail closed.
|
||||
// Never silently initialize an empty permission database.
|
||||
string nullSnapshot = Path.Combine(root, "null-experiences.json");
|
||||
File.WriteAllText(nullSnapshot, "null");
|
||||
bool nullRejected = false;
|
||||
try { using var invalid = new NexExperienceStore(nullSnapshot); }
|
||||
catch (InvalidOperationException) { nullRejected = true; }
|
||||
Require(nullRejected, "null snapshot silently reset Experience authority");
|
||||
|
||||
string truncatedSnapshot = Path.Combine(root, "truncated-experiences.json");
|
||||
File.WriteAllText(truncatedSnapshot, "{bad");
|
||||
bool invalidJsonRejected = false;
|
||||
try { using var invalid = new NexExperienceStore(truncatedSnapshot); }
|
||||
catch (JsonException) { invalidJsonRejected = true; }
|
||||
Require(invalidJsonRejected, "corrupt JSON did not prevent Robust startup");
|
||||
|
||||
string unfinished = Path.Combine(root, "interrupted-first-write.json");
|
||||
File.WriteAllText(unfinished + ".tmp", "{incomplete");
|
||||
bool incompleteRejected = false;
|
||||
try { using var invalid = new NexExperienceStore(unfinished); }
|
||||
catch (InvalidOperationException) { incompleteRejected = true; }
|
||||
Require(incompleteRejected, "incomplete initial commit discarded consent database");
|
||||
|
||||
// The existing primary snapshot always takes precedence over a
|
||||
// stray stale .tmp file after a later interrupted replacement.
|
||||
string staleTemp = Path.Combine(root, "stale-temp.json");
|
||||
using (var committed = new NexExperienceStore(staleTemp))
|
||||
committed.Create(Guid.NewGuid(), Guid.Empty, "Durable", "",
|
||||
NexExperienceMaturity.General, "ci");
|
||||
File.WriteAllText(staleTemp + ".tmp", "{incomplete");
|
||||
using (var recovered = new NexExperienceStore(staleTemp))
|
||||
Require(recovered.Search("Durable", 0, 10).Count == 1,
|
||||
"stale temp incorrectly overrode last committed snapshot");
|
||||
|
||||
Directory.Delete(root, true);
|
||||
|
||||
Console.WriteLine(
|
||||
|
||||
@@ -98,6 +98,32 @@ for marker in (
|
||||
):
|
||||
assert marker in experience_store, f"missing Experience core marker: {marker}"
|
||||
|
||||
# Multi-Robust JSON authority safety: only one live local writer and
|
||||
# fail-closed persistence errors; no false distributed SQL claim.
|
||||
robust_example = robust_hg_config
|
||||
experiences_regression = regression
|
||||
for marker in (
|
||||
"public sealed class NexExperienceStore : IDisposable",
|
||||
"FileShare.None",
|
||||
".writer.lock",
|
||||
"m_PersistenceFailed = true",
|
||||
"FileOptions.WriteThrough",
|
||||
"output.Flush(flushToDisk: true)",
|
||||
"File.Move(temp, m_Path, true)",
|
||||
"if (File.Exists(m_Path + \".tmp\"))",
|
||||
"NexExperiences JSON snapshot is null",
|
||||
"throw new ObjectDisposedException",
|
||||
):
|
||||
assert marker in experience_store, f"unsafe Experience JSON authority: {marker}"
|
||||
for marker in ("StoreBackend", "SingleWriterJson",
|
||||
"new NexExperienceStore(", "experienceStore.Dispose()"):
|
||||
assert marker in connector, f"missing Robust single-authority startup guard: {marker}"
|
||||
assert 'StoreBackend = "SingleWriterJson"' in robust_example
|
||||
for marker in ("secondWriterRejected", "disposedWriterRejected",
|
||||
"incompleteRejected", "nullRejected", "invalidJsonRejected",
|
||||
"stale temp incorrectly overrode last committed snapshot"):
|
||||
assert marker in experiences_regression, f"missing Experience disk regression: {marker}"
|
||||
|
||||
for marker in (
|
||||
"/api/v1/experiences",
|
||||
"/api/v1/experiences/script/resolve",
|
||||
|
||||
Reference in new issue
Block a user