mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
internal/ was 141 packages side by side, so nothing but a reader's memory
said which were foundations and which assembled the rest. Each now sits in a
layer directory, and the directory is the declaration:
base L0 foundation with no domain in it
contract L1 types and interfaces the layers above agree on
model, tools, safety, ext, state, platform
L2 subsystems, peers of one another
runtime L3 the turn engine
session L4 the controller
assembly L5 the composition root
frontend L6 cli, serve, acp and the host adapters
Only paths change: package names, code and behaviour do not. Imports,
repolint and coverage baselines, sensitive paths, CI package lists and docs
follow the new paths; release notes keep the paths they were written with,
and sample paths inside tests and fixtures keep theirs.
repolint gains layer-order: a package may import its own layer and those
below it, read from where it lives. The 47 imports that point upward today
are recorded as that rule's opening debt (-allow-widen, a new rule's first
baseline) and can only go down. Most of it is config, which still reaches
into eight subsystems and is the next thing to take apart; the rest is
event, history and a few tools reaching into runtime for types that belong
in contract.
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"reasonix/internal/contract/tool"
|
|
)
|
|
|
|
// The contract internal/contract/tool enforces over the built-ins, over the tools this
|
|
// package owns. Listed explicitly because these are constructed by the host
|
|
// rather than registered globally — a new one has to be added here, which is
|
|
// the point at which its author is asked for the reason and for which host
|
|
// fact it names.
|
|
func TestAgentContextualToolsExplainThemselves(t *testing.T) {
|
|
want := map[string]string{
|
|
"submit_plan": codeNoPlanningTurn,
|
|
"conclude_no_changes": codeNoPlanningTurn,
|
|
}
|
|
for _, target := range []tool.Tool{&SubmitPlanTool{}, &ConcludeNoChangesTool{}} {
|
|
if _, ok := target.(tool.ContextualTool); !ok {
|
|
t.Errorf("%s is listed here but is not contextual", target.Name())
|
|
continue
|
|
}
|
|
r, ok := target.(tool.ContextualReasoner)
|
|
if !ok {
|
|
t.Errorf("%s cannot say why it is unavailable", target.Name())
|
|
continue
|
|
}
|
|
refusal := r.Unavailable(context.Background())
|
|
if strings.TrimSpace(refusal.Message) == "" {
|
|
t.Errorf("%s returned a blank reason", target.Name())
|
|
}
|
|
if refusal.Code != want[target.Name()] {
|
|
t.Errorf("%s refusal code = %q, want %q", target.Name(), refusal.Code, want[target.Name()])
|
|
}
|
|
}
|
|
}
|
|
|
|
// Both plan tools refuse for one predicate and phrase it for their own caller.
|
|
// That the words differ while the identity does not is the whole point: a
|
|
// reader grouping these two by text would see two kinds of failure.
|
|
func TestPlanToolsShareOneIdentityAndKeepTheirOwnWords(t *testing.T) {
|
|
submit := (&SubmitPlanTool{}).Unavailable(context.Background())
|
|
conclude := (&ConcludeNoChangesTool{}).Unavailable(context.Background())
|
|
if submit.Code != conclude.Code {
|
|
t.Fatalf("codes diverged: %q vs %q", submit.Code, conclude.Code)
|
|
}
|
|
if submit.Message == conclude.Message {
|
|
t.Fatal("the two tools now say the same sentence; the test no longer proves words are free to differ")
|
|
}
|
|
}
|