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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion agentcore/chatlog/compaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/felinics/twilight/agentcore/session/filestore/filestoretest"
"github.com/felinics/twilight/agentcore/session/unit"
"github.com/felinics/twilight/agentcore/session/writer"
"github.com/felinics/twilight/agentcore/session/writer/writertest"
)

func TestPlanCompaction(t *testing.T) {
Expand Down Expand Up @@ -130,7 +131,7 @@ func compactionWriter(t *testing.T) writer.Writer {
t.Fatal(err)
}
bindings, artifacts := artifacttest.Stores(t)
w, err := writer.OpenWriter(ctx, store, reg, writer.Admission{Bindings: bindings, Ledger: artifacts}, "s", session.OpenOptions{})
w, err := writertest.Open(t, ctx, &writer.Factory{Store: store, Registry: reg, Admission: writer.Admission{Bindings: bindings, Ledger: artifacts}}, "s", session.OpenOptions{})
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion agentcore/chatlog/foldbench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func benchFold(b *testing.B, def module.ProjectionDefinition, n int) {
// Context now appends and copies only the map an event writes; Surface keeps
// its content in persistent Tables (O(sqrt(n)) per write). These benchmarks
// pin the shape: doubling N should roughly double elapsed time. The cost is
// paid by OpenWriter's rebuild and ProjectionReader.Load, which fold the log.
// paid by Writer binding's rebuild and ProjectionReader.Load, which fold the log.
func BenchmarkSurfaceFold(b *testing.B) {
for _, n := range []int{400, 800, 1600, 3200} {
b.Run(fmt.Sprint(n), func(b *testing.B) { benchFold(b, SurfaceProjection, n) })
Expand Down
25 changes: 25 additions & 0 deletions agentcore/chatlog/input.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package chatlog

import (
"context"
"errors"

"github.com/felinics/twilight/agentcore/run"
"github.com/felinics/twilight/agentcore/session/unit"
"github.com/felinics/twilight/agentcore/session/writer"
)

// SubmitInput contributes input admission to a cross-module unit, for example
// an agent's atomic command receipt. Its caller supplies the stable operation
// identity; this module alone constructs the chatlog fact. It starts no Turn.
func SubmitInput(id run.InputID, content run.CanonicalJSON) unit.Part {
return unit.PartFunc(func(_ context.Context, _ writer.View, now int64) ([]writer.TypedBatch, error) {
if id == "" || content.IsZero() {
return nil, errors.New("chatlog: input identity and content are required")
}
return []writer.TypedBatch{{Domain: Stream, Events: []writer.TypedEvent{{
Type: TypeInputSubmitted, RecordedAtUnixMilli: now,
Value: InputSubmittedPayload{InputID: InputID(id), Content: content, SubmittedAtUnixMilli: now},
}}}}, nil
})
}
Loading
Loading