mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
A spend row could say what a call cost and not who caused it. The credential that placed the call was written into the user column, so an application — a program, which cannot owe anyone money — read as the customer. Over half a month's inference arrived attributed to a service account, and the query for unattributed spend found nothing, because by that column every row had an owner. bind is now the one place a record learns its principal, replacing a name written at each of 35 emit sites. Only a person is named: a person's credential names itself and no header can move it, a machine is recorded as the agent and names whoever the identity boundary authenticated before it, and a machine naming nobody leaves the column empty and says so. Attribution stays separate from settlement — naming a person never moves money. Alongside it the row gained the host that answered, the credential ref, and the conversation. Provider is our label for a route; origin is the address the bytes went to. Two columns can disagree, and that disagreement is the measurement — a customer sees the label, and we can still see who served it. The schema was stated in three places said to be kept in lockstep by comment, and four columns were declared, documented, populated on the record, and written by nothing. Empty is indistinguishable from unused, so they read as no-data. The write order is now one list the statement derives from, and tests fail on a column that is declared and never written.
50 lines
2.0 KiB
Go
50 lines
2.0 KiB
Go
// Copyright 2023-2026 Hanzo AI Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package object
|
|
|
|
import "testing"
|
|
|
|
// TestOriginIsTheHost: a provider's name is a word we chose and can keep saying
|
|
// after it stops being true; its URL is where the bytes go. Origin reduces the URL
|
|
// to the party at the other end — no path, no key, no scheme — because "who
|
|
// answered" is the only question a spend row needs it for.
|
|
func TestOriginIsTheHost(t *testing.T) {
|
|
for _, c := range []struct {
|
|
url string
|
|
want string
|
|
why string
|
|
}{
|
|
{"https://inference.do-ai.run/v1", "inference.do-ai.run", "the path is route detail"},
|
|
{"https://openrouter.ai/api/v1", "openrouter.ai", ""},
|
|
{"https://api.openai.com/v1", "api.openai.com", ""},
|
|
{"http://speech.hanzo.svc.cluster.local:8000", "speech.hanzo.svc.cluster.local",
|
|
"the port is not the party"},
|
|
{"localhost:11434", "localhost", "a bare host:port is a host, not a path"},
|
|
{"", "", "a provider with no URL has no address to name"},
|
|
{" ", "", "and neither does a blank one"},
|
|
{"://nonsense", "", "unparseable says nothing rather than guessing"},
|
|
} {
|
|
p := &Provider{Name: "any", ProviderUrl: c.url}
|
|
if got := p.Origin(); got != c.want {
|
|
t.Errorf("Origin(%q) = %q, want %q — %s", c.url, got, c.want, c.why)
|
|
}
|
|
}
|
|
|
|
// The zero provider is reachable from a failed route, where nothing answered.
|
|
if got := (*Provider)(nil).Origin(); got != "" {
|
|
t.Errorf("a nil provider answered %q; nothing served, so nothing is the answer", got)
|
|
}
|
|
}
|