Files
histsdk/docs/plans
dohertj2 b3d22befd0 write-commands plan: AddS2 prereq is architectural - not implementable as generic client write
Three follow-up attempts to satisfy the AddS2 server-cache prereq all
failed at the same client-side gate before any AddS2 byte reached the
wire:

1. TagKey synthetic→real override. First attempt used the placeholder
   TagKey=10000000 returned by HistorianAccess.AddTag. Native
   AddStreamedValue refused with error 168 "Tag not added to server".
   Harness now ALWAYS resolves the real wwTagKey from Runtime.dbo.Tag
   after AddTag (logged as TagKeyOverride: Synthetic→RealFromSql).
   Error code shifted to 129 "Tag not found in cache" — request now
   reaches the server but the server's in-memory tag cache doesn't
   know about the new tag.

2. Server-cache settle wait. Up to 8s sleep between AddTag and
   AddStreamedValue (--write-resync-wait-seconds N). Wait period
   contains 2× UpdC3 + 2× Trx/GetV keep-alives but no server-side
   cache update — error 129 persists.

3. Fresh process / fresh connection. Skipped AddTag entirely
   (--write-skip-add-tag) and ran AddStreamedValue alone against the
   already-existing sandbox tag. New native client instance, new
   client-side cache, new server session. SAME error 129 — no AddS2
   bytes sent on wire. Capture confirms 44 records ending in Close2.

Interpretation: the Historian engine's runtime tag cache only ingests
tags from configured IOServers / Application Server data pipelines,
not from HistorianAccess.AddTag-only client flows. AddTag populates
Runtime.dbo.Tag (wwTagKey=240 was created) but doesn't register the
tag with the live cache that AddStreamedValue checks. That
registration happens server-side when an upstream data producer (an
OPC driver, AnE event subsystem, Application Server attribute store)
claims the tag.

WriteValueAsync therefore CANNOT be implemented as a generic client
API against this server architecture. The SDK's realistic writeable
surface is now narrowed to EnsureTagAsync + DeleteTagAsync only.

Harness changes:
- --write-skip-add-tag    skip the AddTag call (for fresh-cache test)
- --write-skip-add-value  skip the AddStreamedValue call (capture EnsT2 only)
- --write-resync-wait-seconds N  sleep N seconds between AddTag and
                                  AddStreamedValue (default 0)
- TagKey lookup now ALWAYS hits SQL after AddTag, not just when
  the synthetic key is 0.

Plan doc updated with full Phase 2 follow-on findings + revised
remaining work (4-item checklist focused on EnsureTagAsync/
DeleteTagAsync, plus a stretch goal of probing AddRevisionValues*
against an existing-tag).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 08:06:28 -04:00
..