diff --git a/conformance/stack-encrypt/coverage.md b/conformance/stack-encrypt/coverage.md index 10377adab7..a35bb18e6b 100644 --- a/conformance/stack-encrypt/coverage.md +++ b/conformance/stack-encrypt/coverage.md @@ -144,9 +144,8 @@ Each runs in native Rust and Go WASI under `test:conformance`. | Native `a_stored_record_that_does_not_fit`, the read profile | `shape-*`, `authenticated-*`, `success-*` | Mutation vocabulary over real ciphertext | | Guest `test_frame` and `last_error` tests | `transport-*`, `leaf-*` | Plan-frame boundary cases, ABI status mapping | -Unsupported combinations the corpora record rather than skip: the order -index on `bytes` stores a term no operator reads; a repeated key in a stored record is -a transport refusal in both decoders, and the engine's own `field_repeated` +Unsupported combinations the corpora record rather than skip: a repeated +key in a stored record is a transport refusal in both decoders, and the engine's own `field_repeated` and `repeated_key` guards are reached natively alone; the Go host refuses the zero `Date`, a decimal scale above 28, a timestamp outside the decoder's range and non-value Go types before the engine. `NaN` and diff --git a/conformance/stack-encrypt/declaration-grammar.md b/conformance/stack-encrypt/declaration-grammar.md index 12e59eacf8..889ade83d0 100644 --- a/conformance/stack-encrypt/declaration-grammar.md +++ b/conformance/stack-encrypt/declaration-grammar.md @@ -176,9 +176,14 @@ select a different leaf encoding. | Other integer widths | Admitted | Refused | Admitted | | float32, float64, decimal, date, timestamp | Admitted | Refused | Admitted | | string | Admitted | Admitted | Admitted | -| bytes | Admitted | Refused | Admitted | +| bytes | Admitted | Refused | Refused | | array, object, json | Refused | Refused | Refused | +An index is admitted only over a kind one of its operators answers. Bytes +have no order term: no ordering operator compares them, so a term would be +stored and never queried. The order indexes are refused on bytes as +`index_not_admitted`. + The corpus explicitly tests all 21 kinds against all five scalar indexes. `array` and `object` may still be sealed without indexes. A `json` field requires a document target. A raw `json` output has a recognized syntax but is refused as diff --git a/conformance/stack-encrypt/exchange-contract.md b/conformance/stack-encrypt/exchange-contract.md index 574efb0d54..189cfea99a 100644 --- a/conformance/stack-encrypt/exchange-contract.md +++ b/conformance/stack-encrypt/exchange-contract.md @@ -30,7 +30,7 @@ mise run test:conformance:exchange | Kind | Producer writes | Consumer checks | |---|---|---| -| `values` | One record per positive case of `v1/record-values-v1.cases.json` (the value-boundary corpus), under the plan that case declares, with context `["conformance", "exchange"]`: the sealed leaf and every declared index term; nothing for a SQL null | The record opens to the case's typed input. Every stored term equals the term the consumer's own query of the same value derives (`eq` for equality, `lt` for an order index), and the `equal_query` spelling derives the same equality term. An index the corpus lists as unanswered is present and not queried | +| `values` | One record per positive case of `v1/record-values-v1.cases.json` (the value-boundary corpus), under the plan that case declares, with context `["conformance", "exchange"]`: the sealed leaf and every declared index term; nothing for a SQL null | The record opens to the case's typed input. Every stored term equals the term the consumer's own query of the same value derives (`eq` for equality, `lt` for an order index), and the `equal_query` spelling derives the same equality term. | | `record` | The rows of the corpus's one record: a passthrough `int64` id (held on the host by Go, lowered as a `passthrough` output by Rust), text, `uint32`, decimal, date and timestamp fields with equality and order terms, a SQL-null text field and a sealed-null `float32` field, under context `["conformance", "exchange", "people"]` | The passthrough carried equals the corpus input; every sealed field opens to its input, a sealed null opens as null and a SQL null is absent from storage and opens as null; every stored term equals the consumer's derived query term | | `blobs` | A whole struct (`name`, `age`, `tags`, optional `nickname`) as one opaque ciphertext under `["conformance", "exchange", "blob"]`, field `value`: Rust through `OpaqueBlob`, Go through the storage blob the generated opaque path writes (`vcffi.MarshalStorage` sealed as the one `bytes` field) | The ciphertext opens and decodes to the corpus value through the other SDK's opaque reader (`OpaqueBlob` or `gensupport.Opaque`). A nil Go slice and an empty Rust `Vec` are one value; Rust's `Some` marker and Go's bare pointer are one value | | `eql-rows` | The EQL v4 `profiles` rows: every column of the committed fixture's plaintexts sealed afresh, Rust through eql-bindings' typed targets, Go through its generated code | Each column opens to the plaintext through the other side's typed target, and each equality column's stored `hm` equals the term the consumer's own equality query derives for that plaintext (the generated `*Eq` query in Go, the typed `*EqQuery` target in Rust) | diff --git a/conformance/stack-encrypt/query-refusals-contract.md b/conformance/stack-encrypt/query-refusals-contract.md index ce0c15779e..df6edf8836 100644 --- a/conformance/stack-encrypt/query-refusals-contract.md +++ b/conformance/stack-encrypt/query-refusals-contract.md @@ -21,7 +21,7 @@ and `languages/golang/encrypt/query_refusal_conformance_test.go`. `["conformance", ]`: equality-only text, match-only text, order-only text (ORE and block ORE), an integer with equality and order, an order-only float, a 128-bit integer with equality and OPE, a ciphertext-only bool and -text, a sealed-null and a SQL-null integer, and bytes with an order index. +text, a sealed-null and a SQL-null integer, and equality-only bytes. A case names a `field`, an `operator` and an `input`: a scalar `{type, text}` in the value profile's form, or `{"type": "list", "items": [...]}` for a @@ -40,7 +40,7 @@ Source and plan refusals cover every scalar operator (`eq`, `lt`, `lte`, indexes do not answer it, one case per pair: the equality-only text and integer, the match-only text, the ORE and block ORE text, the order-only float, the ciphertext-only bool and text, and the bytes field (equality -and an order index no operator reads). The 128-bit integer (equality and +alone: a declaration refuses an order index on bytes). The 128-bit integer (equality and OPE) and the 32-bit integer (equality and ORE) answer every operator but `matches`. The SQL-null integer shares the equality-only integer's indexes and is not repeated. A JSON document operator on an diff --git a/conformance/stack-encrypt/v1/record-declarations-v1.cases.json b/conformance/stack-encrypt/v1/record-declarations-v1.cases.json index 9df28c8eed..6dadcada26 100644 --- a/conformance/stack-encrypt/v1/record-declarations-v1.cases.json +++ b/conformance/stack-encrypt/v1/record-declarations-v1.cases.json @@ -1916,7 +1916,11 @@ } } }, - "accepted": true + "accepted": false, + "expected_error": { + "code": "stack_encrypt::dynamic_plan", + "fields": { "reason": "index_not_admitted", "field": "value" } + } }, { "id": "type-bytes-ope", @@ -1929,7 +1933,11 @@ } } }, - "accepted": true + "accepted": false, + "expected_error": { + "code": "stack_encrypt::dynamic_plan", + "fields": { "reason": "index_not_admitted", "field": "value" } + } }, { "id": "type-bytes-ore_block", @@ -1942,7 +1950,11 @@ } } }, - "accepted": true + "accepted": false, + "expected_error": { + "code": "stack_encrypt::dynamic_plan", + "fields": { "reason": "index_not_admitted", "field": "value" } + } }, { "id": "type-array-eq", diff --git a/conformance/stack-encrypt/v1/record-query-refusals-v1.cases.json b/conformance/stack-encrypt/v1/record-query-refusals-v1.cases.json index 1b126161a0..d8da2e08e4 100644 --- a/conformance/stack-encrypt/v1/record-query-refusals-v1.cases.json +++ b/conformance/stack-encrypt/v1/record-query-refusals-v1.cases.json @@ -51,7 +51,7 @@ }, "data": { "kind": "bytes", - "outputs": ["c", "eq", "ore"] + "outputs": ["c", "eq"] } }, "cases": [ @@ -216,7 +216,7 @@ } }, { - "id": "lt-on-bytes-order-index", + "id": "lt-on-bytes", "field": "data", "operator": "lt", "input": { @@ -773,7 +773,7 @@ } }, { - "id": "lte-on-bytes-order-index", + "id": "lte-on-bytes", "field": "data", "operator": "lte", "input": { @@ -789,7 +789,7 @@ } }, { - "id": "gt-on-bytes-order-index", + "id": "gt-on-bytes", "field": "data", "operator": "gt", "input": { @@ -805,7 +805,7 @@ } }, { - "id": "gte-on-bytes-order-index", + "id": "gte-on-bytes", "field": "data", "operator": "gte", "input": { @@ -821,7 +821,7 @@ } }, { - "id": "between-on-bytes-order-index", + "id": "between-on-bytes", "field": "data", "operator": "between", "input": { @@ -846,7 +846,7 @@ } }, { - "id": "matches-on-bytes-order-index", + "id": "matches-on-bytes", "field": "data", "operator": "matches", "input": { diff --git a/conformance/stack-encrypt/v1/record-values-v1.cases.json b/conformance/stack-encrypt/v1/record-values-v1.cases.json index 4cc29b3ae8..683c8a73d2 100644 --- a/conformance/stack-encrypt/v1/record-values-v1.cases.json +++ b/conformance/stack-encrypt/v1/record-values-v1.cases.json @@ -342,13 +342,12 @@ "id": "bytes-binary", "kind": "bytes", "null": "", - "outputs": ["c", "eq", "ore"], + "outputs": ["c", "eq"], "input": { "type": "bytes", "text": "00ff10" }, - "frame": "0b0300000000ff10", - "unanswered": ["ore"] + "frame": "0b0300000000ff10" }, { "id": "string-nul", diff --git a/conformance/stack-encrypt/values-contract.md b/conformance/stack-encrypt/values-contract.md index 2948a13c16..0624227395 100644 --- a/conformance/stack-encrypt/values-contract.md +++ b/conformance/stack-encrypt/values-contract.md @@ -93,19 +93,21 @@ requirements 1 to 4: it stores no record, so no data key is generated, no term exists to compare and no ciphertext is opened; its row reads back as null. -`unanswered` lists stored indexes no query operator answers for the kind. A -query of such an index is refused as `operator_not_answered` in both -runners. Today that is the order index on `bytes`: the declaration admits -it and the engine stores an order term, but no dynamic operator reads it. - -This is a leak, not only a gap. Anyone who holds the stored rows can -compare the order terms without a key. No query uses them. - -The typed Rust path refuses it. An order index is bounded by vitaminc-ore's -`Orderable`, which does not cover `Vec`, so an order index on bytes -does not compile. The fix for the declaration is to refuse an order index -on `bytes` there too. Data that Go rc.3 stored must stay readable. Until -then, this entry keeps the behaviour visible. +Every index a case declares is one a query operator answers for the kind, +because a declaration admits no other. An order index on `bytes` is the +case that shows it: bytes have no order term, because no ordering operator +compares them. A stored term would let anyone who holds two rows compare +them without a key, and no query could use it. +Both paths refuse it. The typed Rust path bounds an order index on +vitaminc-ore's `Orderable`, which does not cover `Vec`, so the +declaration does not compile. The dynamic path, which both runners +use, refuses the declaration as `index_not_admitted` +(`v1/record-declarations-v1.cases.json`, cases `type-bytes-ore`, +`type-bytes-ope` and `type-bytes-ore_block`). + +A row stored under an earlier declaration of such an index still opens +once the index is removed from the plan: opening ignores a stored term the +plan does not declare. `expected_error` cases are refused before any pending operation, with the structured diagnostic `code`, `reason` and `field`, and no key call. They diff --git a/docs/plans/2026-10-24-stack-encrypt-api-plan.md b/docs/plans/2026-10-24-stack-encrypt-api-plan.md index 76e803c6f2..3c1b7b2222 100644 --- a/docs/plans/2026-10-24-stack-encrypt-api-plan.md +++ b/docs/plans/2026-10-24-stack-encrypt-api-plan.md @@ -2280,6 +2280,15 @@ review. The rules are the query artifact's. generated from the `op` types. Each index declares its operators and admitted plaintexts once, and `index_for` reads them. Overlap is refused on both paths. A test shows the typed and dynamic faces agree. + An index admits exactly the plaintexts one of its operators + answers. The typed path enforces this with a trait bound, not a + test: each order index, order term and ordering operator is bounded + by vitaminc-ore's `Orderable`, which does not cover bytes. So an + order index on bytes does not compile. The dynamic path refuses the + declaration, in `dynamic::admits`, as `index_not_admitted`. A row + stored under such a declaration still opens once the index is removed + from the plan, because opening ignores a stored term the plan does + not declare. 2. Derivation once, refusals once. The `sem` query functions, the analyzer in place of `MatchCase`, and `Match` arrive. `check`, `verifier`, `admit`, `QueryToken`, `check_input`, and the diff --git a/languages/golang/CHANGELOG.md b/languages/golang/CHANGELOG.md index f32b0e4ec4..6838584324 100644 --- a/languages/golang/CHANGELOG.md +++ b/languages/golang/CHANGELOG.md @@ -36,6 +36,26 @@ and `languages/golang/encrypt/encrypttest/vX.Y.Z` on the same commit. 9999. If you might have stored one, check before you upgrade. Decrypt the column with the release you run now, or check its plaintext source. +- **An order index on bytes is refused** (#1577). A `[]byte` field tagged + `index=ore` or `index=ope` is now a field error from `stashgen`. A plan + built by hand with an `ore`, `ope` or `ore_block` output on a `bytes` + field is refused by the guest (`index_not_admitted`) before any key is + requested. No ordering operator + is answered over bytes, so the field stored an order term that anyone + who read the column could compare and that no query could use. + `stashgen`'s notice for an index no generated method queries is gone + with the case it described. + - Code that rc.6 or earlier generated for such a field still compiles, + but the guest refuses its plan when it is parsed. Until the tag is + edited and `stashgen` is run again, `Encrypt` and `Decrypt` of that + record type fail with `index_not_admitted`, as does its bytes field's + `Field.Encrypt`. That includes rows that were stored correctly. + - To upgrade, remove the index from the tag and generate again. Once the + code is generated again, rows stored with the term still open: opening + ignores a stored term the plan does not declare. The stored terms stay + in the database until the row is written again or the column is + dropped. + ### Changed - `vcffi` and `vcvalue` move to vitaminc `f1fc9ae74`, the commit vitaminc diff --git a/languages/golang/encrypt/README.md b/languages/golang/encrypt/README.md index dc9c7148f5..413cfb6a3d 100644 --- a/languages/golang/encrypt/README.md +++ b/languages/golang/encrypt/README.md @@ -264,7 +264,7 @@ or a type defined over one (`type Email string`): | Go field | Seals as | Indexes it can store | Query methods | |---|---|---|---| | `string` | text | `equality`, `match`, `ore`, `ope` | `Eq`, `Matches`, `Lt`, `Lte`, `Gt`, `Gte`, `Between` | -| `[]byte` | bytes | `equality`, `ore`, `ope` | `Eq` | +| `[]byte` | bytes | `equality` | `Eq` | | `bool` | a boolean | none | none | | `int16`, `int32`, `int64`, `int` | an integer of the field's own width (`int` is 64-bit) | `equality`, `ore`, `ope` | `Eq`, `Lt`, `Lte`, `Gt`, `Gte`, `Between` | | `uint16`, `uint32`, `uint64`, `uint` | the same, unsigned | `equality`, `ore`, `ope` | the same | @@ -275,9 +275,10 @@ or a type defined over one (`type Email string`): | `encrypt.Date` | a calendar date | `equality` | `Eq` | | `time.Time` | a timestamp, to the nanosecond, in UTC | `equality` | `Eq` | -Each query method needs its index declared. An `ore` or `ope` index on bytes -stores its term, but the engine answers no ordering through it, so such a -field has no `Lt` (see [Queries](#queries)). +Each query method needs its index declared. A field of bytes takes no `ore` +or `ope` index: the engine answers no ordering over bytes, so the term +would be stored and never queried, and `stashgen` refuses the declaration +(see [Queries](#queries)). `encrypt.Date`, `Int128`, `Uint128` and `Decimal` are vitaminc's `vcvalue` types; build them with `encrypt.DateOf`, `ParseInt128`, `ParseUint128` and @@ -359,11 +360,9 @@ one value, and every NaN is one value, above `+Inf`, so `Between(math.NaN(), math.Inf(1))` matches nothing. A `float32` orders as the `float64` it widens to. -An order index on bytes stores its term but answers no ordering -operator, so such a field has no `Lt`; nor does the `ope` index of a field -that declares `ore` too, since `ore` answers the orderings. stashgen prints a notice for each such index, on stderr and in -the generated file: the terms are stored, and only your own code can compare -them. A match index on an index-only field (`index=match` with no `encrypt`) +An order index on bytes is refused: no ordering operator is answered over +bytes, so the term would be stored, where anyone who reads the column can +compare it, and no query could use it. A match index on an index-only field (`index=match` with no `encrypt`) is refused, because `Verify` checks a match query's rows by decrypting them. Every query type implements `driver.Valuer`, so it binds as a parameter in diff --git a/languages/golang/encrypt/exchange_conformance_test.go b/languages/golang/encrypt/exchange_conformance_test.go index b7de110eff..2d89e40f03 100644 --- a/languages/golang/encrypt/exchange_conformance_test.go +++ b/languages/golang/encrypt/exchange_conformance_test.go @@ -227,10 +227,8 @@ func exchangeOperator(t testing.TB, index string) string { // checkExchangeTerms checks that every stored term is the term this // runner's own query of the same value derives: the query semantics of the -// artifact, independent of who wrote it. An index the corpus lists as -// unanswered has no operator to compare with, so only its presence is -// checked. -func checkExchangeTerms(t testing.TB, ctx context.Context, cipher *encrypt.Cipher, plan *record.Plan, field string, stored exchangeStored, declared, unanswered []string, input any, equal *conformanceInput, what string) { +// artifact, independent of who wrote it. +func checkExchangeTerms(t testing.TB, ctx context.Context, cipher *encrypt.Cipher, plan *record.Plan, field string, stored exchangeStored, declared []string, input any, equal *conformanceInput, what string) { t.Helper() if len(stored.Terms) != len(declared)-1 { t.Fatalf("%s: stored %d terms for %v", what, len(stored.Terms), declared[1:]) @@ -240,13 +238,6 @@ func checkExchangeTerms(t testing.TB, ctx context.Context, cipher *encrypt.Ciphe if !ok { t.Fatalf("%s: no %s term", what, index) } - skip := false - for _, u := range unanswered { - skip = skip || u == index - } - if skip { - continue - } probes := []any{input} if index == "eq" && equal != nil { probes = append(probes, conformanceValue(t, *equal)) @@ -482,7 +473,7 @@ func consumeExchange(t testing.TB, ctx context.Context, cipher *encrypt.Cipher, t.Fatalf("%s: a SQL null stores no term", what) } } else { - checkExchangeTerms(t, ctx, cipher, plan, corpus.Values.Field, stored, c.Outputs, c.Unanswered, input, c.EqualQuery, what) + checkExchangeTerms(t, ctx, cipher, plan, corpus.Values.Field, stored, c.Outputs, input, c.EqualQuery, what) sealed[corpus.Values.Field] = exchangeOutputsOf(t, stored, what) } opened, err := cipher.Open(ctx, plan, []record.Sealed{sealed}) @@ -529,7 +520,7 @@ func consumeExchange(t testing.TB, ctx context.Context, cipher *encrypt.Cipher, } continue } - checkExchangeTerms(t, ctx, cipher, plan, f.Name, outputs, f.Outputs, nil, conformanceValue(t, input), nil, what+": "+f.Name) + checkExchangeTerms(t, ctx, cipher, plan, f.Name, outputs, f.Outputs, conformanceValue(t, input), nil, what+": "+f.Name) sealed[f.Name] = exchangeOutputsOf(t, outputs, what+": "+f.Name) } if len(stored.Passthrough) != passthroughs { diff --git a/languages/golang/encrypt/internal/testusers/probe_stash.go b/languages/golang/encrypt/internal/testusers/probe_stash.go index d308c0f20d..545483fc65 100644 --- a/languages/golang/encrypt/internal/testusers/probe_stash.go +++ b/languages/golang/encrypt/internal/testusers/probe_stash.go @@ -16,17 +16,11 @@ const _ = gensupport.GeneratedVersion2 // Probe prints its sealed fields in the clear: it has no String or LogValue // method. Write them, or run stashgen with -redact. -// B: stores ore terms that no generated method queries: the engine answers no -// query through the ore index on this field ([]byte): the orderings are -// answered over integers, floats, text, decimals, dates and timestamps only. -// Drop the index unless your own code compares the stored terms. - type EncryptedProbe struct { U32 EncryptedProbeU32 U64 EncryptedProbeU64 I64 EncryptedProbeI64 S EncryptedProbeS - B EncryptedProbeB F64 EncryptedProbeF64 F32 EncryptedProbeF32 } @@ -51,11 +45,6 @@ type EncryptedProbeS struct { Ore encrypt.OreTerm } -type EncryptedProbeB struct { - Ciphertext encrypt.Ciphertext - Ore encrypt.OreTerm -} - type EncryptedProbeF64 struct { Ciphertext encrypt.Ciphertext Ore encrypt.OreTerm @@ -67,11 +56,11 @@ type EncryptedProbeF32 struct { } func (e EncryptedProbe) String() string { - return gensupport.Redacted("EncryptedProbe", nil, "U32", "U64", "I64", "S", "B", "F64", "F32") + return gensupport.Redacted("EncryptedProbe", nil, "U32", "U64", "I64", "S", "F64", "F32") } func (e EncryptedProbe) LogValue() slog.Value { - return gensupport.RedactedLog(nil, "U32", "U64", "I64", "S", "B", "F64", "F32") + return gensupport.RedactedLog(nil, "U32", "U64", "I64", "S", "F64", "F32") } // Stops compiling when Probe gains, loses, reorders or retypes a field. @@ -83,7 +72,6 @@ type probeShape struct { U64 uint64 I64 int64 S string - B []byte F64 float64 F32 float32 } @@ -93,7 +81,6 @@ var probeDeclaration = gensupport.Declare("prop"). EncryptIndex("u64", gensupport.Uint64, encrypt.Ore). EncryptIndex("i64", gensupport.Int64, encrypt.Ore). EncryptIndex("s", gensupport.String, encrypt.Ore). - EncryptIndex("b", gensupport.Bytes, encrypt.Ore). EncryptIndex("f64", gensupport.Float64, encrypt.Ore). EncryptIndex("f32", gensupport.Float32, encrypt.Ore) @@ -107,7 +94,6 @@ var probeCodec = gensupport.New(gensupport.Generated[Probe, EncryptedProbe]{ "u64": v.U64, "i64": v.I64, "s": v.S, - "b": v.B, "f64": v.F64, "f32": v.F32, } @@ -130,10 +116,6 @@ var probeCodec = gensupport.New(gensupport.Generated[Probe, EncryptedProbe]{ Ciphertext: rec["s"].Ciphertext, Ore: rec["s"].Ore, } - e.B = EncryptedProbeB{ - Ciphertext: rec["b"].Ciphertext, - Ore: rec["b"].Ore, - } e.F64 = EncryptedProbeF64{ Ciphertext: rec["f64"].Ciphertext, Ore: rec["f64"].Ore, @@ -150,7 +132,6 @@ var probeCodec = gensupport.New(gensupport.Generated[Probe, EncryptedProbe]{ "u64": {Ciphertext: e.U64.Ciphertext, Ore: e.U64.Ore}, "i64": {Ciphertext: e.I64.Ciphertext, Ore: e.I64.Ore}, "s": {Ciphertext: e.S.Ciphertext, Ore: e.S.Ore}, - "b": {Ciphertext: e.B.Ciphertext, Ore: e.B.Ore}, "f64": {Ciphertext: e.F64.Ciphertext, Ore: e.F64.Ore}, "f32": {Ciphertext: e.F32.Ciphertext, Ore: e.F32.Ore}, } @@ -170,9 +151,6 @@ var probeCodec = gensupport.New(gensupport.Generated[Probe, EncryptedProbe]{ if v.S, err = gensupport.Get[string](vals, "s"); err != nil { return Probe{}, err } - if v.B, err = gensupport.Get[[]byte](vals, "b"); err != nil { - return Probe{}, err - } if v.F64, err = gensupport.Get[float64](vals, "f64"); err != nil { return Probe{}, err } @@ -201,7 +179,6 @@ var ProbeFields = struct { U64 ProbeU64Field I64 ProbeI64Field S ProbeSField - B ProbeBField F64 ProbeF64Field F32 ProbeF32Field }{ @@ -209,7 +186,6 @@ var ProbeFields = struct { U64: ProbeU64Field{gensupport.NewField[uint64](probeDeclaration, "u64")}, I64: ProbeI64Field{gensupport.NewField[int64](probeDeclaration, "i64")}, S: ProbeSField{gensupport.NewField[string](probeDeclaration, "s")}, - B: ProbeBField{gensupport.NewField[[]byte](probeDeclaration, "b")}, F64: ProbeF64Field{gensupport.NewField[float64](probeDeclaration, "f64")}, F32: ProbeF32Field{gensupport.NewField[float32](probeDeclaration, "f32")}, } @@ -362,18 +338,6 @@ func (f ProbeSField) Between(ctx context.Context, c *encrypt.Cipher, lo, hi stri return encrypt.Range[encrypt.OreTerm]{Low: low, High: high}, err } -type ProbeBField struct { - field gensupport.Field[[]byte] -} - -func (f ProbeBField) Encrypt(ctx context.Context, c *encrypt.Cipher, v []byte) (EncryptedProbeB, error) { - out, err := f.field.Encrypt(ctx, c, v) - if err != nil { - return EncryptedProbeB{}, err - } - return EncryptedProbeB{Ciphertext: out.Ciphertext, Ore: out.Ore}, nil -} - type ProbeF64Field struct { field gensupport.Field[float64] } diff --git a/languages/golang/encrypt/internal/testusers/probeope_stash.go b/languages/golang/encrypt/internal/testusers/probeope_stash.go index 56a7e2d82a..580706d833 100644 --- a/languages/golang/encrypt/internal/testusers/probeope_stash.go +++ b/languages/golang/encrypt/internal/testusers/probeope_stash.go @@ -16,17 +16,11 @@ const _ = gensupport.GeneratedVersion2 // ProbeOpe prints its sealed fields in the clear: it has no String or LogValue // method. Write them, or run stashgen with -redact. -// B: stores ope terms that no generated method queries: the engine answers no -// query through the ope index on this field ([]byte): the orderings are -// answered over integers, floats, text, decimals, dates and timestamps only. -// Drop the index unless your own code compares the stored terms. - type EncryptedProbeOpe struct { U32 EncryptedProbeOpeU32 U64 EncryptedProbeOpeU64 I64 EncryptedProbeOpeI64 S EncryptedProbeOpeS - B EncryptedProbeOpeB F64 EncryptedProbeOpeF64 F32 EncryptedProbeOpeF32 } @@ -51,11 +45,6 @@ type EncryptedProbeOpeS struct { Ope encrypt.OpeTerm } -type EncryptedProbeOpeB struct { - Ciphertext encrypt.Ciphertext - Ope encrypt.OpeTerm -} - type EncryptedProbeOpeF64 struct { Ciphertext encrypt.Ciphertext Ope encrypt.OpeTerm @@ -67,11 +56,11 @@ type EncryptedProbeOpeF32 struct { } func (e EncryptedProbeOpe) String() string { - return gensupport.Redacted("EncryptedProbeOpe", nil, "U32", "U64", "I64", "S", "B", "F64", "F32") + return gensupport.Redacted("EncryptedProbeOpe", nil, "U32", "U64", "I64", "S", "F64", "F32") } func (e EncryptedProbeOpe) LogValue() slog.Value { - return gensupport.RedactedLog(nil, "U32", "U64", "I64", "S", "B", "F64", "F32") + return gensupport.RedactedLog(nil, "U32", "U64", "I64", "S", "F64", "F32") } // Stops compiling when ProbeOpe gains, loses, reorders or retypes a field. @@ -83,7 +72,6 @@ type probeOpeShape struct { U64 uint64 I64 int64 S string - B []byte F64 float64 F32 float32 } @@ -93,7 +81,6 @@ var probeOpeDeclaration = gensupport.Declare("prop_ope"). EncryptIndex("u64", gensupport.Uint64, encrypt.Ope). EncryptIndex("i64", gensupport.Int64, encrypt.Ope). EncryptIndex("s", gensupport.String, encrypt.Ope). - EncryptIndex("b", gensupport.Bytes, encrypt.Ope). EncryptIndex("f64", gensupport.Float64, encrypt.Ope). EncryptIndex("f32", gensupport.Float32, encrypt.Ope) @@ -107,7 +94,6 @@ var probeOpeCodec = gensupport.New(gensupport.Generated[ProbeOpe, EncryptedProbe "u64": v.U64, "i64": v.I64, "s": v.S, - "b": v.B, "f64": v.F64, "f32": v.F32, } @@ -130,10 +116,6 @@ var probeOpeCodec = gensupport.New(gensupport.Generated[ProbeOpe, EncryptedProbe Ciphertext: rec["s"].Ciphertext, Ope: rec["s"].Ope, } - e.B = EncryptedProbeOpeB{ - Ciphertext: rec["b"].Ciphertext, - Ope: rec["b"].Ope, - } e.F64 = EncryptedProbeOpeF64{ Ciphertext: rec["f64"].Ciphertext, Ope: rec["f64"].Ope, @@ -150,7 +132,6 @@ var probeOpeCodec = gensupport.New(gensupport.Generated[ProbeOpe, EncryptedProbe "u64": {Ciphertext: e.U64.Ciphertext, Ope: e.U64.Ope}, "i64": {Ciphertext: e.I64.Ciphertext, Ope: e.I64.Ope}, "s": {Ciphertext: e.S.Ciphertext, Ope: e.S.Ope}, - "b": {Ciphertext: e.B.Ciphertext, Ope: e.B.Ope}, "f64": {Ciphertext: e.F64.Ciphertext, Ope: e.F64.Ope}, "f32": {Ciphertext: e.F32.Ciphertext, Ope: e.F32.Ope}, } @@ -170,9 +151,6 @@ var probeOpeCodec = gensupport.New(gensupport.Generated[ProbeOpe, EncryptedProbe if v.S, err = gensupport.Get[string](vals, "s"); err != nil { return ProbeOpe{}, err } - if v.B, err = gensupport.Get[[]byte](vals, "b"); err != nil { - return ProbeOpe{}, err - } if v.F64, err = gensupport.Get[float64](vals, "f64"); err != nil { return ProbeOpe{}, err } @@ -201,7 +179,6 @@ var ProbeOpeFields = struct { U64 ProbeOpeU64Field I64 ProbeOpeI64Field S ProbeOpeSField - B ProbeOpeBField F64 ProbeOpeF64Field F32 ProbeOpeF32Field }{ @@ -209,7 +186,6 @@ var ProbeOpeFields = struct { U64: ProbeOpeU64Field{gensupport.NewField[uint64](probeOpeDeclaration, "u64")}, I64: ProbeOpeI64Field{gensupport.NewField[int64](probeOpeDeclaration, "i64")}, S: ProbeOpeSField{gensupport.NewField[string](probeOpeDeclaration, "s")}, - B: ProbeOpeBField{gensupport.NewField[[]byte](probeOpeDeclaration, "b")}, F64: ProbeOpeF64Field{gensupport.NewField[float64](probeOpeDeclaration, "f64")}, F32: ProbeOpeF32Field{gensupport.NewField[float32](probeOpeDeclaration, "f32")}, } @@ -362,18 +338,6 @@ func (f ProbeOpeSField) Between(ctx context.Context, c *encrypt.Cipher, lo, hi s return encrypt.Range[encrypt.OpeTerm]{Low: low, High: high}, err } -type ProbeOpeBField struct { - field gensupport.Field[[]byte] -} - -func (f ProbeOpeBField) Encrypt(ctx context.Context, c *encrypt.Cipher, v []byte) (EncryptedProbeOpeB, error) { - out, err := f.field.Encrypt(ctx, c, v) - if err != nil { - return EncryptedProbeOpeB{}, err - } - return EncryptedProbeOpeB{Ciphertext: out.Ciphertext, Ope: out.Ope}, nil -} - type ProbeOpeF64Field struct { field gensupport.Field[float64] } diff --git a/languages/golang/encrypt/internal/testusers/users.go b/languages/golang/encrypt/internal/testusers/users.go index 183b82b73c..1e65e439a5 100644 --- a/languages/golang/encrypt/internal/testusers/users.go +++ b/languages/golang/encrypt/internal/testusers/users.go @@ -84,7 +84,6 @@ type Probe struct { U64 uint64 `stash:"u64,encrypt,index=ore"` I64 int64 `stash:"i64,encrypt,index=ore"` S string `stash:"s,encrypt,index=ore"` - B []byte `stash:"b,encrypt,index=ore"` F64 float64 `stash:"f64,encrypt,index=ore"` F32 float32 `stash:"f32,encrypt,index=ore"` } @@ -98,7 +97,6 @@ type ProbeOpe struct { U64 uint64 `stash:"u64,encrypt,index=ope"` I64 int64 `stash:"i64,encrypt,index=ope"` S string `stash:"s,encrypt,index=ope"` - B []byte `stash:"b,encrypt,index=ope"` F64 float64 `stash:"f64,encrypt,index=ope"` F32 float32 `stash:"f32,encrypt,index=ope"` } diff --git a/languages/golang/encrypt/order_test.go b/languages/golang/encrypt/order_test.go index d3ae18e4a2..59c0e93804 100644 --- a/languages/golang/encrypt/order_test.go +++ b/languages/golang/encrypt/order_test.go @@ -17,9 +17,8 @@ import ( // Property tests of term ordering: random plaintexts, the terms the guest // stores for them through the generated Probe and ProbeOpe fields' Encrypt, -// comparison in Go. A query method derives the same bytes, but only over -// integers, floats and text, so the stored terms reach every index and -// kind; a field declares one order index, so ORE and OPE are two records. ORE is +// comparison in Go. A field declares one order index, so ORE and OPE are +// two records. ORE is // probabilistic — a wrong comparator or a wrong derivation still agrees // with plaintext order on many pairs — so a fixed vector set says little; // hundreds of random pairs per type say more. The index key is the @@ -260,13 +259,6 @@ func TestTermOrderIsPlaintextOrder(t *testing.T) { values = append(values, math.SmallestNonzeroFloat32, -math.SmallestNonzeroFloat32, math.MaxFloat32) adjacentProperty(t, cipher, ope, d, values, floatOrder[float32]) }) - t.Run("bytes", func(t *testing.T) { - d := probeTerm(ope, - f.B.Encrypt, func(e testusers.EncryptedProbeB) []byte { return e.Ore }, - p.B.Encrypt, func(e testusers.EncryptedProbeOpeB) []byte { return e.Ope }) - orderProperty(t, cipher, ope, d, bytes.Compare) - adjacentProperty(t, cipher, ope, d, [][]byte{{}, {0}, {0, 0}, {0, 1}, {1}, {255}, {255, 0}}, bytes.Compare) - }) }) } } diff --git a/languages/golang/encrypt/value_conformance_test.go b/languages/golang/encrypt/value_conformance_test.go index 86c634bc23..f69ae275ae 100644 --- a/languages/golang/encrypt/value_conformance_test.go +++ b/languages/golang/encrypt/value_conformance_test.go @@ -8,7 +8,6 @@ import ( "math" "path/filepath" "reflect" - "slices" "testing" "time" @@ -26,7 +25,6 @@ type valueCase struct { Frame *string `json:"frame"` Companion *conformanceInput `json:"companion"` EqualQuery *conformanceInput `json:"equal_query"` - Unanswered []string `json:"unanswered"` ExpectedError *struct { Code string `json:"code"` Reason string `json:"reason"` @@ -122,13 +120,6 @@ func TestValueConformance(t *testing.T) { if !record.Kind(c.Kind).Known() || c.Kind == "" || len(c.Outputs) == 0 || c.Outputs[0] != "c" { t.Fatal("unsupported declaration") } - // An unanswered index must be one the case declares, or the - // entry checks nothing. - for _, u := range c.Unanswered { - if !slices.Contains(c.Outputs[1:], u) { - t.Fatalf("unanswered %s is not a declared index", u) - } - } isNull := c.Input.Type == "null" if (c.Frame == nil) != isNull { t.Fatal("a frame is frozen for every value, and for no null") @@ -183,14 +174,6 @@ func TestValueConformance(t *testing.T) { operator = "lt" } term, err := cipher.QueryTerm(ctx, plan, "value", operator, value) - unanswered := false - for _, u := range c.Unanswered { - unanswered = unanswered || u == o - } - if unanswered { - assertConformanceDiagnostic(t, err, "stack_encrypt::dynamic_source", "operator_not_answered", "value") - continue - } if err != nil || len(term.Terms) != 1 || !bytes.Equal(term.Terms[0], row.Terms[record.Output(o)]) { t.Fatalf("%s: stored/query term mismatch: %v", o, err) } diff --git a/languages/golang/stashgen/emit.go b/languages/golang/stashgen/emit.go index 2103e8fa60..a977c66ac5 100644 --- a/languages/golang/stashgen/emit.go +++ b/languages/golang/stashgen/emit.go @@ -795,61 +795,32 @@ func planQueries(f *genFile) error { } g.queries = append(g.queries, q) } - unqueried, err := indexesAnswer(g) - if err != nil { + if err := verifiable(g); err != nil { return fieldErr(f.typeName, g.GoName, "%v", err) } - for _, n := range unqueried { - f.notices = append(f.notices, g.GoName+": "+n) - f.unqueried = append(f.unqueried, fmt.Sprintf("stashgen: %s.%s: %s", f.typeName, g.GoName, n)) - } } return nil } -// indexesAnswer checks a field's indexes against the operators the engine -// answers on it. -// -// It refuses a probabilistic query on an index-only field: the query's rows -// are checked by decrypting them with Verify, and an index-only field -// stores no ciphertext, so Verify could never pass and every real match -// would be thrown away. +// verifiable refuses a probabilistic query on a field that only stores an +// index. The caller checks the rows of such a query by decrypting them +// with Verify. A field that only stores an index has no ciphertext, so +// Verify would never pass. The caller would discard every real match. // -// It returns a notice for each index the engine answers no operator -// through on the field: the index stores a term no generated method can -// query. That is an ore or ope index on bytes: the engine stores it and -// answers the orderings over integers, floats, text, decimals, dates and -// timestamps only. Storing it is allowed, since a program may compare the -// stored terms itself, but an order term tells anyone who reads the column -// how its values order, so the generator says so. A second order index -// beside the first is no longer a notice: the engine refuses a field that -// declares two indexes for one operator (overlapping_outputs), before any -// code is written. -func indexesAnswer(g *genField) ([]string, error) { - if g.Verb != VerbEncryptIndex && g.Verb != VerbIndex { - return nil, nil - } - answers := map[IndexName]string{} - for _, op := range g.operators { - if op.Probabilistic && g.Verb == VerbIndex { - return nil, fmt.Errorf("the %s index answers %s, whose rows are checked by decrypting them with Verify, and an index-only field stores no ciphertext to decrypt; seal it as well (encrypt,index=%s)", op.Index, op.Name, op.Index) - } - if _, ok := answers[op.Index]; !ok { - answers[op.Index] = op.Name - } +// The engine only accepts an index on a field if one of the index's +// operators accepts the field's type. A generated method can therefore +// query every stored index. The engine refuses the one index that no +// method could query: an order index on bytes. +func verifiable(g *genField) error { + if g.Verb != VerbIndex { + return nil } - var notices []string - for _, ix := range g.Indexes { - if _, ok := answers[ix.Name]; ok { - continue - } - why := "" - if ix.Name == IndexOre || ix.Name == IndexOpe { - why = ": the orderings are answered over integers, floats, text, decimals, dates and timestamps only" + for _, op := range g.operators { + if op.Probabilistic { + return fmt.Errorf("the %s index answers %s, whose rows are checked by decrypting them with Verify, and an index-only field stores no ciphertext to decrypt; seal it as well (encrypt,index=%s)", op.Index, op.Name, op.Index) } - notices = append(notices, fmt.Sprintf("stores %s terms that no generated method queries: the engine answers no query through the %s index on this field (%s)%s. Drop the index unless your own code compares the stored terms.", ix.Name, ix.Name, g.valueExpr, why)) } - return notices, nil + return nil } func queryFor(g *genField, op Operator) (queryMethod, error) { diff --git a/languages/golang/stashgen/enginetest/enginetest.go b/languages/golang/stashgen/enginetest/enginetest.go index dc8d1e862c..f07eed5a49 100644 --- a/languages/golang/stashgen/enginetest/enginetest.go +++ b/languages/golang/stashgen/enginetest/enginetest.go @@ -199,9 +199,10 @@ func (e Static) operators(ctx context.Context, d stashgen.Declaration) (map[stri // answeredBy mirrors Op::answered_by in stack-encrypt: eq through an // equality index, matches through a match index, and the orderings through // the one order index the field declares (ORE, block ORE or OPE; check -// refused a field with two), over an integer of 16 bits or wider, a float, -// text, a decimal, a date or a timestamp; each only where the index applies -// to the type. +// refused a field with two); each only where the index applies to the type +// (indexApplies). As in the engine, there is no second list of the types +// that the orderings accept. If an index applies to a type, each of the +// index's operators accepts that type. func answeredBy(operator string, t stashgen.GoType, indexes []stashgen.IndexName) (stashgen.IndexName, bool) { declared := func(want stashgen.IndexName) bool { for _, idx := range indexes { @@ -217,11 +218,6 @@ func answeredBy(operator string, t stashgen.GoType, indexes []stashgen.IndexName case "matches": return stashgen.IndexMatch, declared(stashgen.IndexMatch) } - orderable := (integer(t) && !eightBit(t)) || logical(t) || - t.Kind == stashgen.KindFloat || t.Kind == stashgen.KindString - if !orderable { - return "", false - } for _, index := range []stashgen.IndexName{stashgen.IndexOre, stashgen.IndexOreBlock} { if declared(index) { return index, true @@ -239,15 +235,6 @@ func integer(t stashgen.GoType) bool { return false } -// logical reports whether the type is a decimal, a date or a timestamp. -func logical(t stashgen.GoType) bool { - switch t.Kind { - case stashgen.KindDecimal, stashgen.KindDate, stashgen.KindTimestamp: - return true - } - return false -} - // eightBit reports whether the type is an 8-bit integer (int8, uint8 or // byte, or a type defined over one), which has no order term. func eightBit(t stashgen.GoType) bool { @@ -262,10 +249,11 @@ func eightBit(t stashgen.GoType) bool { // every kind vitaminc gives an equality domain (integers of every width, // floats, decimals, dates, timestamps, text and bytes; a boolean has none), // match over text alone, ORE and OPE over integers of 16 bits and wider, -// floats, text, bytes, decimals, dates and timestamps. Not over a boolean -// or an 8-bit integer, whose order term would reveal which rows are true, -// or each row's rank among 256 values. The JSON index is not in the engine -// yet. +// floats, text, decimals, dates and timestamps. Not over a boolean or an +// 8-bit integer, whose order term would reveal which rows are true, or +// each row's rank among 256 values. Not over bytes: no ordering operator +// accepts bytes, so no query could use the stored term. +// The JSON index is not in the engine yet. func indexApplies(name stashgen.IndexName, t stashgen.GoType) error { switch name { case stashgen.IndexEquality: @@ -283,7 +271,7 @@ func indexApplies(name stashgen.IndexName, t stashgen.GoType) error { return fmt.Errorf("match applies to a string, not to %s", t) case stashgen.IndexOre, stashgen.IndexOpe, stashgen.IndexOreBlock: switch t.Kind { - case stashgen.KindString, stashgen.KindBytes, stashgen.KindFloat, + case stashgen.KindString, stashgen.KindFloat, stashgen.KindDecimal, stashgen.KindDate, stashgen.KindTimestamp: return nil } diff --git a/languages/golang/stashgen/read.go b/languages/golang/stashgen/read.go index 0750e7a11f..8b6131628f 100644 --- a/languages/golang/stashgen/read.go +++ b/languages/golang/stashgen/read.go @@ -58,7 +58,7 @@ type genFile struct { notices []string printsPlaintext bool unexported []string - unqueried []string // stderr notices about one field: an index no generated method queries, an array with no Elements accessor + unqueried []string // stderr notices about one field: an array with no Elements accessor redact bool redactRecv string diff --git a/languages/golang/stashgen/refusal_test.go b/languages/golang/stashgen/refusal_test.go index 332a5aa2e3..d25d712e42 100644 --- a/languages/golang/stashgen/refusal_test.go +++ b/languages/golang/stashgen/refusal_test.go @@ -382,7 +382,9 @@ func TestRefusalsHoldAgainstTheEmbeddedEngine(t *testing.T) { {"every index on an integer", "\tScore int64 `stash:\"score,encrypt,index=equality;ore\"`\n\tRank int32 `stash:\"rank,index=ope\"`"}, {"two order indexes on an integer", "\tScore int64 `stash:\"score,encrypt,index=ore;ope\"`"}, {"orders on a decimal, a date and a timestamp", "\tAmount encrypt.Decimal `stash:\"amount,encrypt,index=equality;ore\"`\n\tDay encrypt.Date `stash:\"day,encrypt,index=ope\"`\n\tAt time.Time `stash:\"at,encrypt,index=equality;ore\"`"}, - {"orders on text, bytes and a float", "\tName string `stash:\"name,encrypt,index=ope;match\"`\n\tBlob []byte `stash:\"blob,encrypt,index=equality;ore\"`\n\tScore float64 `stash:\"score,encrypt,index=ore\"`"}, + {"orders on text and a float, equality on bytes", "\tName string `stash:\"name,encrypt,index=ope;match\"`\n\tBlob []byte `stash:\"blob,encrypt,index=equality\"`\n\tScore float64 `stash:\"score,encrypt,index=ore\"`"}, + {"ore on bytes", "\tBlob []byte `stash:\"blob,encrypt,index=equality;ore\"`"}, + {"ope on bytes", "\tBlob []byte `stash:\"blob,index=ope\"`"}, {"a match query on an index-only field", "\tName string `stash:\"name,index=match\"`"}, } { dir := writeModule(t, map[string]string{"model.go": user(ctx + c.line), "crm/contact.go": crmPackage}) @@ -425,39 +427,39 @@ func TestTheWholeDeclarationIsCheckedAgainstTheEmbeddedEngine(t *testing.T) { } } -// An index no generated method queries is stored, and the generator says -// so, on stderr and in the file: an order index on bytes. An order index on -// text, a float or an integer answers the orderings, so it gets methods and -// no notice. A second order index on one field is no notice: the engine -// refuses the declaration (`TestRefusalsHoldAgainstTheEmbeddedEngine`). -func TestAnIndexNoMethodQueriesGetsANotice(t *testing.T) { - src := user(ctx + "\tName string `stash:\"name,encrypt,index=match;ope\"`\n\tBlob []byte `stash:\"blob,encrypt,index=ope\"`\n\tScore float64 `stash:\"score,encrypt,index=ore\"`\n\tAge int64 `stash:\"age,encrypt,index=ore\"`\n\tRank int32 `stash:\"rank,encrypt,index=ope\"`") +// An order index on bytes is refused: no ordering operator is answered +// over bytes, so its term would be stored and never queried. An order index +// on text, a float or an integer answers the orderings, so it gets methods. +func TestAnOrderIndexOnBytesIsRefused(t *testing.T) { + for _, index := range []string{"ore", "ope", "equality;ore"} { + src := user(ctx + "\tBlob []byte `stash:\"blob,encrypt,index=" + index + "\"`") + _, err := generate(t, src, stashgen.Request{Type: "User"}) + var fe *stashgen.FieldError + if !errors.As(err, &fe) || fe.Field != "Blob" { + t.Errorf("index=%s on bytes: %v", index, err) + } + } + src := user(ctx + "\tName string `stash:\"name,encrypt,index=match;ope\"`\n\tBlob []byte `stash:\"blob,encrypt,index=equality\"`\n\tScore float64 `stash:\"score,encrypt,index=ore\"`") file, err := generate(t, src, stashgen.Request{Type: "User"}) if err != nil { t.Fatal(err) } + // Every index here answers a query method, so no notice names a field. notices := strings.Join(file.Notices, "\n") - for _, want := range []string{ - "stashgen: User.Blob: stores ope terms that no generated method queries", - } { - if !strings.Contains(notices, want) { - t.Errorf("notices lack %q:\n%s", want, notices) - } - } - for _, field := range []string{"User.Name", "User.Rank", "User.Score", "User.Age"} { + for _, field := range []string{"User.Name", "User.Blob", "User.Score"} { if strings.Contains(notices, field) { - t.Errorf("an order index that answers the orderings got a notice (%s):\n%s", field, notices) + t.Errorf("a field whose every index is queried got a notice (%s):\n%s", field, notices) } } - if !strings.Contains(string(file.Content), "// Blob: stores ope terms that no generated method queries") { - t.Errorf("the file does not carry the notice:\n%s", file.Content) - } if !strings.Contains(string(file.Content), "func (f NameField) Lt(") { t.Errorf("a text field with ope has no Lt:\n%s", file.Content) } if !strings.Contains(string(file.Content), "func (f ScoreField) Between(") { t.Errorf("a float field with ore has no Between:\n%s", file.Content) } + if !strings.Contains(string(file.Content), "func (f BlobField) Eq(") { + t.Errorf("a bytes field with equality has no Eq:\n%s", file.Content) + } } // The storage profile writes a struct with no fields at all as an empty diff --git a/packages/stack-encrypt/CHANGELOG.md b/packages/stack-encrypt/CHANGELOG.md index 81e3730722..d7ff983a6f 100644 --- a/packages/stack-encrypt/CHANGELOG.md +++ b/packages/stack-encrypt/CHANGELOG.md @@ -766,6 +766,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 convert it: `P::decrypt_from_with_context(record, &cipher, expected)`. For no check, `P::decrypt_from(record, &cipher)` also works. +- **A data plan refuses an order index on bytes** (#1577). + `dynamic::admits` no longer admits `ore`, `ope` or `ore_block` on a + `bytes` field, so `record::plan` refuses the declaration with + `index_not_admitted`. Go reaches the same check through the guest. + Before, the declaration was accepted, each row stored an order term + that anyone who held two rows could compare, and every ordering query + was refused as `operator_not_answered`. + - To upgrade, remove the index from the plan. A row stored with the + term still opens under the new plan: opening ignores a stored term, + and an index-only field, that the plan does not declare. The stored + terms stay in the database until the row is written again. + - The dynamic path no longer derives an order term of bytes, as the + typed path does not. `IndexSpec::defines` reports no order term for + bytes, and `dynamic::term` refuses one. + - The conformance corpus follows. In `record-declarations-v1` the + cases `type-bytes-ore`, `type-bytes-ope` and `type-bytes-ore_block` + are now refused. `record-values-v1` no longer has an `unanswered` + list. In `record-query-refusals-v1` the bytes field declares + equality alone, and the six `*-on-bytes-order-index` cases are + renamed `*-on-bytes`. + - `tests/fixtures/stored_rows_v1.json` is not changed. Its `every_kind` + plan declares an order index on two bytes fields. The test now opens + those rows under the plan with the indexes removed. + - **`CipherRef` replaces `target::CipherScope` and `dynamic::Scope`** (#1488). A `CipherRef` is one borrowed value: a connection, and the keyset it is confined to, if any. It is built from `&StackCipher`, diff --git a/packages/stack-encrypt/src/dynamic/kind.rs b/packages/stack-encrypt/src/dynamic/kind.rs index 2c74527e9c..5d6fc7bf31 100644 --- a/packages/stack-encrypt/src/dynamic/kind.rs +++ b/packages/stack-encrypt/src/dynamic/kind.rs @@ -56,12 +56,22 @@ use crate::target::IndexSpec; /// of every width, both floats, a decimal, a date, a timestamp, text and /// bytes, and not a boolean. The rest are this crate's: match over text /// alone, and ORE, OPE and block ORE over the integers of 16 bits and -/// wider, both floats, text, bytes, a decimal, a date and a timestamp. A +/// wider, both floats, text, a decimal, a date and a timestamp. A /// boolean and an 8-bit integer have no order term: over so small a domain /// it would reveal which rows are `true`, or each row's rank among 256 /// values. A composite (`array`, `object`) has no term. Only the index's /// kind matters: a match index's options do not change what it applies to. /// +/// Bytes have no order term: no ordering operator compares them, so no +/// query could use a stored term, and anyone who reads the rows could +/// still compare the terms. So a plan refuses an order index on bytes, as +/// [`IndexSpec::defines`] gives bytes no order term. +/// +/// A plan therefore accepts an index on a kind only if one of the +/// index's operators accepts that kind. The typed interface has the same +/// rule: an order index needs [`Orderable`](crate::Orderable), which does +/// not cover bytes. +/// /// ``` /// use stack_encrypt::dynamic::{admits, ValueKind}; /// use stack_encrypt::target::IndexSpec; @@ -75,6 +85,8 @@ use crate::target::IndexSpec; /// assert!(!admits(ValueKind::Bool, &IndexSpec::Equality)); /// assert!(!admits(ValueKind::Bool, &IndexSpec::Ore)); /// assert!(!admits(ValueKind::Object, &IndexSpec::Ore)); +/// assert!(admits(ValueKind::Bytes, &IndexSpec::Equality)); +/// assert!(!admits(ValueKind::Bytes, &IndexSpec::Ore)); /// ``` pub fn admits(kind: ValueKind, index: &IndexSpec) -> bool { scalar_of(kind).is_some_and(|(ty, scalar)| index.takes(ty, &scalar)) @@ -687,10 +699,20 @@ mod tests { /// `admits` is `IndexSpec::defines` stated over kinds: the two cannot /// disagree about a value of any kind, and a composite admits nothing. + /// Bytes have no order term, so a plan refuses an order index on them + /// with `index_not_admitted`. #[test] fn admits_agrees_with_defines_for_every_kind() { for kind in value_kinds() { for index in indexes() { + let order = matches!(index, IndexSpec::Ore | IndexSpec::Ope | IndexSpec::OreBlock); + if kind == ValueKind::Bytes && order { + assert_eq!( + not_admitted(kind, &index), + Some(Reason::IndexNotAdmitted), + "bytes and {index}" + ); + } assert_eq!( admits(kind, &index), index.defines(sample(kind)), diff --git a/packages/stack-encrypt/src/dynamic/query.rs b/packages/stack-encrypt/src/dynamic/query.rs index 1d35db374a..9ff3072d19 100644 --- a/packages/stack-encrypt/src/dynamic/query.rs +++ b/packages/stack-encrypt/src/dynamic/query.rs @@ -189,12 +189,8 @@ impl Op { // answers is the one. A document field's JSON index answers the // document operators over a document alone; every other index // answers over the kinds it is defined for. - // An order index over bytes stores a term and answers no ordering: - // the orderings are answered over the integers, the floats, text, - // decimals, dates and timestamps. - if self.is_ordering() && !ordered(kind) { - return None; - } + // Bytes have no order term, so `admits` refuses an order index over + // them, and no ordering is answered there. indexes.iter().find(|index| { index.answers(self) && match index { @@ -203,38 +199,6 @@ impl Op { } }) } - - /// Whether this is an ordering operator over a scalar: `lt`, `lte`, - /// `gt`, `gte` or `between`. - fn is_ordering(self) -> bool { - matches!(self, Op::Lt | Op::Lte | Op::Gt | Op::Gte | Op::Between) - } -} - -/// The kinds the ordering operators are answered over: the integers of 16 -/// bits and wider, `int16` to `uint128`, the floats, text, and dates, -/// timestamps and decimals, as [`Orderable`](crate::Orderable) covers -/// them in the typed path. Not `int8` or `uint8`, which have no order term. -/// Each orders by its order key; a `float32` is ordered as the -/// `f64` it widens to, as the typed path asks. -fn ordered(kind: ValueKind) -> bool { - matches!( - kind, - ValueKind::Int16 - | ValueKind::Int32 - | ValueKind::Int64 - | ValueKind::Int128 - | ValueKind::UInt16 - | ValueKind::UInt32 - | ValueKind::UInt64 - | ValueKind::UInt128 - | ValueKind::Float32 - | ValueKind::Float64 - | ValueKind::String - | ValueKind::Decimal - | ValueKind::Date - | ValueKind::Timestamp - ) } /// How far the server's answer to an operator can be trusted, as a catalog diff --git a/packages/stack-encrypt/src/dynamic/record.rs b/packages/stack-encrypt/src/dynamic/record.rs index d6ff7a6cd8..98dd0e0d4a 100644 --- a/packages/stack-encrypt/src/dynamic/record.rs +++ b/packages/stack-encrypt/src/dynamic/record.rs @@ -418,8 +418,8 @@ impl FieldPlan { /// [`Error::Plan`] if the field asks for an index the kind is not /// defined for ([`admits`](super::admits)), with the reason [`not_admitted`] gives: /// [`Reason::IndexNotAdmitted`] for match on an integer, equality or an - /// order index on a boolean, an order index on an 8-bit integer, any - /// index on a composite. + /// order index on a boolean, an order index on an 8-bit integer or on + /// bytes, any index on a composite. pub fn with_type(mut self, field_type: ValueKind) -> Result { for output in &self.outputs { if let Output::Term(index) = output { diff --git a/packages/stack-encrypt/src/dynamic/term.rs b/packages/stack-encrypt/src/dynamic/term.rs index 1cc48a154d..af96b53b74 100644 --- a/packages/stack-encrypt/src/dynamic/term.rs +++ b/packages/stack-encrypt/src/dynamic/term.rs @@ -16,7 +16,7 @@ //! a domain of its own. A boolean has none. //! - **Match** takes text only, cut in Unicode 16 NFC. //! - **ORE, OPE and block ORE** take an integer of 16 bits or wider, a -//! float, text, bytes, a date, a timestamp or a decimal, each handed to +//! float, text, a date, a timestamp or a decimal, each handed to //! clww-ore (ORE, OPE) or ore-rs (block ORE) as the Rust type the typed //! path would have named: an `i16` as an `i16`, a `u128` as a `u128`, a //! date as a [`value::Date`](crate::value::Date). A boolean, a `u8` and an @@ -142,7 +142,7 @@ impl IndexSpec { /// gives an equality domain (an integer, a float, text, bytes, a date, /// timestamp, decimal or uuid, and a null), not a boolean. Match /// takes text. ORE, OPE and block ORE take an integer of 16 bits or - /// wider, a float, text, bytes, a date, a timestamp or a decimal; not a + /// wider, a float, text, a date, a timestamp or a decimal; not bytes, a /// boolean, an 8-bit integer or a uuid. A match index's options do not /// change what it takes. /// @@ -191,8 +191,9 @@ impl IndexSpec { } /// Whether the order indexes (CLLW ORE and OPE, and block ORE) order this -/// scalar: an integer of 16 bits or wider, a float, text, bytes, or a date, -/// timestamp or decimal in range. Not a boolean, and not an 8-bit integer: +/// scalar: an integer of 16 bits or wider, a float, text, or a date, +/// timestamp or decimal in range. Not bytes, which no ordering operator +/// compares. Not a boolean, and not an 8-bit integer: /// an order term over so small a domain reveals too much, which rows hold /// `true`, or each row's rank among 256 values, which a few known rows /// resolve to the values. Not a null, and not a uuid or any other logical @@ -201,7 +202,10 @@ fn ordered(ty: Option, value: &Physical<'_>) -> bool { match ty { None => match value { Physical::Int(Int::I8(_) | Int::U8(_)) | Physical::Null | Physical::Bool(_) => false, - Physical::Int(_) | Physical::Float(_) | Physical::Text(_) | Physical::Bytes(_) => true, + Physical::Int(_) | Physical::Float(_) | Physical::Text(_) => true, + // No ordering operator compares bytes, so an order term of + // them answers no query and reveals the order of the rows. + Physical::Bytes(_) => false, }, Some(Logical::Date) => Date::from_scalar(ty, *value).is_some(), Some(Logical::Timestamp(_)) => Timestamp::from_scalar(ty, *value).is_some(), @@ -642,10 +646,10 @@ enum OrderIndex { /// Rust type the typed path would have named; `None` for a scalar it does /// not order ([`ordered`]). /// -/// Text and bytes are read where the walk holds them, and not copied: -/// each term makes the scalar's order encoding first, under `Protected`, -/// so nothing is freed with the plaintext still in it, in a guest's linear -/// memory, where the host can read it. +/// Text is read where the walk holds it, and not copied: each term makes +/// the scalar's order encoding first, under `Protected`, so nothing is +/// freed with the plaintext still in it, in a guest's linear memory, where +/// the host can read it. /// /// Each scalar is encoded at the target of the Rust type named here /// ([`Orderable`]), as on the typed path: text by its case and accent @@ -697,7 +701,6 @@ where Physical::Float(Float::F32(v)) => order(cipher, index, v, context), Physical::Float(Float::F64(v)) => order(cipher, index, v, context), Physical::Text(t) => order(cipher, index, t, context), - Physical::Bytes(b) => order_at(cipher, index, OrderTarget::Bytes, b, context), _ => return None, }) } @@ -720,11 +723,6 @@ where /// The term of `value` under `index`, encoded as `target`. The term's /// bytes are its frozen encoding: the raw CLLW ciphertext, or the /// serialised block ORE one. -/// -/// Bytes are not [`Orderable`]: no ordering operator compares them, so the -/// typed path has no order term of bytes. A data plan can still declare an -/// order index on bytes, and the rows it stored carry the term, so this path -/// derives it as it did, by naming the `Bytes` target. fn order_at<'a, 'c, K: 'static, V, D>( cipher: &'a KeysetCipher<'_, K>, index: OrderIndex, @@ -1546,16 +1544,17 @@ mod tests { fn defines_is_true() { for (label, leaf) in every_scalar() { let not_bool = !matches!(leaf, Tree::Bool(_)); - let wide = not_bool && !matches!(leaf, Tree::Int8(_) | Tree::UInt8(_)); + let wide = + not_bool && !matches!(leaf, Tree::Int8(_) | Tree::UInt8(_) | Tree::Bytes(_)); assert_eq!( IndexSpec::Ore.defines(&leaf), wide, - "{label} takes an ore term exactly when it is not a boolean or 8 bits wide" + "{label} takes an ore term exactly when it is not a boolean, bytes or 8 bits wide" ); assert_eq!( IndexSpec::Ope.defines(&leaf), wide, - "{label} takes an ope term exactly when it is not a boolean or 8 bits wide" + "{label} takes an ope term exactly when it is not a boolean, bytes or 8 bits wide" ); assert_eq!( IndexSpec::Equality.defines(&leaf), diff --git a/packages/stack-encrypt/src/refusal.rs b/packages/stack-encrypt/src/refusal.rs index 1e34adc379..191c1b0a43 100644 --- a/packages/stack-encrypt/src/refusal.rs +++ b/packages/stack-encrypt/src/refusal.rs @@ -478,7 +478,8 @@ reasons! { /// `"type"` is not a string naming a value type. UnknownType => "unknown_type", r#""type" does not name a value type"#; /// The field's declared type has no such index: match on an integer, - /// equality or an order index on a boolean, any index on a composite. + /// equality or an order index on a boolean, an order index on an + /// 8-bit integer or on bytes, any index on a composite. IndexNotAdmitted => "index_not_admitted", "the declared type has no such index"; /// The field declares the JSON index as an output. A data plan /// reaches the JSON index through a target that stores a document diff --git a/packages/stack-encrypt/tests/exchange_conformance.rs b/packages/stack-encrypt/tests/exchange_conformance.rs index 3581049b65..c044b9dd4e 100644 --- a/packages/stack-encrypt/tests/exchange_conformance.rs +++ b/packages/stack-encrypt/tests/exchange_conformance.rs @@ -133,8 +133,6 @@ struct ValueCase { frame: Option, companion: Option, equal_query: Option, - #[serde(default)] - unanswered: Vec, expected_error: Option, } @@ -382,8 +380,6 @@ struct Terms<'a> { field: &'a str, /// The field's declared outputs, `c` first. declared: &'a [String], - /// Stored indexes no operator answers: present, and not queried. - unanswered: &'a [String], input: &'a Input, /// Another spelling whose equality query derives the same term. equal_query: Option<&'a Input>, @@ -391,8 +387,7 @@ struct Terms<'a> { /// Every stored term is the term this runner's own query of the same value /// derives: the query semantics of the artifact, independent of who wrote -/// it. An index the corpus lists as unanswered has no operator to compare -/// with, so only its presence is checked. +/// it. async fn check_terms( keyset: &KeysetCipher<'_, common::DeterministicSource>, terms: Terms<'_>, @@ -403,9 +398,6 @@ async fn check_terms( let present: BTreeSet<_> = stored.terms.keys().map(String::as_str).collect(); assert_eq!(present, declared, "{what}: stores every declared index"); for (index, term) in &stored.terms { - if terms.unanswered.contains(index) { - continue; - } let mut probes = vec![terms.input]; if index == "eq" { probes.extend(terms.equal_query); @@ -649,7 +641,6 @@ async fn consume( plan: &plan, field: &corpus.values.field, declared: &case.outputs, - unanswered: &case.unanswered, input: &case.input, equal_query: case.equal_query.as_ref(), }, @@ -694,7 +685,6 @@ async fn consume( plan: &plan, field: &field.name, declared: &field.outputs, - unanswered: &[], input, equal_query: None, }, diff --git a/packages/stack-encrypt/tests/fixtures/README.md b/packages/stack-encrypt/tests/fixtures/README.md index 9b961e1f2e..240ef2057b 100644 --- a/packages/stack-encrypt/tests/fixtures/README.md +++ b/packages/stack-encrypt/tests/fixtures/README.md @@ -219,6 +219,14 @@ of being regenerated away. sealed leaves (which carry a fresh nonce): the same shape and map keys in order, the same terms and the same passthroughs. +One declaration in the file is no longer accepted: an order index on a +`bytes` field (`blob` with `ore`, and the index-only `blob_ope`, in +`every_kind`). The file keeps it, because it records what was stored. The +test removes those indexes from the plan before it builds it, as a user +whose plan declared one must. It opens each row as stored, retired terms +included, under that plan. It seals the source again and compares the two +trees without the retired terms and without `blob_ope`. + Nothing reads `STACK_ENCRYPT_UPDATE_FIXTURES` for this file. The one test that creates it, `write_stored_rows_v1`, is `#[ignore]`d and refuses to run when the file exists. The check rewrites it only under diff --git a/packages/stack-encrypt/tests/stored_rows.rs b/packages/stack-encrypt/tests/stored_rows.rs index b36e4a680d..e8282e6809 100644 --- a/packages/stack-encrypt/tests/stored_rows.rs +++ b/packages/stack-encrypt/tests/stored_rows.rs @@ -20,6 +20,10 @@ //! `STACK_ENCRYPT_REFREEZE_ORDER_TERMS=1`. That run asserts nothing else //! moved before it rewrites anything. //! +//! One declaration the file records is no longer accepted: an order index +//! on a `bytes` field. The file keeps it, and the check opens the rows +//! under the plan with those indexes removed ([`todays_plan`]). +//! //! The schema and the rules are in `tests/fixtures/README.md`. #![cfg(feature = "dynamic")] @@ -187,8 +191,94 @@ fn without_order_terms(json: &Json) -> Json { } } -/// Copy every order term of `resealed` over the one in the same place in -/// `stored`. The two have the same shape, which the caller has asserted. +/// Whether `output` of a field of the frozen plan is retired: an index the +/// engine no longer admits for the field's kind. The plan the rows were +/// stored under declares two, an order index on a `bytes` field (`blob` +/// with `ore`, and the index-only `blob_ope`). The engine's own rule +/// decides, so if it admits an order index on bytes again, nothing is +/// retired and the frozen rows must reseal as they were. +fn retired(field: &Json, output: &Json) -> bool { + let Some(kind) = field + .get("type") + .and_then(Json::as_str) + .and_then(|ty| ty.parse::().ok()) + else { + return false; + }; + let index = match output.as_str() { + Some("ore") => IndexSpec::Ore, + Some("ope") => IndexSpec::Ope, + Some("ore_block") => IndexSpec::OreBlock, + _ => return false, + }; + !admits(kind, &index) +} + +/// Whether every output of a field of the frozen plan is retired: the field +/// held an order term on bytes and nothing else. +fn emptied(field: &Json) -> bool { + field + .get("outputs") + .and_then(Json::as_array) + .is_some_and(|outputs| outputs.iter().all(|output| retired(field, output))) +} + +/// The frozen plan as a build declares it today: without an order index on +/// a `bytes` field. This is what a user whose plan declared one does: +/// remove the index. The rows stored under the old declaration must still +/// open under this one. +/// +/// A field left with no output is removed, which is the plan the rows are +/// opened under. With `holding_source`, it is kept as ciphertext instead: +/// the frozen source still carries that field's value, and sealing refuses +/// a source field the plan does not declare. +fn todays_plan(frozen: &Json, holding_source: bool) -> Json { + let mut plan = frozen.clone(); + let fields = plan.as_object_mut().expect("a plan is an object"); + fields.retain(|_, field| { + if !field.is_object() || field.get("type") != Some(&json!("bytes")) { + return true; + } + let was = field.clone(); + let outputs = field["outputs"].as_array_mut().expect("outputs"); + outputs.retain(|output| !retired(&was, output)); + if outputs.is_empty() && holding_source { + outputs.push(json!("c")); + } + !outputs.is_empty() + }); + plan +} + +/// A row without what the frozen plan's retired indexes stored: the order +/// terms of its `bytes` fields, and each field that held nothing else. +fn without_retired(row: &Json, frozen_plan: &Json) -> Json { + // A batch is stored as a sequence of rows. + if let Some(rows) = row.get("seq").and_then(Json::as_array) { + let rows: Vec = rows + .iter() + .map(|row| without_retired(row, frozen_plan)) + .collect(); + return json!({ "seq": rows }); + } + let mut row = row.clone(); + let fields = row["map"].as_array_mut().expect("a row is a map"); + fields.retain_mut(|pair| { + let field = &frozen_plan[pair[0].as_str().expect("a key")]; + if emptied(field) { + return false; + } + if let Some(outputs) = pair[1].get_mut("map").and_then(Json::as_array_mut) { + outputs.retain(|output| !retired(field, &output[0])); + } + true + }); + row +} + +/// Copy every order term of `resealed` over the one under the same key in +/// `stored`. An entry of `stored` that `resealed` does not hold (a retired +/// term) stays as it was frozen. fn refreeze_order_terms(stored: &mut Json, resealed: &Json) { let Some(object) = stored.as_object_mut() else { return; @@ -203,11 +293,15 @@ fn refreeze_order_terms(stored: &mut Json, resealed: &Json) { } } "map" => { - for (index, pair) in value.as_array_mut().expect("a list").iter_mut().enumerate() { + let theirs = theirs.as_array().expect("a list"); + for pair in value.as_array_mut().expect("a list") { + let Some(their) = theirs.iter().find(|their| their[0] == pair[0]) else { + continue; + }; if is_order_term(pair) { - pair[1] = theirs[index][1].clone(); + pair[1] = their[1].clone(); } else { - refreeze_order_terms(&mut pair[1], &theirs[index][1]); + refreeze_order_terms(&mut pair[1], &their[1]); } } } @@ -290,13 +384,21 @@ async fn every_frozen_row_opens_and_seals_as_it_did() { "the deterministic source names the keyset it named" ); - let cases = fixture["cases"].as_array_mut().expect("a list of cases"); - assert!(!cases.is_empty()); - for case in cases { + let frozen = fixture["cases"].as_array_mut().expect("a list of cases"); + assert!(!frozen.is_empty()); + for case in frozen { let name = case["name"].as_str().expect("a name"); - let plan = plan_of(&case["plan"]); + // The row is opened as it was frozen, retired order terms and all, + // under the plan a build accepts today: opening ignores a stored + // term, and an index-only field, the plan does not declare. + let plan = plan_of(&todays_plan(&case["plan"], false)); + // The frozen source is sealed again under the same plan, with a + // field that lost its last index held as ciphertext so the source + // still fits. Neither side of the comparison keeps that field. + let sealing = plan_of(&todays_plan(&case["plan"], true)); let source = Protected::new(unhex(case["source"].as_str().expect("hex"))); let stored = &case["stored"]; + let kept = without_retired(stored, &case["plan"]); let opened = open(&cipher, node_of_json(stored), &plan, expected_of(case)).await; assert_eq!( @@ -305,11 +407,13 @@ async fn every_frozen_row_opens_and_seals_as_it_did() { "{name}: the frozen row opens to what it opened to" ); - let resealed = - json_of_node(seal(&cipher, source.as_protected_ref().as_deref(), &plan).await); + let resealed = without_retired( + &json_of_node(seal(&cipher, source.as_protected_ref().as_deref(), &sealing).await), + &case["plan"], + ); assert_eq!( without_order_terms(&resealed), - without_order_terms(stored), + without_order_terms(&kept), "{name}: sealing the source today stores the same shape, terms and passthroughs" ); if refreeze { @@ -317,7 +421,7 @@ async fn every_frozen_row_opens_and_seals_as_it_did() { } else { assert_eq!( skeleton(&resealed), - skeleton(stored), + skeleton(&kept), "{name}: only ORE or OPE terms moved. If that is deliberate, re-freeze them \ with STACK_ENCRYPT_REFREEZE_ORDER_TERMS=1 and say so in the CHANGELOG \ (tests/fixtures/README.md)" diff --git a/packages/stack-encrypt/tests/ui/order_index_on_bytes.rs b/packages/stack-encrypt/tests/ui/order_index_on_bytes.rs new file mode 100644 index 0000000000..f6dd23016d --- /dev/null +++ b/packages/stack-encrypt/tests/ui/order_index_on_bytes.rs @@ -0,0 +1,34 @@ +//! An order index stores a term that reveals the order of the rows. No +//! ordering operator compares bytes, so an order index on bytes would store +//! that term and answer no query. vitaminc-ore's `Orderable` does not cover +//! bytes, so it does not compile: as a set of indexes, as a field of a +//! derived record, as a target of its own (owned or borrowed), or as the +//! low-level operation an index of another crate would be built from. +use stack_encrypt::sem::{OpeTerm, OreBlockTerm, OreTerm}; +use stack_encrypt::target::{self, indexed, Borrowed, EncryptTarget}; +use stack_encrypt::{Encrypted, Ope, Ore, OreBlock}; +use zeroize::Zeroize; + +#[derive(Clone, Zeroize)] +struct File { + digest: Vec, +} + +#[derive(EncryptTarget)] +#[stash(struct = File, scope = "files")] +struct EncryptedFile { + digest: Encrypted>>, +} + +fn main() { + let _ = indexed::, (), Borrowed, _>(Ore); + let _ = indexed::, (), Borrowed, _>(Ope); + let _ = indexed::, (), Borrowed, _>(OreBlock); + let _ = > as EncryptTarget>>::encryption::<()>(); + let _ = > as EncryptTarget>>::encryption::<()>(); + let _ = > as EncryptTarget>>::encryption::<()>(); + let _ = > as EncryptTarget>>::owned_encryption::<()>(); + let _ = target::ore::, (), Borrowed>(); + let _ = target::ope::, (), Borrowed>(); + let _ = target::ore_block::, (), Borrowed>(); +} diff --git a/packages/stack-encrypt/tests/ui/order_index_on_bytes.stderr b/packages/stack-encrypt/tests/ui/order_index_on_bytes.stderr new file mode 100644 index 0000000000..37aedf9b62 --- /dev/null +++ b/packages/stack-encrypt/tests/ui/order_index_on_bytes.stderr @@ -0,0 +1,448 @@ +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:20:23 + | +20 | digest: Encrypted>>, + | ^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreTerm` + --> src/sem/mod.rs + | + | pub struct OreTerm(OreClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreTerm` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:20:13 + | +20 | digest: Encrypted>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreTerm` + --> src/sem/mod.rs + | + | pub struct OreTerm(OreClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreTerm` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:20:13 + | +20 | digest: Encrypted>>, + | ^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `OreTerm>` to implement `TermSet>` + = note: required for `Encrypted>>` to implement `EncryptTarget>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:17:10 + | +17 | #[derive(EncryptTarget)] + | ^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreTerm` + --> src/sem/mod.rs + | + | pub struct OreTerm(OreClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreTerm` + = note: this error originates in the derive macro `EncryptTarget` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:17:10 + | +17 | #[derive(EncryptTarget)] + | ^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreTerm` + --> src/sem/mod.rs + | + | pub struct OreTerm(OreClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreTerm` + = note: this error originates in the derive macro `EncryptTarget` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:24:13 + | +24 | let _ = indexed::, (), Borrowed, _>(Ore); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `stack_encrypt::Ore` to implement `stack_encrypt::Index>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:25:13 + | +25 | let _ = indexed::, (), Borrowed, _>(Ope); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `stack_encrypt::Ope` to implement `stack_encrypt::Index>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:26:13 + | +26 | let _ = indexed::, (), Borrowed, _>(OreBlock); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `stack_encrypt::OreBlock` to implement `stack_encrypt::Index>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:27:13 + | +27 | let _ = > as EncryptTarget>>::encryption::<()>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `OreTerm>` to implement `EncryptTarget>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:28:13 + | +28 | let _ = > as EncryptTarget>>::encryption::<()>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `OpeTerm>` to implement `EncryptTarget>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:29:13 + | +29 | let _ = > as EncryptTarget>>::encryption::<()>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others + = note: required for `OreBlockTerm>` to implement `EncryptTarget>` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:30:13 + | +30 | let _ = > as EncryptTarget>>::owned_encryption::<()>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreTerm` + --> src/sem/mod.rs + | + | pub struct OreTerm(OreClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreTerm` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:31:27 + | +31 | let _ = target::ore::, (), Borrowed>(); + | ^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `stack_encrypt::target::ore` + --> src/target/operations.rs + | + | ore, crate::sem::OreTerm, wipe(std::convert::identity), [], + | --- required by a bound in this function + | [S: crate::Orderable + EncryptRef + 'static] + | ^^^^^^^^^^^^^^^^ required by this bound in `ore` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:31:13 + | +31 | let _ = target::ore::, (), Borrowed>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreTerm` + --> src/sem/mod.rs + | + | pub struct OreTerm(OreClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreTerm` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:32:27 + | +32 | let _ = target::ope::, (), Borrowed>(); + | ^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `stack_encrypt::target::ope` + --> src/target/operations.rs + | + | ope, crate::sem::OpeTerm, wipe(std::convert::identity), [], + | --- required by a bound in this function + | [S: crate::Orderable + EncryptRef + 'static] + | ^^^^^^^^^^^^^^^^ required by this bound in `ope` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:32:13 + | +32 | let _ = target::ope::, (), Borrowed>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OpeTerm` + --> src/sem/mod.rs + | + | pub struct OpeTerm(OpeClww8VariableV1, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OpeTerm` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:33:33 + | +33 | let _ = target::ore_block::, (), Borrowed>(); + | ^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `stack_encrypt::target::ore_block` + --> src/target/operations.rs + | + | ore_block, crate::sem::OreBlockTerm, wipe(std::convert::identity), [], + | --------- required by a bound in this function + | [S: crate::Orderable + EncryptRef + 'static] + | ^^^^^^^^^^^^^^^^ required by this bound in `ore_block` + +error[E0277]: `Vec` is not `Orderable`: it has no order target of its own + --> tests/ui/order_index_on_bytes.rs:33:13 + | +33 | let _ = target::ore_block::, (), Borrowed>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ has no order target of its own + | + = help: the trait `Orderable` is not implemented for `Vec` + = note: name the target: `scheme.target(I64).encrypt_checked(value)` + = note: there is no 8-bit target: an order term over 256 values reveals them, so an `i8` goes into `I16` or wider by name (`scheme.target(I16).encrypt(value)`), or into an equality index + = note: bytes order only into a target named for them, `scheme.target(Bytes)`: no ordering operator compares bytes + = help: the following other types implement trait `Orderable`: + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + &jiff::civil::date::Date + &jiff::timestamp::Timestamp + and $N others +note: required by a bound in `OreBlockTerm` + --> src/sem/mod.rs + | + | pub struct OreBlockTerm(ore_rs::Term, PhantomData T>); + | ^^^^^^^^^ required by this bound in `OreBlockTerm` diff --git a/packages/stack-encrypt/tests/ui/pass/order_indexes.rs b/packages/stack-encrypt/tests/ui/pass/order_indexes.rs new file mode 100644 index 0000000000..637ca34a94 --- /dev/null +++ b/packages/stack-encrypt/tests/ui/pass/order_indexes.rs @@ -0,0 +1,33 @@ +//! Every type an ordering operator accepts takes each order index: as a set +//! of indexes, as an `Encrypted` target, and as a term on its own, owned or +//! borrowed. `order_index_on_bytes.rs` is the other side: bytes take none. +use stack_encrypt::sem::{OpeTerm, OreBlockTerm, OreTerm}; +use stack_encrypt::target::{self, indexed, Borrowed, EncryptTarget}; +use stack_encrypt::value::{Date, Decimal, Timestamp}; +use stack_encrypt::{Encrypted, Ope, Ore, OreBlock}; + +macro_rules! takes_every_order_index { + ($($ty:ty),+ $(,)?) => {$( + let _ = indexed::<$ty, (), Borrowed, _>(Ore); + let _ = indexed::<$ty, (), Borrowed, _>(Ope); + let _ = indexed::<$ty, (), Borrowed, _>(OreBlock); + let _ = > as EncryptTarget<$ty>>::encryption::<()>(); + let _ = > as EncryptTarget<$ty>>::encryption::<()>(); + let _ = > as EncryptTarget<$ty>>::encryption::<()>(); + let _ = as EncryptTarget<$ty>>::encryption::<()>(); + let _ = as EncryptTarget<$ty>>::encryption::<()>(); + let _ = as EncryptTarget<$ty>>::encryption::<()>(); + let _ = as EncryptTarget<$ty>>::owned_encryption::<()>(); + let _ = as EncryptTarget<$ty>>::owned_encryption::<()>(); + let _ = as EncryptTarget<$ty>>::owned_encryption::<()>(); + let _ = target::ore::<$ty, (), Borrowed>(); + let _ = target::ope::<$ty, (), Borrowed>(); + let _ = target::ore_block::<$ty, (), Borrowed>(); + )+}; +} + +fn main() { + takes_every_order_index!( + u16, u32, u64, u128, i16, i32, i64, i128, f32, f64, String, Date, Timestamp, Decimal, + ); +} diff --git a/packages/stack-encrypt/tests/value_conformance.rs b/packages/stack-encrypt/tests/value_conformance.rs index d63d0fe36f..506e886a3f 100644 --- a/packages/stack-encrypt/tests/value_conformance.rs +++ b/packages/stack-encrypt/tests/value_conformance.rs @@ -77,10 +77,6 @@ struct Case { companion: Option, /// Another spelling whose equality query must derive the stored term. equal_query: Option, - /// Stored indexes no query operator answers for this kind: the term is - /// stored, and a query of it is refused as `operator_not_answered`. - #[serde(default)] - unanswered: Vec, expected_error: Option, } @@ -170,15 +166,6 @@ async fn shared_record_value_profile() { assert!(KINDS[..18].contains(&case.kind.as_str()), "{}", case.id); assert!(KINDS.contains(&case.input.kind.as_str()), "{}", case.id); assert!(!case.outputs.is_empty() && case.outputs[0] == "c"); - // An unanswered index must be one the case declares, or the entry - // checks nothing. - for index in &case.unanswered { - assert!( - case.outputs[1..].contains(index), - "{}: unanswered {index} is not a declared index", - case.id - ); - } let is_null = case.input.kind == "null"; assert_eq!(case.frame.is_none(), is_null, "{}: frame", case.id); let mut spec = json!({"context": ["conformance", "value"], "outputs": case.outputs, "type": case.kind}); @@ -262,25 +249,6 @@ async fn shared_record_value_profile() { "ore" | "ope" => Op::Lt, other => panic!("{other}"), }; - if case.unanswered.contains(index) { - let error = dynamic::query_term( - &keyset, - &plan, - "value", - operator, - value(target), - &NoTargets, - ) - .err() - .expect("an unanswered index is refused before any term"); - refusal( - &error, - "stack_encrypt::dynamic_source", - "operator_not_answered", - "value", - ); - continue; - } queried.push((target.clone(), operator, term.clone())); } if output == 0 {