Three routes now deliver truth data -- a sidecar, a worker push, and a fetched
manifest -- and once stored they were indistinguishable. The truth file records
nothing about how it arrived, so a locally computed sidecar and a loose-tier
manifest from a third-party server looked identical to every reader, despite
making claims of very different strength about the same item.
TruthProvenance records source, server, match tier, applied offset and caveat.
GET /Items/{itemId}/Provenance serves it, and JR-036's loose-tier caveat now
has somewhere to come from.
Two decisions carried in the code rather than assumed:
Provenance is stored BESIDE the truth file, never inside it. Injecting fields
would mean the bytes served back are not the bytes the producer wrote, which is
the property JR-004 turns on. UT-026 pins it by asserting the stored truth JSON
contains no provenance keys.
The applied offset is recorded because it is otherwise unrecoverable. Once
JR-030 shifts every window the timings look native, and nothing else would say
they had been shifted -- which matters when diagnosing an overlay that is
consistently a few seconds out.
A sidecar's provenance is derived rather than stored: it is local, and its
timestamp is the file's own. Precedence resolves through the same rule as
GetTruthAsync, because resolving it twice by different rules is how the two
would drift.
Fourth mutation check: stopping Delete from removing provenance fails UT-027
alone -- a stale record would otherwise outlive its claim and describe data the
next fetch had already replaced.
TRACES: UT-024, UT-025, UT-026, UT-027, UT-028 | JR-010
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Jellyfin.Plugin.JRay.Models;
|
|
|
|
namespace Jellyfin.Plugin.JRay.Services.Interfaces;
|
|
|
|
/// <summary>
|
|
/// Loads and caches scene-actor-extraction "truth" files for library items.
|
|
/// </summary>
|
|
public interface ITruthDataService
|
|
{
|
|
/// <summary>
|
|
/// Gets the truth file for the given library item, if one exists.
|
|
/// </summary>
|
|
/// <param name="itemId">The Jellyfin library item id.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>The parsed truth file, or null if no truth file exists for this item.</returns>
|
|
Task<TruthFile?> GetTruthAsync(Guid itemId, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Gets how the item's truth data was obtained, or null if it has none.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Resolves the same precedence as <see cref="GetTruthAsync"/>: managed
|
|
/// truth (pushed or fetched) wins, and a sidecar is reported as such.
|
|
/// </remarks>
|
|
/// <param name="itemId">The Jellyfin library item id.</param>
|
|
/// <returns>The provenance of the truth data that would be served.</returns>
|
|
TruthProvenance? GetProvenance(Guid itemId);
|
|
|
|
/// <summary>
|
|
/// Removes any cached truth file for the given item, so the next
|
|
/// <see cref="GetTruthAsync"/> call re-reads from the managed store or sidecar file.
|
|
/// </summary>
|
|
/// <param name="itemId">The Jellyfin library item id.</param>
|
|
void Invalidate(Guid itemId);
|
|
|
|
/// <summary>
|
|
/// Cheaply checks whether truth data exists for an item (managed upload
|
|
/// or sidecar file), without loading or caching it.
|
|
/// </summary>
|
|
/// <param name="itemId">The Jellyfin library item id.</param>
|
|
/// <param name="itemPath">The item's media file path.</param>
|
|
/// <returns><c>true</c> if truth data exists for this item.</returns>
|
|
bool HasTruth(Guid itemId, string itemPath);
|
|
}
|