JuliusBrussee/caveman · error

ccr typed object budget

Error message

ccr typed object budget: %w

What it means

Wraps the storageBytes() query failure in PutObject: current retained bytes could not be read, so the budget check for the incoming object cannot be computed. The typed-object put fails closed rather than storing unaccounted bytes.

Solutions

  1. Check the wrapped error for lock or corruption causes
  2. Retry the put once the database is quiet
  3. Verify the storage accounting tables are intact
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at engine/ccr/store_sqlite.go:503 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/a627d46faabcd4b2. Report an issue: GitHub.

Appendix: source

Thrown at engine/ccr/store_sqlite.go:503

	}
	return metadata, nil
}

// PutObject stores one immutable typed working-memory object. Repeated puts of
// the same content-derived ID are idempotent; currentness changes use
// SetObjectCurrentness so invalidation stays explicit.
func (s *Store) PutObject(input Object) (string, error) {
	obj, err := prepareObject(input)
	if err != nil {
		return "", err
	}
	deps, err := json.Marshal(obj.Dependencies)
	if err != nil {
		return "", fmt.Errorf("ccr typed object dependencies: %w", err)
	}
	used, err := s.storageBytes()
	if err != nil {
		return "", fmt.Errorf("ccr typed object budget: %w", err)
	}
	var existingBytes int64
	err = s.db.QueryRow(`SELECT length(data)+length(dependencies_json) FROM typed_objects WHERE object_id=?`, obj.ID).Scan(&existingBytes)
	if errors.Is(err, sql.ErrNoRows) {
		existingBytes = 0
	} else if err != nil {
		return "", fmt.Errorf("ccr typed object budget: %w", err)
	}
	if used-existingBytes+int64(len(obj.Data)+len(deps)) > s.maxBytes {
		return "", fmt.Errorf("ccr typed object put: %w", ErrBudgetExceeded)
	}
	result, err := s.db.Exec(
		`INSERT INTO typed_objects (
		 object_id, object_type, content_hash, source, created_at, repository_state,
		 session_id, transform_version, currentness, lifecycle, dependencies_json,
		 original_byte_length, stored_byte_length, data
		) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
		ON CONFLICT(object_id) DO NOTHING`,

View on GitHub (pinned to 766dce6b13)