Prepare shared Context Intent author draft operations
This commit is contained in:
parent
9a3f4fbb21
commit
b76af35ecd
@ -1,7 +1,10 @@
|
||||
# Context Intent task 67: preparation and schema release prerequisite
|
||||
# Context Intent task 67: implementation checkpoint
|
||||
|
||||
Status: partial implementation, not ready for acceptance. No migration, database
|
||||
change or deployment has been performed. The task remains incomplete.
|
||||
Status: partial implementation, not ready for acceptance. No task-67 migration,
|
||||
database change or deployment has been performed. The task remains incomplete.
|
||||
The former schema-release blocker is resolved: use the installed controller route
|
||||
and `Docs/Deployment/AutomaticDevelopment.md` under standing Development authority.
|
||||
Do not request individual routine Development SQL approval.
|
||||
|
||||
## Implemented preparation
|
||||
|
||||
@ -30,6 +33,31 @@ paid verification workflow or change its contracts.
|
||||
There is no Context endpoint, palette data loader, UI or persistence wired to this
|
||||
utility yet. Passing these tests does not establish feature acceptance.
|
||||
|
||||
## Shared draft editing preparation (2 December 2026)
|
||||
|
||||
`ContextIntentDraft` implements unsaved author operations for reuse by Context and
|
||||
Writer. It is not registered with an endpoint or presented as a working feature.
|
||||
It supports atomic reviewed-paste addition, explicit manual completion without
|
||||
prose, editing/changed flag/notes, stable-key reorder/removal, identity-selected
|
||||
entity links and independent covered state, and scoped quote evidence with an
|
||||
explicit completion choice. It never calls matching, facts, relationship/event
|
||||
creation, AI, manuscript navigation, sync or candidate acceptance.
|
||||
|
||||
Snapshots defensively copy attachment collections. Invalid edits, paste batches
|
||||
and evidence leave existing work intact. Bounds cover items, text, notes, links
|
||||
and evidence. Evidence is restricted to the draft book/chapter and optional scene;
|
||||
accepted revision and paragraph identities remain opaque optional source labels.
|
||||
The persistence/editor adapter still must verify those labels and canonical scope
|
||||
against accepted server data rather than trusting a client submission. A palette
|
||||
passed to `LinkEntity` must already be authorised; persistence must independently
|
||||
revalidate every identity. No authorisation is implied by this pure helper.
|
||||
|
||||
`ContextIntentDraftTests` exercises state transitions including ambiguous names,
|
||||
link/coverage/completion separation, scope rejection, invalid-batch atomicity,
|
||||
reorder identity, attachment bounds and defensive copies. Focused invocation:
|
||||
`dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj -- --context-intent-draft`.
|
||||
The full harness includes it as well.
|
||||
|
||||
## Concrete storage proposal for the remaining implementation
|
||||
|
||||
Keep `ChapterGoals` and existing scene purpose/outcome fields authoritative. Keep
|
||||
@ -47,7 +75,8 @@ into an independent Intent document. Extend that checklist to support chapter it
|
||||
| Permissions | Reuse book/project access and `ContextEditPolicy`; independently validate scope and edit permission in stored procedures. All mutations require antiforgery. |
|
||||
| Lifecycle | Item children delete with the item. Chapter/book/project deletion and restore explicitly include chapter items; no orphaned metadata. Entity archival/merge must retain meaningful author evidence and resolve current identity through canonical references. |
|
||||
|
||||
This is a proposed schema contract, not an approved or qualified SQL migration.
|
||||
This is a proposed schema contract, not a qualified SQL migration. Routine
|
||||
Development implementation/qualification/deployment has standing owner authority.
|
||||
Recheck the next migration number when implementing (339 was the latest numeric
|
||||
prefix at discovery). Never edit existing numbered scripts.
|
||||
|
||||
@ -90,23 +119,27 @@ accepted Word manuscript updates through the existing accepted-source contract.
|
||||
Use theme controls, collapsible/resizable palette and `PlotDirector.toast`.
|
||||
|
||||
Run the solution build, regression harness, focused UI/concurrency tests and schema
|
||||
qualification. After a reviewed schema release to Development, verify the full
|
||||
qualification. After an automatically qualified schema release to Development, verify the full
|
||||
deployed commit and use the registered ordinary browser fixture for real manual
|
||||
checklist/entity-link/evidence persistence after reload and fresh login, held-scope
|
||||
SignalR refresh, chapter-only/no-prose use and cleanup. Record receipts, feature URL,
|
||||
actual outcomes and limitations in CYJ. Production is excluded.
|
||||
|
||||
## Deployment gate requiring operator assistance
|
||||
## Resolved deployment prerequisite and continuation
|
||||
|
||||
`Docs/Codex/Deployment.md`, “SQL changes and recovery”, requires an explicit reviewed
|
||||
plan qualified against Development's schema. The installed unattended route invokes
|
||||
the routine code-only publisher. `Tools/Deployment/development_release.py` explicitly
|
||||
rejects any `PlotLine/Sql` changes relative to its approved baseline with:
|
||||
“Schema changes require a separately reviewed/qualified migration plan”.
|
||||
Assistance stage 125 is resolved. The installed permanent Development schema route
|
||||
now qualifies pending migrations on disposable restored copies, maintains backup
|
||||
and migration history, and activates through the existing controller boundary.
|
||||
Use the installed `deployment-request` / `deployment-result` commands for
|
||||
`application-development`; no worker sudo, signing access or per-release routine
|
||||
SQL approval. Read `Docs/Codex/Deployment.md`,
|
||||
`Docs/Deployment/AutomaticDevelopment.md` and the installed toolkit `DEPLOYMENT.md`
|
||||
before requesting a release. Reconcile any uncertain receipt before retrying.
|
||||
|
||||
The worker must not bypass that guard, invoke sudo, access signing material, manually
|
||||
apply SQL or change the baseline. An operator must identify/provision the authorised
|
||||
schema qualification and activation route for this task. This is a deployment
|
||||
prerequisite, not a request to reopen the agreed Intent product design. Resume from
|
||||
the committed preparation and this contract once that route is supplied; do not
|
||||
claim Development readiness or mark task 67 complete in the meantime.
|
||||
The resumed source branch is `feature/context-intent-67-resume`, based on
|
||||
`9a3f4fbb` and including the original preparation commit `5bee47e6`. No task-67
|
||||
external write or deployment has occurred to reconcile. Do not treat preparation
|
||||
helpers or passing pure tests as feature acceptance. Required endpoint/persistence,
|
||||
shared UI, palette loading/search, accepted Word updates, Hold/Follow refresh,
|
||||
backup/restore/deletion integration, schema qualification, Development deployment
|
||||
and genuine browser persistence/reload acceptance all remain outstanding.
|
||||
|
||||
96
PlotLine.Tests/ContextIntentDraftTests.cs
Normal file
96
PlotLine.Tests/ContextIntentDraftTests.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using PlotLine.Services.Context;
|
||||
using static PlotLine.Services.Context.ContextIntentDraft;
|
||||
|
||||
internal static class ContextIntentDraftTests
|
||||
{
|
||||
public static void Run()
|
||||
{
|
||||
static void Check(bool condition, string message) { if (!condition) throw new Exception(message); }
|
||||
static void Reject(Action action) { try { action(); } catch (ArgumentException) { return; } throw new Exception("Expected rejected Intent operation."); }
|
||||
var chapter = new Scope(10, 20);
|
||||
var draft = new ContextIntentDraft(chapter);
|
||||
var first = draft.Add("Reveal the disagreement");
|
||||
draft.AddPreview(ContextIntentText.Parse("- [x] Keep the promise\n- [ ] Reveal the disagreement"));
|
||||
Check(draft.Items.Count == 3 && draft.Items[1].Completed && !draft.Items[2].Completed, "Reviewed preview preserves explicit checked choices and duplicate author objectives.");
|
||||
var last = draft.Items[2].Key;
|
||||
draft.Complete(first, true);
|
||||
Check(draft.Items[0].Key == first && draft.Items[0].Completed, "Manual completion works without prose and does not reorder.");
|
||||
draft.Edit(first, " Revise the disagreement ", "Author note", true);
|
||||
Check(draft.Items[0] is { Text: "Revise the disagreement", Notes: "Author note", Changed: true, Completed: true }, "Editing/changed flag preserves manual completion.");
|
||||
draft.Complete(first, false);
|
||||
|
||||
ContextIntentText.Entity[] palette = [
|
||||
new("character:1", "Captain", [], ["Recorded appearance"]),
|
||||
new("candidate:2", "Captain", [], ["Candidate · unconfirmed"])
|
||||
];
|
||||
var ambiguous = ContextIntentText.Match("Captain", palette).Single();
|
||||
Check(ambiguous.Ambiguous && draft.Items[0].Links.Count == 0, "Matching an ambiguous occurrence does not mutate the draft.");
|
||||
Reject(() => draft.LinkEntity(first, "Captain", palette));
|
||||
Reject(() => draft.LinkEntity(first, "character:99", palette));
|
||||
draft.LinkEntity(first, "candidate:2", palette);
|
||||
draft.LinkEntity(first, "candidate:2", palette);
|
||||
Check(draft.Items[0].Links.Count == 1 && !draft.Items[0].Links[0].Covered && !draft.Items[0].Completed, "Linking a selected candidate is idempotent and never confirms/marks covered/completes.");
|
||||
draft.CoverEntity(first, "candidate:2", true);
|
||||
Check(draft.Items[0].Links[0].Covered && !draft.Items[0].Completed, "Explicit entity coverage remains independent of item completion.");
|
||||
Reject(() => draft.CoverEntity(first, "character:1", true));
|
||||
draft.LinkEntity(first, "character:1", palette);
|
||||
Check(draft.Items[0].Links.Count == 2, "Different identities sharing a label remain distinct.");
|
||||
|
||||
var passage = new Evidence(new Scope(10, 20, 30), "An author-selected passage.", "accepted-revision-1", "paragraph-1");
|
||||
draft.AddEvidence(first, passage, false);
|
||||
Check(draft.Items[0].Evidence.Count == 1 && !draft.Items[0].Completed, "Attaching evidence requires an independent completion choice.");
|
||||
draft.AddEvidence(first, passage with { Passage = "A second passage." }, true);
|
||||
Check(draft.Items[0].Completed && draft.Items[0].Evidence[0] == passage, "Explicit evidence completion retains source identity and previous quote.");
|
||||
Reject(() => draft.AddEvidence(first, passage with { Source = new Scope(11, 20, 30) }, true));
|
||||
Reject(() => draft.AddEvidence(first, passage with { Source = new Scope(10, 21, 30) }, true));
|
||||
Reject(() => draft.AddEvidence(first, passage with { Passage = " " }, true));
|
||||
Check(draft.Items[0].Evidence.Count == 2, "Rejected evidence is atomic.");
|
||||
draft.RemoveEvidence(first, 0);
|
||||
Check(draft.Items[0].Completed, "Removing evidence does not silently undo manual completion.");
|
||||
|
||||
draft.Move(last, 0);
|
||||
Check(draft.Items[0].Key == last && draft.Items[1].Key == first, "Drag/keyboard move uses stable identity and author order.");
|
||||
Reject(() => draft.Move(first, 3));
|
||||
Reject(() => draft.Move(Guid.NewGuid(), 0));
|
||||
draft.Move(last, 2);
|
||||
Check(draft.Items[2].Key == last, "Downward movement uses final destination index.");
|
||||
var before = draft.Items.ToArray();
|
||||
Reject(() => draft.AddPreview([new("Valid first item", false), new(new string('x', 301), false)]));
|
||||
Check(draft.Items.SequenceEqual(before), "An invalid paste cannot add an earlier valid item.");
|
||||
Reject(() => draft.Edit(first, " ", "", false));
|
||||
Reject(() => draft.Edit(first, "Valid", new string('x', MaximumNotesLength + 1), false));
|
||||
Check(draft.Items.SequenceEqual(before), "Rejected edits retain all local work.");
|
||||
draft.UnlinkEntity(first, "candidate:2");
|
||||
Check(draft.Items[0].Completed && draft.Items[0].Links.Single().EntityKey == "character:1", "Removing a link does not affect completion or another identity.");
|
||||
|
||||
var sceneDraft = new ContextIntentDraft(new Scope(10, 20, 31));
|
||||
var sceneItem = sceneDraft.Add("Scene objective");
|
||||
Reject(() => sceneDraft.AddEvidence(sceneItem, passage, true));
|
||||
Check(!sceneDraft.Items.Single().Completed, "Evidence from another scene cannot complete a scene-scoped item.");
|
||||
sceneDraft.AddEvidence(sceneItem, passage with { Source = new Scope(10, 20, 31) }, true);
|
||||
for (var i = 1; i < MaximumEvidence; i++) sceneDraft.AddEvidence(sceneItem, passage with { Source = new Scope(10, 20, 31) }, false);
|
||||
Reject(() => sceneDraft.AddEvidence(sceneItem, passage with { Source = new Scope(10, 20, 31) }, false));
|
||||
Check(sceneDraft.Items.Single().Evidence.Count == MaximumEvidence, "Attachment count is bounded without losing existing evidence.");
|
||||
|
||||
var links = new List<Link> { new("character:1", false) };
|
||||
var evidence = new List<Evidence> { passage };
|
||||
var imported = new Item(Guid.NewGuid(), 5, "Saved objective", false, false, "", links, evidence);
|
||||
var loaded = new ContextIntentDraft(chapter, [imported]);
|
||||
links.Clear(); evidence.Clear();
|
||||
Check(loaded.Items.Single().Links.Count == 1 && loaded.Items.Single().Evidence.Count == 1, "Loaded collections are defensively copied.");
|
||||
var readOnly = false;
|
||||
try { ((IList<Link>)loaded.Items.Single().Links).Add(new("asset:3", false)); }
|
||||
catch (NotSupportedException) { readOnly = true; }
|
||||
Check(readOnly, "Presentation callers cannot change attachment collections outside explicit operations.");
|
||||
Reject(() => new ContextIntentDraft(chapter, [imported, imported]));
|
||||
Reject(() => new ContextIntentDraft(chapter, [imported, imported with { Key = Guid.NewGuid() }]));
|
||||
Reject(() => new ContextIntentDraft(new Scope(0, 20)));
|
||||
Reject(() => new ContextIntentDraft(new Scope(10, 20, 0)));
|
||||
var full = new ContextIntentDraft(chapter);
|
||||
full.AddPreview(Enumerable.Repeat(new ContextIntentText.PreviewItem("Objective", false), ContextIntentText.MaximumItems));
|
||||
Reject(() => full.Add("One too many"));
|
||||
Check(full.Items.Count == ContextIntentText.MaximumItems, "Checklist bounds retain every reviewed objective.");
|
||||
draft.Remove(last);
|
||||
Check(draft.Items.Count == 2, "Explicit removal affects only the selected item.");
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,7 @@ if(args.Contains("--context-metrics")){ContextMetricsTests.Run();return;}
|
||||
if(args.Contains("--scene-creation")){await SceneCreationTests.Run();return;}
|
||||
if(args.Contains("--help-visibility")){HelpVisibilityTests.Run();return;}
|
||||
if(args.Contains("--context-intent-text")){ContextIntentTextTests.Run();Console.WriteLine("PASS Context Intent paste preview, identity deduplication and deterministic passage matching");return;}
|
||||
if(args.Contains("--context-intent-draft")){ContextIntentDraftTests.Run();Console.WriteLine("PASS Context Intent author draft editing, explicit coverage and scoped evidence");return;}
|
||||
if(args.Contains("--application-domain")){ApplicationDomainBoundaryTests.Run();return;}
|
||||
if(args.Contains("--spatial-context-database")){await SpatialContextDatabaseTests.Run(args.Last());return;}
|
||||
if(args.Contains("--location-taxonomy-fixture")){await LocationsWorkspaceDatabaseTests.ExportTaxonomy(args[^2],args[^1]);return;}
|
||||
@ -249,6 +250,7 @@ var tests = new (string Name, Action Test)[]
|
||||
("Context Threads narrative history and scope",ContextThreadsTests.Run),
|
||||
("Context character narrative projection and focused editing",()=>ContextCharacterTests.Run().GetAwaiter().GetResult()),
|
||||
("Context Intent deterministic text preparation",ContextIntentTextTests.Run),
|
||||
("Context Intent author draft operations",ContextIntentDraftTests.Run),
|
||||
("Context My Windows routing and lifecycle",ContextWindowsTests.Run),
|
||||
("Context committed-save notifications and scope",()=>ContextSavedDataTests.Run().GetAwaiter().GetResult()),
|
||||
("Context main-page navigation safety and delegated link coverage",ContextWorkspaceNavigationTests.Run),
|
||||
|
||||
183
PlotLine/Services/Context/ContextIntentDraft.cs
Normal file
183
PlotLine/Services/Context/ContextIntentDraft.cs
Normal file
@ -0,0 +1,183 @@
|
||||
namespace PlotLine.Services.Context;
|
||||
|
||||
/// <summary>
|
||||
/// Shared editing state for the Context and Writer presentations. This is an
|
||||
/// unsaved author draft, never a source of story facts or manuscript positions.
|
||||
/// Persistence adapters must authorise the scope and every linked identity again.
|
||||
/// </summary>
|
||||
public sealed class ContextIntentDraft
|
||||
{
|
||||
public sealed record Scope(int BookID, int ChapterID, int? SceneID = null);
|
||||
public sealed record Link(string EntityKey, bool Covered);
|
||||
public sealed record Evidence(Scope Source, string Passage, string? AcceptedRevision = null,
|
||||
string? ParagraphIdentity = null);
|
||||
public sealed record Item(Guid Key, int? SavedItemID, string Text, bool Completed,
|
||||
bool Changed, string Notes, IReadOnlyList<Link> Links, IReadOnlyList<Evidence> Evidence);
|
||||
|
||||
public const int MaximumNotesLength = 4_000;
|
||||
public const int MaximumLinks = 100;
|
||||
public const int MaximumEvidence = 20;
|
||||
private readonly List<Item> items = [];
|
||||
public Scope Position { get; }
|
||||
// Presentation callers cannot mutate the ordered backing list.
|
||||
public IReadOnlyList<Item> Items => items.AsReadOnly();
|
||||
|
||||
public ContextIntentDraft(Scope position, IEnumerable<Item>? existing = null)
|
||||
{
|
||||
ValidateScope(position);
|
||||
Position = position;
|
||||
if (existing is null) return;
|
||||
var rows = existing.Take(ContextIntentText.MaximumItems + 1).ToArray();
|
||||
if (rows.Length > ContextIntentText.MaximumItems || rows.Select(x => x.Key).Distinct().Count() != rows.Length ||
|
||||
rows.Where(x => x.SavedItemID.HasValue).Select(x => x.SavedItemID).Distinct().Count() != rows.Count(x => x.SavedItemID.HasValue))
|
||||
throw new ArgumentException("Invalid or duplicate Intent items.");
|
||||
foreach (var row in rows)
|
||||
{
|
||||
ValidateItem(row);
|
||||
items.Add(Freeze(row));
|
||||
}
|
||||
}
|
||||
|
||||
public Guid Add(string text)
|
||||
{
|
||||
var row = New(text, false);
|
||||
EnsureCapacity(1);
|
||||
items.Add(row);
|
||||
return row.Key;
|
||||
}
|
||||
|
||||
// Apply the author's reviewed preview in one operation. Parsing alone never
|
||||
// invokes this method, and a rejected batch must leave the whole draft intact.
|
||||
public void AddPreview(IEnumerable<ContextIntentText.PreviewItem> reviewed)
|
||||
{
|
||||
var rows = reviewed.Take(ContextIntentText.MaximumItems + 1).Select(x => New(x.Text, x.RequestedCompleted)).ToArray();
|
||||
EnsureCapacity(rows.Length);
|
||||
items.AddRange(rows);
|
||||
}
|
||||
|
||||
public void Edit(Guid key, string text, string notes, bool changed)
|
||||
{
|
||||
var index = Index(key);
|
||||
var row = items[index] with { Text = text.Trim(), Notes = notes, Changed = changed };
|
||||
ValidateItem(row);
|
||||
items[index] = row;
|
||||
}
|
||||
|
||||
public void Complete(Guid key, bool completed)
|
||||
{
|
||||
var index = Index(key);
|
||||
items[index] = items[index] with { Completed = completed };
|
||||
}
|
||||
|
||||
// Used by drag reorder and keyboard up/down alike. Completion does not sort.
|
||||
public void Move(Guid key, int destination)
|
||||
{
|
||||
var index = Index(key);
|
||||
if (destination < 0 || destination >= items.Count) throw new ArgumentException("Choose an item position within this checklist.");
|
||||
var row = items[index];
|
||||
items.RemoveAt(index);
|
||||
items.Insert(destination, row);
|
||||
}
|
||||
|
||||
public void Remove(Guid key) => items.RemoveAt(Index(key));
|
||||
|
||||
// Only a selected identity from an already authorised palette may be linked.
|
||||
// A shared spelling is never an identity selection. Linking never completes.
|
||||
public void LinkEntity(Guid key, string entityKey, IReadOnlyList<ContextIntentText.Entity> authorisedPalette)
|
||||
{
|
||||
var index = Index(key);
|
||||
if (!authorisedPalette.Any(e => e.Key == entityKey)) throw new ArgumentException("Choose an available Story Element identity.");
|
||||
var row = items[index];
|
||||
if (row.Links.Any(link => link.EntityKey == entityKey)) return;
|
||||
var updated = row with { Links = Array.AsReadOnly(row.Links.Append(new Link(entityKey, false)).ToArray()) };
|
||||
ValidateItem(updated);
|
||||
items[index] = updated;
|
||||
}
|
||||
|
||||
public void CoverEntity(Guid key, string entityKey, bool covered)
|
||||
{
|
||||
var index = Index(key);
|
||||
var row = items[index];
|
||||
if (!row.Links.Any(link => link.EntityKey == entityKey)) throw new ArgumentException("Link the selected Story Element first.");
|
||||
items[index] = row with { Links = Array.AsReadOnly(row.Links.Select(link => link.EntityKey == entityKey ? link with { Covered = covered } : link).ToArray()) };
|
||||
}
|
||||
|
||||
public void UnlinkEntity(Guid key, string entityKey)
|
||||
{
|
||||
var index = Index(key);
|
||||
items[index] = items[index] with { Links = Array.AsReadOnly(items[index].Links.Where(link => link.EntityKey != entityKey).ToArray()) };
|
||||
}
|
||||
|
||||
// Evidence is an author-selected quote, not an inferred event. The future
|
||||
// editor adapter supplies accepted revision/paragraph identities; these opaque
|
||||
// values must never be interpreted as Word offsets or navigation commands.
|
||||
public void AddEvidence(Guid key, Evidence evidence, bool complete)
|
||||
{
|
||||
var index = Index(key);
|
||||
var row = items[index];
|
||||
var updated = row with
|
||||
{
|
||||
Evidence = Array.AsReadOnly(row.Evidence.Append(evidence).ToArray()),
|
||||
Completed = complete || row.Completed
|
||||
};
|
||||
ValidateItem(updated);
|
||||
items[index] = updated;
|
||||
}
|
||||
|
||||
public void RemoveEvidence(Guid key, int evidenceIndex)
|
||||
{
|
||||
var index = Index(key);
|
||||
var row = items[index];
|
||||
if (evidenceIndex < 0 || evidenceIndex >= row.Evidence.Count) throw new ArgumentException("Choose existing passage evidence.");
|
||||
items[index] = row with { Evidence = Array.AsReadOnly(row.Evidence.Where((_, i) => i != evidenceIndex).ToArray()) };
|
||||
}
|
||||
|
||||
private void ValidateItem(Item row)
|
||||
{
|
||||
if (row.Key == Guid.Empty || row.SavedItemID <= 0 || string.IsNullOrWhiteSpace(row.Text) ||
|
||||
row.Text.Length > ContextIntentText.MaximumItemLength || row.Notes is null || row.Notes.Length > MaximumNotesLength ||
|
||||
row.Links is null || row.Evidence is null || row.Links.Count > MaximumLinks || row.Evidence.Count > MaximumEvidence)
|
||||
throw new ArgumentException("Check the Intent text, notes and attachment limits.");
|
||||
if (row.Links.Any(link => string.IsNullOrWhiteSpace(link.EntityKey) || link.EntityKey.Length > 200) ||
|
||||
row.Links.Select(link => link.EntityKey).Distinct(StringComparer.Ordinal).Count() != row.Links.Count)
|
||||
throw new ArgumentException("Choose distinct Story Element identities.");
|
||||
foreach (var evidence in row.Evidence)
|
||||
{
|
||||
ValidateScope(evidence.Source);
|
||||
if (evidence.Source.BookID != Position.BookID || evidence.Source.ChapterID != Position.ChapterID ||
|
||||
Position.SceneID.HasValue && evidence.Source.SceneID != Position.SceneID ||
|
||||
string.IsNullOrWhiteSpace(evidence.Passage) || evidence.Passage.Length > ContextIntentText.MaximumPassageLength ||
|
||||
evidence.AcceptedRevision?.Length > 200 || evidence.ParagraphIdentity?.Length > 200)
|
||||
throw new ArgumentException("Choose a passage within this Intent scope.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateScope(Scope position)
|
||||
{
|
||||
if (position.BookID <= 0 || position.ChapterID <= 0 || position.SceneID <= 0)
|
||||
throw new ArgumentException("Choose a saved chapter and optional saved scene.");
|
||||
}
|
||||
|
||||
private Item New(string text, bool completed)
|
||||
{
|
||||
var row = new Item(Guid.NewGuid(), null, text.Trim(), completed, false, "", [], []);
|
||||
ValidateItem(row);
|
||||
return Freeze(row);
|
||||
}
|
||||
|
||||
private static Item Freeze(Item row) => row with
|
||||
{
|
||||
Links = Array.AsReadOnly(row.Links.ToArray()), Evidence = Array.AsReadOnly(row.Evidence.ToArray())
|
||||
};
|
||||
|
||||
private void EnsureCapacity(int added)
|
||||
{
|
||||
if (added > ContextIntentText.MaximumItems - items.Count) throw new ArgumentException("Keep at most 200 items in one Intent scope.");
|
||||
}
|
||||
|
||||
private int Index(Guid key)
|
||||
{
|
||||
var index = items.FindIndex(row => row.Key == key);
|
||||
return index >= 0 ? index : throw new ArgumentException("Choose an existing Intent item.");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user