Codebasis als Dateien ins Arbeitsrepo statt als Gitlink

QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142)
getrackt, ohne .gitmodules und ohne erreichbares Remote. Der
Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar
gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege
der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen.

Umstellung:
- Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert
  (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6)
- Gitlink aus dem Index entfernt
- Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB

Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte
bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
This commit is contained in:
Christoph Schwörer
2026-08-26 07:43:51 +02:00
parent 18edae75b6
commit f045b99a25
24664 changed files with 5846716 additions and 1 deletions
@@ -0,0 +1,45 @@
using System;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryRecordArtificialIntelligenceToolUsage : EndToEndTest
{
public TelemetryRecordArtificialIntelligenceToolUsage(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
var toolName = $"ai_assistant_test_{Guid.NewGuid():N}";
var hardwareId = $"hardware_test_{Guid.NewGuid():N}";
var occurredUtc = new DateTime(2026, 5, 2, 12, 29, 59, DateTimeKind.Utc);
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().RecordArtificialIntelligenceToolUsageBatch(
11,
new[] { toolName, toolName },
hardwareId,
occurredUtc);
Assert.True(result.IsSuccess, result.Message);
});
var count = this.Sql<int>($@"
SELECT T.[Count]
FROM dbo.ArtificialIntelligenceToolUsageTelemetry T
INNER JOIN dbo.McpToolNameLookup N ON N.I3D = T.ToolNameI3D
INNER JOIN dbo.HardwareIDLookup H ON H.I3D = T.HardwareIDI3D
WHERE T.UserID = 11
AND N.Name = '{toolName}'
AND H.Name = '{hardwareId}'
AND T.BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(2, count);
}
}
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertApiCall_DistinguishesByUserKindAndLicenseGuid : EndToEndTest
{
public TelemetryUpsertApiCall_DistinguishesByUserKindAndLicenseGuid(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
int methodI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveApiMethodNameI3Ds(new[] { "M" });
Assert.True(resolve.IsSuccess);
methodI3D = resolve.Data["M"];
});
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
// 4 distinct keys: User+Centron, WebAccount+Centron, User+ServiceBoard, AccessToken+NULL.
// The NULL-LicenseKind row exercises the ISNULL(-1) MERGE matcher in TelemetryBL.
// Note: increments are pre-aggregated by the runtime aggregator (one row per key); we
// mirror that contract here — MERGE source must not contain duplicate keys.
var increments = new List<ApiCallBucketIncrement>
{
new() { UserID = 11, UserKind = TelemetryUserKind.User, LicenseKind = TelemetryLicenseKind.Centron, MethodNameI3D = methodI3D, BucketStartUtc = bucket, Increment = 1 },
new() { UserID = 11, UserKind = TelemetryUserKind.WebAccount, LicenseKind = TelemetryLicenseKind.Centron, MethodNameI3D = methodI3D, BucketStartUtc = bucket, Increment = 1 },
new() { UserID = 11, UserKind = TelemetryUserKind.User, LicenseKind = TelemetryLicenseKind.ServiceBoard, MethodNameI3D = methodI3D, BucketStartUtc = bucket, Increment = 1 },
new() { UserID = 11, UserKind = TelemetryUserKind.AccessToken, LicenseKind = null, MethodNameI3D = methodI3D, BucketStartUtc = bucket, Increment = 2 }
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertApiCallBatch(increments);
Assert.True(result.IsSuccess);
});
Assert.Equal(4, this.Sql<int>($"SELECT COUNT(*) FROM dbo.ApiCallTelemetry WHERE UserID = 11 AND MethodNameI3D = {methodI3D} AND BucketStartUtc = '2026-05-02T12:15:00'"));
// The NULL-LicenseKind row matched via ISNULL sentinel and stored Count=2.
Assert.Equal(2, this.Sql<int>($"SELECT [Count] FROM dbo.ApiCallTelemetry WHERE UserID = 11 AND UserKind = 2 AND LicenseKind IS NULL AND MethodNameI3D = {methodI3D} AND BucketStartUtc = '2026-05-02T12:15:00'"));
}
}
}
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertApiCall_IncrementExisting : EndToEndTest
{
public TelemetryUpsertApiCall_IncrementExisting(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
int methodI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveApiMethodNameI3Ds(new[] { "GetSomething" });
Assert.True(resolve.IsSuccess);
methodI3D = resolve.Data["GetSomething"];
});
this.Sql($@"
INSERT INTO dbo.ApiCallTelemetry (UserID, UserKind, LicenseKind, MethodNameI3D, HardwareIDI3D, BucketStartUtc, [Count])
VALUES (11, 0, {(short)TelemetryLicenseKind.Centron}, {methodI3D}, 0, '2026-05-02T12:15:00', 6)");
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
var increments = new List<ApiCallBucketIncrement>
{
new()
{
UserID = 11,
UserKind = TelemetryUserKind.User,
LicenseKind = TelemetryLicenseKind.Centron,
MethodNameI3D = methodI3D,
BucketStartUtc = bucket,
Increment = 5
}
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertApiCallBatch(increments);
Assert.True(result.IsSuccess);
});
var rowCount = this.Sql<int>(
$"SELECT COUNT(*) FROM dbo.ApiCallTelemetry WHERE UserID = 11 AND UserKind = 0 AND LicenseKind = {(short)TelemetryLicenseKind.Centron} AND MethodNameI3D = {methodI3D} AND BucketStartUtc = '2026-05-02T12:15:00'");
var count = this.Sql<int>(
$"SELECT [Count] FROM dbo.ApiCallTelemetry WHERE UserID = 11 AND UserKind = 0 AND LicenseKind = {(short)TelemetryLicenseKind.Centron} AND MethodNameI3D = {methodI3D} AND BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(1, rowCount);
Assert.Equal(11, count);
}
}
}
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertApiCall_InsertNew : EndToEndTest
{
public TelemetryUpsertApiCall_InsertNew(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
int methodI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveApiMethodNameI3Ds(new[] { "GetSomething" });
Assert.True(resolve.IsSuccess);
methodI3D = resolve.Data["GetSomething"];
});
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
var increments = new List<ApiCallBucketIncrement>
{
new()
{
UserID = 11,
UserKind = TelemetryUserKind.User,
LicenseKind = TelemetryLicenseKind.Centron,
MethodNameI3D = methodI3D,
BucketStartUtc = bucket,
Increment = 4
}
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertApiCallBatch(increments);
Assert.True(result.IsSuccess);
});
var count = this.Sql<int>(
$"SELECT [Count] FROM dbo.ApiCallTelemetry WHERE UserID = 11 AND UserKind = 0 AND LicenseKind = {(short)TelemetryLicenseKind.Centron} AND MethodNameI3D = {methodI3D} AND BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(4, count);
}
}
}
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertMcpToolUsage_DistinguishesByAllKeyColumns : EndToEndTest
{
public TelemetryUpsertMcpToolUsage_DistinguishesByAllKeyColumns(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
int toolI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveMcpToolNameI3Ds(new[] { "tool" });
Assert.True(resolve.IsSuccess);
toolI3D = resolve.Data["tool"];
});
var bucketA = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
var bucketB = new DateTime(2026, 5, 2, 12, 30, 0, DateTimeKind.Utc);
var increments = new List<McpToolUsageBucketIncrement>
{
new() { UserID = 11, ToolNameI3D = toolI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucketA, Increment = 1 },
new() { UserID = 11, ToolNameI3D = toolI3D, ToolMode = McpToolMode.Agent, BucketStartUtc = bucketA, Increment = 1 },
new() { UserID = 11, ToolNameI3D = toolI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucketB, Increment = 1 }
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertMcpToolUsageBatch(increments);
Assert.True(result.IsSuccess);
});
Assert.Equal(3, this.Sql<int>($"SELECT COUNT(*) FROM dbo.McpToolUsageTelemetry WHERE UserID = 11 AND ToolNameI3D = {toolI3D}"));
}
}
}
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertMcpToolUsage_IncrementExisting : EndToEndTest
{
public TelemetryUpsertMcpToolUsage_IncrementExisting(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
int toolNameI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveMcpToolNameI3Ds(new[] { "create_ticket" });
Assert.True(resolve.IsSuccess);
toolNameI3D = resolve.Data["create_ticket"];
});
this.Sql($@"
INSERT INTO dbo.McpToolUsageTelemetry (UserID, ToolNameI3D, HardwareIDI3D, ToolMode, BucketStartUtc, [Count])
VALUES (11, {toolNameI3D}, 0, 0, '2026-05-02T12:15:00', 5)");
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
var increments = new List<McpToolUsageBucketIncrement>
{
new() { UserID = 11, ToolNameI3D = toolNameI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucket, Increment = 3 }
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertMcpToolUsageBatch(increments);
Assert.True(result.IsSuccess);
});
var rowCount = this.Sql<int>(
$"SELECT COUNT(*) FROM dbo.McpToolUsageTelemetry WHERE UserID = 11 AND ToolNameI3D = {toolNameI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'");
var count = this.Sql<int>(
$"SELECT [Count] FROM dbo.McpToolUsageTelemetry WHERE UserID = 11 AND ToolNameI3D = {toolNameI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(1, rowCount);
Assert.Equal(8, count);
}
}
}
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertMcpToolUsage_InsertNew : EndToEndTest
{
public TelemetryUpsertMcpToolUsage_InsertNew(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
int toolNameI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveMcpToolNameI3Ds(new[] { "create_ticket" });
Assert.True(resolve.IsSuccess);
toolNameI3D = resolve.Data["create_ticket"];
});
var increments = new List<McpToolUsageBucketIncrement>
{
new() { UserID = 11, ToolNameI3D = toolNameI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucket, Increment = 7 }
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertMcpToolUsageBatch(increments);
Assert.True(result.IsSuccess);
});
var count = this.Sql<int>(
$"SELECT [Count] FROM dbo.McpToolUsageTelemetry WHERE UserID = 11 AND ToolNameI3D = {toolNameI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(7, count);
}
}
}
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
public class TelemetryUpsertMcpToolUsage_MixedInsertAndUpdate : EndToEndTest
{
public TelemetryUpsertMcpToolUsage_MixedInsertAndUpdate(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
int toolAI3D = 0, toolBI3D = 0;
this.WithSession(session =>
{
var resolve = session.GetBL<TelemetryBL>().ResolveMcpToolNameI3Ds(new[] { "tool_a", "tool_b" });
Assert.True(resolve.IsSuccess);
toolAI3D = resolve.Data["tool_a"];
toolBI3D = resolve.Data["tool_b"];
});
this.Sql($@"
INSERT INTO dbo.McpToolUsageTelemetry (UserID, ToolNameI3D, HardwareIDI3D, ToolMode, BucketStartUtc, [Count])
VALUES (11, {toolAI3D}, 0, 0, '2026-05-02T12:15:00', 4)");
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
var increments = new List<McpToolUsageBucketIncrement>
{
new() { UserID = 11, ToolNameI3D = toolAI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucket, Increment = 2 },
new() { UserID = 11, ToolNameI3D = toolBI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucket, Increment = 1 },
new() { UserID = 12, ToolNameI3D = toolAI3D, ToolMode = McpToolMode.User, BucketStartUtc = bucket, Increment = 9 }
};
this.WithSession(session =>
{
var result = session.GetBL<TelemetryBL>().UpsertMcpToolUsageBatch(increments);
Assert.True(result.IsSuccess);
});
Assert.Equal(6, this.Sql<int>($"SELECT [Count] FROM dbo.McpToolUsageTelemetry WHERE UserID = 11 AND ToolNameI3D = {toolAI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'"));
Assert.Equal(1, this.Sql<int>($"SELECT [Count] FROM dbo.McpToolUsageTelemetry WHERE UserID = 11 AND ToolNameI3D = {toolBI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'"));
Assert.Equal(9, this.Sql<int>($"SELECT [Count] FROM dbo.McpToolUsageTelemetry WHERE UserID = 12 AND ToolNameI3D = {toolAI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'"));
Assert.Equal(3, this.Sql<int>("SELECT COUNT(*) FROM dbo.McpToolUsageTelemetry WHERE BucketStartUtc = '2026-05-02T12:15:00'"));
}
}
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Telemetry;
using Centron.Data.Entities.Telemetry;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Telemetry
{
/// <summary>
/// Validates the HOLDLOCK / UPDLOCK guards added in Phase 3:
/// - Concurrent UpsertMcpToolUsageBatch calls on the same key must NOT throw and must produce
/// exactly one row whose Count equals the sum of all increments.
/// - Concurrent ResolveMcpToolNameI3Ds calls with overlapping names must NOT throw and the
/// lookup table must end up with exactly one row per distinct name.
/// </summary>
public class TelemetryUpsert_ConcurrentFlush_NoDuplicatesOrErrors : EndToEndTest
{
public TelemetryUpsert_ConcurrentFlush_NoDuplicatesOrErrors(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
const int parallelism = 8;
const int incrementPerTask = 25;
var bucket = new DateTime(2026, 5, 2, 12, 15, 0, DateTimeKind.Utc);
var sharedToolNames = new[] { "concurrent_a", "concurrent_b", "concurrent_c" };
// -------- Resolve race: 8 parallel resolves, overlapping names --------
var resolveTasks = Enumerable.Range(0, parallelism).Select(_ => Task.Run(() =>
{
using var bls = new BLSession();
var result = bls.GetBL<TelemetryBL>().ResolveMcpToolNameI3Ds(sharedToolNames);
Assert.True(result.IsSuccess, $"ResolveMcpToolNameI3Ds failed: {result.Message}");
return result.Data;
})).ToArray();
Task.WaitAll(resolveTasks);
var firstResolve = resolveTasks[0].Result;
foreach (var task in resolveTasks)
{
foreach (var name in sharedToolNames)
Assert.Equal(firstResolve[name], task.Result[name]);
}
foreach (var name in sharedToolNames)
{
var rowCount = this.Sql<int>($"SELECT COUNT(*) FROM dbo.McpToolNameLookup WHERE Name = '{name}'");
Assert.Equal(1, rowCount);
}
// -------- Upsert race: many parallel batches, identical bucket key --------
var toolI3D = firstResolve["concurrent_a"];
// Mirror real aggregator behavior: one source row per merge key (already deduplicated
// by the in-memory dictionary). Parallel tasks contend on the same target row.
var upsertTasks = Enumerable.Range(0, parallelism).Select(_ => Task.Run(() =>
{
var increments = new List<McpToolUsageBucketIncrement>
{
new()
{
UserID = 77,
ToolNameI3D = toolI3D,
ToolMode = McpToolMode.User,
BucketStartUtc = bucket,
Increment = incrementPerTask,
}
};
using var bls = new BLSession();
var result = bls.GetBL<TelemetryBL>().UpsertMcpToolUsageBatch(increments);
Assert.True(result.IsSuccess, $"UpsertMcpToolUsageBatch failed: {result.Message}");
})).ToArray();
Task.WaitAll(upsertTasks);
var bucketRowCount = this.Sql<int>(
$"SELECT COUNT(*) FROM dbo.McpToolUsageTelemetry WHERE UserID = 77 AND ToolNameI3D = {toolI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(1, bucketRowCount);
var totalCount = this.Sql<int>(
$"SELECT [Count] FROM dbo.McpToolUsageTelemetry WHERE UserID = 77 AND ToolNameI3D = {toolI3D} AND ToolMode = 0 AND BucketStartUtc = '2026-05-02T12:15:00'");
Assert.Equal(parallelism * incrementPerTask, totalCount);
}
}
}