Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.CapabilityOnly.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.ConstructorGuard.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.NoCacheMetadata.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.NoConsent.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.NoRequestGuard.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.NoSaveGuard.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.OverrideArn.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.RegistryPrices.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.SelectedRegion.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.UnfixedRouting.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/architecture/tla/BedrockErgo.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 132 additions & 0 deletions docs/architecture/tla/BedrockErgo.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---- MODULE BedrockErgo ----
\* Sources: inference settings, validateApiConfiguration, and validateApiConfigurationExcludingModelErrors.
\* Sinks: handler construction, Save, createMessage, and completePrompt. Both request methods share one model entry.
\* Failures: unsupported routing, Global without consent, constructor rejection, and saving invalid settings.
\* Invariants: SupportedProfile, GlobalConsent, ConstructorSafe, and SaveRejectsInvalid.
\* Scope: aliases, explicit profiles, and opaque ARNs. ARN parsing is an input oracle.
\* AWS acceptance is an input: US and Global profiles are supported. Transport is outside this model.
\* Review: PR #2815 supplied findings. Covered: 2; added: 2; gap: 14.
\* Added: SaveRequestAgree and PriceAgreement. Covered: findings 2 and 7, alias routing and explicit profile consent.
\* Gaps: findings 4-6 and 8-18 need code tests or review, including opaque prices and telemetry.
\* The review preceded these invariants. The blind-first step was not possible.
\* Expected: selected regions cause Save disagreement. Registry prices cause reader disagreement.
\* Property test: validate.spec.ts ARN matrix and useSelectedModel.spec.ts Ergo price matrix.
\* Gate: check.sh BedrockErgo and focused provider, validation, and hook tests.
\* Result: fixed config passes. Each defect config fails. Region and price replays fail on the original code.
\* Findings: the review defects recur. No new defect or false alarm was found. Cost: about 20 minutes.
\* Refactor expectation: one resolver preserves routing, rejection, and prices for each reader.
\* Refactor failures: changing explicit routes or treating opaque estimates as a known profile.
\* Refactor invariants: ExplicitRoutePreserved, OpaqueProfileUnknown, and ExpectedPrices.
\* Refactor property test: bedrock-ergo.test.ts route and price matrices.
\* Refactor result: fixed config passes. All eight defect configs fail. No new defect was found.
\* Replay: overriding explicit ARNs fails 10 resolver cases. Ignoring ARN regions fails 35 cases.
\* Simplification: merge non-US classes. States fall from 324 to 216. Every defect witness remains.
\* Refactor cost: about ten minutes. This model does not prove the code correct.
\* Review round 2: PR #2815 summary. Covered: 1 (finding 6, SaveRequestAgree for opaque ARNs).
\* Added: 1 (finding 1, GlobalControlChangesRoute). Gaps: 6 (findings 2-5, 7-8).
\* Gaps need code, error text, test, render, or other-model checks. The model does not inspect code.
\* Expected: route validity and opaque Save acceptance remain unchanged. No new routing defect is expected.
\* Round 2 result: fixed config passes (216 states). All nine defect configs fail. No new defect was found.
\* Real-code checks: both Save validators accept both opaque ARN classes. Both request guards reject invalid aliases.
\* Visibility source: Bedrock.supportsGlobalInference. Sink: request routing through resolveBedrockErgoRoute.
\* Visibility failure: a custom ARN has a Global control that cannot change its route.
\* Expected: the old capability rule exposes a control for fixed ARN routes.
\* Visibility oracle: routeKind and capability. The model does not parse an ARN.
\* Invariants: GlobalControlChangesRoute and RegularGlobalControlPreserved. Property test: Bedrock.spec.tsx visibility matrix.
\* Replay: the old component fails four visibility rows. The fixed component passes all five ARN rows.
\* Result: the capability-only defect violates GlobalControlChangesRoute. No new defect or false alarm was found.
\* Round 2 cost: about ten minutes. Derive visibility without new state variables.
\* Simplification source: getModel settings. Sinks: cached and uncached model returns, request guards, and prices.
\* Failure: one model reader resolves a different route or loses validity when the cache path changes.
\* Expectation: one local route preserves existing invariants for canonical settings. No new defect is expected.
\* Covered: SaveRequestAgree, ExplicitRoutePreserved, OpaqueProfileUnknown, and ExpectedPrices.
\* The cache selection is outside this model. Check it with the provider route matrix on the real code.
\* Simplification result: fixed config passes (216 states). All nine defect configs fail. No new defect was found.
\* Real-code checks: 360 provider tests and 67 resolver tests pass. Type checking accepts the return without an assertion.
\* Cost: about three minutes. No new state variable or invariant was needed.
\* Review round 3: PR #2815 locale key and label-source findings. Covered: 0; added: 0; gap: 2.
\* Gap: the route model does not read locale catalogs or comments. Use the translation and interpolation checks.
\* Expected: missing keys fail the catalog check. Routing states remain unchanged.
\* Result: catalog check reproduces all 17 missing keys, then passes. Both placeholders exist in all 18 locales.
\* Result: interpolation check and lint pass. TLC passes 216 states; all nine defect configs fail.
\* Cost: about four minutes. No routing defect was found. No model state or invariant was added.
\* Review round 4: local search-review thread, head 806e49d443. Covered: 0; added: 1; gap: 1.
\* Added: enabled cache metadata reaches a system checkpoint. Gap: the size advisory is outside this model.
\* Sources: bedrockModels and awsUsePromptCache. Sinks: supportsAwsPromptCache and ConverseStreamCommand.
\* Failures: missing enabled checkpoints, disabled checkpoints, or checkpoints in unsupported message fields.
\* Expected: absent Ergo cache fields violate SystemCacheAgreement. No new routing defect is expected.
\* The finding was read before this extension. This is a review ratchet, not a blind first invariant.
\* Cache metadata is an input oracle. Prompt sizes are below, at, or above the published minimum.
\* Property test: bedrock.spec.ts Ergo cache matrix checks real request payloads across routes and settings.
\* Replay: missing fields fail SystemCacheAgreement and all 36 initial request-matrix rows on the old code.
\* Result: fixed config passes (216 states). All ten defect configs fail. No new defect or false alarm was found.
\* Real-code checks: 72 cache rows, 417 provider tests, and 67 resolver tests pass. Type checking passes.
\* Simplification: quantify cache inputs without new state variables. The state count remains 216.
\* Cost: about ten minutes. The model does not prove the code correct.
EXTENDS TLC, Naturals
CONSTANT RoutingFixed, ConsentGuard, ConstructorGuard, SaveGuard, RequestGuard, SaveRegionFixed, SharedPrices, PreserveArn, GlobalControlFixed, CacheMetadataFixed
VARIABLE input
Inputs == {i \in [region : {"us", "nonUs"}, global : BOOLEAN, cross : BOOLEAN,
arnRegion : {"none", "us", "nonUs"}, kind : {"alias", "profile", "opaque"},
namedProfile : {"us", "global", "unknown"}, entry : {"construct", "save", "request"}] :
(i.kind = "profile" /\ i.namedProfile # "unknown" /\ i.arnRegion # "none") \/
(i.kind = "opaque" /\ i.namedProfile = "unknown" /\ i.arnRegion # "none") \/
(i.kind = "alias" /\ i.namedProfile = "unknown")}
Init == input \in Inputs
Next == UNCHANGED input
Spec == Init /\ [][Next]_input
EffectiveRegion == IF input.arnRegion = "none" THEN input.region ELSE input.arnRegion
ReaderRegion == IF input.entry = "save" /\ ~SaveRegionFixed THEN input.region ELSE EffectiveRegion
UsProfileAllowed == input.cross /\ ReaderRegion = "us"
ExpectedProfile == IF input.kind = "profile" THEN input.namedProfile
ELSE IF input.kind = "opaque" THEN "unknown"
ELSE IF input.global THEN "global"
ELSE IF input.cross /\ EffectiveRegion = "us" THEN "us" ELSE "reject"
Profile == IF PreserveArn /\ input.kind # "alias" THEN
IF input.kind = "profile" THEN input.namedProfile ELSE "unknown"
ELSE IF RoutingFixed THEN
IF input.global THEN "global"
ELSE IF UsProfileAllowed THEN "us"
ELSE IF ConsentGuard THEN "reject" ELSE "global"
ELSE IF input.cross THEN input.region ELSE "bare"
PriceFor(profile) == IF profile = "us" \/ (profile = "unknown" /\ EffectiveRegion = "us")
THEN "us" ELSE "global"
HandlerPrice == PriceFor(Profile)
ViewPrice == IF SharedPrices THEN PriceFor(Profile) ELSE "global"
Outcome == IF input.entry = "construct" THEN
IF ConstructorGuard /\ Profile = "reject" THEN "error" ELSE "ready"
ELSE IF input.entry = "save" /\ ~SaveGuard THEN "saved"
ELSE IF input.entry = "request" /\ ~RequestGuard /\ Profile = "reject" THEN "bare"
ELSE Profile
SupportedProfile == input.entry = "request" => Outcome \in {"us", "global", "reject", "unknown"}
GlobalConsent == input.kind = "alias" /\ Outcome = "global" => input.global
ConstructorSafe == input.entry = "construct" => Outcome = "ready"
SaveRejectsInvalid == input.entry = "save" /\ input.kind = "alias" /\ ~input.global /\ ~UsProfileAllowed
=> Outcome = "reject"

SaveRequestAgree == input.entry = "save" => Outcome = ExpectedProfile
PriceAgreement == ViewPrice = HandlerPrice
ExplicitRoutePreserved == input.kind = "profile" /\ input.entry = "request" => Outcome = input.namedProfile
OpaqueProfileUnknown == input.kind = "opaque" /\ input.entry = "request" => Outcome = "unknown"
ExpectedPrice == IF ExpectedProfile = "us" \/ (input.kind = "opaque" /\ EffectiveRegion = "us")
THEN "us" ELSE "global"
ExpectedPrices == HandlerPrice = ExpectedPrice /\ ViewPrice = ExpectedPrice
GlobalControls == {i \in [custom : BOOLEAN, routeKind : {"alias", "profile", "opaque", "other"},
capability : BOOLEAN] : i.routeKind = "other" \/ i.capability}
Visible(i) == IF i.custom /\ GlobalControlFixed THEN i.routeKind = "alias" ELSE i.capability
GlobalControlChangesRoute == input.entry = "save" => \A i \in GlobalControls : i.custom => (Visible(i) = (i.routeKind = "alias"))
RegularGlobalControlPreserved == input.entry = "save" => \A i \in GlobalControls : ~i.custom => (Visible(i) = i.capability)
CacheInputs == [setting : {"unset", "on", "off"}, tokens : {1023, 1024, 2048}]
CacheEnabled(i) == i.setting # "off"
CacheFields == IF CacheMetadataFixed THEN {"system", "tools"} ELSE {}
CacheLimit == IF CacheMetadataFixed THEN 4 ELSE 0
CacheMinimum == IF CacheMetadataFixed THEN 1024 ELSE 50
SystemCheckpoint(i) == CacheEnabled(i) /\ "system" \in CacheFields /\ CacheLimit > 0
/\ i.tokens >= CacheMinimum
MessageCheckpoint(i) == CacheEnabled(i) /\ "messages" \in CacheFields
SystemCacheAgreement == input.entry = "request" => \A i \in CacheInputs :
SystemCheckpoint(i) = (CacheEnabled(i) /\ i.tokens >= 1024)
DisabledCacheSilent == \A i \in CacheInputs : ~CacheEnabled(i) => ~SystemCheckpoint(i)
MessageCacheAbsent == \A i \in CacheInputs : ~MessageCheckpoint(i)
CacheMetadataReady == input.entry = "request" => CacheFields = {"system", "tools"} /\ CacheLimit = 4 /\ CacheMinimum = 1024
====
Loading
Loading