instant_record 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -0
- data/README.md +267 -61
- data/app/controllers/instant_record/bootstraps_controller.rb +39 -12
- data/app/controllers/instant_record/events_controller.rb +58 -6
- data/app/controllers/instant_record/files_controller.rb +116 -0
- data/app/controllers/instant_record/mutations_controller.rb +84 -5
- data/app/controllers/instant_record/native_screens_controller.rb +60 -0
- data/app/controllers/instant_record/records_controller.rb +86 -8
- data/app/controllers/instant_record/shells_controller.rb +64 -0
- data/app/controllers/instant_record/sync_notices_controller.rb +81 -0
- data/app/helpers/instant_record/sync_notices_helper.rb +41 -0
- data/app/jobs/instant_record/shell_build_job.rb +16 -0
- data/app/models/instant_record/change.rb +36 -3
- data/app/models/instant_record/mutation_applier.rb +633 -50
- data/app/views/instant_record/sync_notices/_notices.html.erb +63 -0
- data/compiled/README.md +272 -0
- data/compiled/pipeline/browser_migrations.rb +18 -0
- data/compiled/pipeline/build.rb +13 -0
- data/compiled/pipeline/build_native.rb +14 -0
- data/compiled/pipeline/native/host.c +78 -0
- data/compiled/pipeline/native/instant_record_native.h +57 -0
- data/compiled/pipeline/native_shim.c +149 -0
- data/compiled/pipeline/reactor_shim.c +66 -0
- data/compiled/pipeline/sqlite/rh_shim.c +5 -0
- data/compiled/pipeline/sqlite_release.rb +43 -0
- data/compiled/toolchain.env.example +22 -0
- data/compiled/web/index.html +20 -0
- data/compiled/web/package-lock.json +884 -0
- data/compiled/web/package.json +17 -0
- data/compiled/web/src/app-host-core.js +556 -0
- data/compiled/web/src/app-host.js +16 -0
- data/compiled/web/src/branch-manager.js +140 -0
- data/compiled/web/src/branch-preview.js +397 -0
- data/compiled/web/src/changes.js +191 -0
- data/compiled/web/src/faults.js +172 -0
- data/compiled/web/src/flight-recorder.js +347 -0
- data/compiled/web/src/history-fill.js +68 -0
- data/compiled/web/src/http-headers.js +100 -0
- data/compiled/web/src/leader-election.js +705 -0
- data/compiled/web/src/main.js +608 -0
- data/compiled/web/src/manifest.js +112 -0
- data/compiled/web/src/opfs-wasi-core.js +109 -0
- data/compiled/web/src/opfs-wasi-file.js +8 -0
- data/compiled/web/src/reactor-runtime.js +1692 -0
- data/compiled/web/src/redactor.js +518 -0
- data/compiled/web/src/release-updates.js +48 -0
- data/compiled/web/src/replay.js +338 -0
- data/compiled/web/src/schema-recovery.js +204 -0
- data/compiled/web/src/server-request.js +68 -0
- data/compiled/web/src/sha256.js +98 -0
- data/compiled/web/src/shell.js +52 -0
- data/compiled/web/src/snapshot-store.js +38 -0
- data/compiled/web/src/sqlite-redactor.js +111 -0
- data/compiled/web/src/storage-backend.js +159 -0
- data/compiled/web/src/stream-leader.js +675 -0
- data/compiled/web/src/sync-context.js +91 -0
- data/compiled/web/src/sync-drain.js +104 -0
- data/compiled/web/src/sync-schedule.js +9 -0
- data/compiled/web/src/wasi-minimal.js +275 -0
- data/compiled/web/src/worker.js +39 -0
- data/compiled/web/vite.config.js +27 -0
- data/config/routes.rb +25 -0
- data/db/migrate/20261119000201_add_scope_to_instant_record_changes.rb +7 -0
- data/db/migrate/20261121000001_create_instant_record_sync_notices.rb +21 -0
- data/db/migrate/20261121000101_add_partition_to_instant_record_changes.rb +8 -0
- data/db/migrate/20261121230300_add_delay_line_to_instant_record_outbox.rb +10 -0
- data/exe/instant_record_mcp +6 -0
- data/frontend/LiveList.js +67 -0
- data/frontend/chord.js +79 -0
- data/frontend/file.js +65 -0
- data/frontend/files.js +738 -0
- data/frontend/focus.js +10 -0
- data/frontend/held.js +192 -0
- data/frontend/http.js +76 -0
- data/frontend/index.js +53 -0
- data/frontend/keyboard.js +56 -0
- data/frontend/live.js +298 -0
- data/frontend/notices.js +118 -0
- data/frontend/package.json +15 -0
- data/frontend/range.js +10 -0
- data/frontend/selection.js +47 -0
- data/frontend/shortcuts.js +25 -0
- data/frontend/sync-notices.js +130 -0
- data/frontend/undo.js +48 -0
- data/frontend/window.js +181 -0
- data/lib/generators/instant_record/install/install_generator.rb +18 -30
- data/lib/generators/instant_record/install/templates/instant_record.rb +34 -0
- data/lib/generators/instant_record/ios/ios_generator.rb +71 -0
- data/lib/generators/instant_record/ios/templates/App.swift.tt +35 -0
- data/lib/generators/instant_record/ios/templates/Info.plist +11 -0
- data/lib/generators/instant_record/ios/templates/LibraryEngine.swift +30 -0
- data/lib/instant_record/branch/sqlite_store.rb +142 -0
- data/lib/instant_record/branch.rb +388 -0
- data/lib/instant_record/client/notifier.rb +8 -12
- data/lib/instant_record/client/rebaser.rb +565 -0
- data/lib/instant_record/client/transport.rb +64 -42
- data/lib/instant_record/client.rb +1600 -169
- data/lib/instant_record/compiled_site.rb +85 -0
- data/lib/instant_record/compiler/app_stage.rb +212 -0
- data/lib/instant_record/compiler/ast_lowerer.rb +659 -0
- data/lib/instant_record/compiler/browser_migrations.rb +161 -0
- data/lib/instant_record/compiler/entry_builder.rb +832 -0
- data/lib/instant_record/compiler/fts5_smoke.rb +205 -0
- data/lib/instant_record/compiler/gem_vendor.rb +194 -0
- data/lib/instant_record/compiler/host_adapters.rb +506 -0
- data/lib/instant_record/compiler/kotlin_codegen.rb +209 -0
- data/lib/instant_record/compiler/manifest.rb +178 -0
- data/lib/instant_record/compiler/native_build.rb +586 -0
- data/lib/instant_record/compiler/native_contracts.rb +338 -0
- data/lib/instant_record/compiler/path_scrubber.rb +31 -0
- data/lib/instant_record/compiler/reachability_tracer.rb +1188 -0
- data/lib/instant_record/compiler/route_analyzer.rb +623 -0
- data/lib/instant_record/compiler/runner.rb +42 -0
- data/lib/instant_record/compiler/schema_lock.rb +606 -0
- data/lib/instant_record/compiler/source_pages.rb +77 -0
- data/lib/instant_record/compiler/static_linter.rb +770 -0
- data/lib/instant_record/compiler/swift_codegen.rb +341 -0
- data/lib/instant_record/compiler/toolchain.rb +219 -0
- data/lib/instant_record/compiler/wasm_build.rb +704 -0
- data/lib/instant_record/compiler/wasm_tree.rb +518 -0
- data/lib/instant_record/compiler.rb +277 -0
- data/lib/instant_record/configuration.rb +104 -0
- data/lib/instant_record/engine.rb +68 -18
- data/lib/instant_record/file_store.rb +162 -0
- data/lib/instant_record/files.rb +92 -0
- data/lib/instant_record/hlc.rb +387 -0
- data/lib/instant_record/host.rb +66 -0
- data/lib/instant_record/inertia/renderer.rb +52 -0
- data/lib/instant_record/inertia.rb +222 -0
- data/lib/instant_record/mcp/cli.rb +319 -0
- data/lib/instant_record/mcp/host_process.rb +229 -0
- data/lib/instant_record/mcp/http_exchange.rb +233 -0
- data/lib/instant_record/mcp/replica.rb +556 -0
- data/lib/instant_record/mcp/runtime.rb +406 -0
- data/lib/instant_record/mcp/server.rb +429 -0
- data/lib/instant_record/mcp.rb +47 -0
- data/lib/instant_record/native/contract.rb +367 -0
- data/lib/instant_record/native/node.rb +125 -0
- data/lib/instant_record/native/screen.rb +366 -0
- data/lib/instant_record/native/xcode_project.rb +344 -0
- data/lib/instant_record/native.rb +41 -0
- data/lib/instant_record/outbox_mutation.rb +81 -9
- data/lib/instant_record/outbox_upcaster.rb +161 -0
- data/lib/instant_record/read_tracker.rb +610 -0
- data/lib/instant_record/routing.rb +33 -0
- data/lib/instant_record/runtime_scoped.rb +4 -0
- data/lib/instant_record/shell.rb +486 -0
- data/lib/instant_record/sync_actions.rb +800 -0
- data/lib/instant_record/sync_metadata.rb +17 -2
- data/lib/instant_record/sync_notice.rb +234 -0
- data/lib/instant_record/sync_partition.rb +63 -0
- data/lib/instant_record/sync_scope.rb +300 -0
- data/lib/instant_record/sync_shape.rb +102 -0
- data/lib/instant_record/sync_window.rb +92 -15
- data/lib/instant_record/syncable.rb +313 -17
- data/lib/instant_record/testing/authoritative_server.rb +547 -0
- data/lib/instant_record/testing/chaos_simulator.rb +429 -0
- data/lib/instant_record/testing/cruby_host_bridge.rb +370 -0
- data/lib/instant_record/testing/fault_network.rb +140 -0
- data/lib/instant_record/testing/parity_suite.rb +435 -0
- data/lib/instant_record/testing/runtimes/base.rb +184 -0
- data/lib/instant_record/testing/runtimes/cruby_runtime.rb +255 -0
- data/lib/instant_record/testing/runtimes/native_runtime.rb +346 -0
- data/lib/instant_record/testing/runtimes/wasm_runtime.rb +371 -0
- data/lib/instant_record/testing/wasm_host_bridge.mjs +240 -0
- data/lib/instant_record/testing.rb +333 -0
- data/lib/instant_record/trace/redactor.rb +278 -0
- data/lib/instant_record/trace/replayer.rb +126 -0
- data/lib/instant_record/trace/schema_extractor.rb +37 -0
- data/lib/instant_record/trace.rb +22 -0
- data/lib/instant_record/version.rb +1 -1
- data/lib/instant_record.rb +107 -37
- data/lib/tasks/instant_record.rake +299 -47
- data/native/ios/InstantRecordNative/Package.swift +12 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/AppHost.swift +706 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/Engine.swift +64 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/FileStore.swift +1048 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/HTTPEngine.swift +36 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/Icons.swift +19 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/Node.swift +64 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/ScreenView.swift +481 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/Screens.swift +94 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/StreamClient.swift +74 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/SyncNotice.swift +282 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/SyncSchedule.swift +153 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/Theme.swift +140 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/Transport.swift +108 -0
- data/native/ios/InstantRecordNative/Sources/InstantRecordNative/TypedContracts.swift +237 -0
- data/native/ios/README.md +341 -0
- data/sig/instant_record/inertia.rbs +47 -0
- data/sig/instant_record/native.rbs +38 -0
- metadata +194 -18
- data/lib/generators/instant_record/install/templates/database.js +0 -32
- data/lib/generators/instant_record/install/templates/index.html +0 -69
- data/lib/generators/instant_record/install/templates/rails.sw.js +0 -750
- data/lib/instant_record/local_schema.rb +0 -75
- data/lib/instant_record/pglite_compat.rb +0 -40
|
@@ -1,53 +1,305 @@
|
|
|
1
1
|
namespace :instant_record do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
toolchain_path = lambda do
|
|
3
|
+
ENV.fetch("INSTANT_RECORD_TOOLCHAIN") { Rails.root.join("config/instant_record_toolchain.env") }
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require_toolchain = lambda do |path|
|
|
7
|
+
abort "No toolchain file at #{path}. Run bin/rails generate instant_record:install, or set INSTANT_RECORD_TOOLCHAIN." unless File.file?(path)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# What both builds are told about this app.
|
|
11
|
+
compiler_options = lambda do
|
|
12
|
+
require "instant_record/compiler"
|
|
13
|
+
Rails.application.eager_load!
|
|
14
|
+
models = InstantRecord.syncable_models
|
|
15
|
+
mount_path = Rails.application.config.instant_record.mount_path || InstantRecord::DEFAULT_MOUNT_PATH
|
|
16
|
+
sync_windows = models.each_with_object({}) do |model, map|
|
|
17
|
+
window = model.instant_record_sync_window
|
|
18
|
+
next unless window
|
|
19
|
+
|
|
20
|
+
map[model.name] = { limit: window.limit, partition_by: window.partition_by }
|
|
21
|
+
end
|
|
22
|
+
{
|
|
23
|
+
root: Rails.root,
|
|
24
|
+
models: models.map(&:name),
|
|
25
|
+
sync_windows: sync_windows,
|
|
26
|
+
toolchain: toolchain_path.call,
|
|
27
|
+
endpoint: ENV.fetch("SYNC_ENDPOINT") { mount_path },
|
|
28
|
+
mount_path: mount_path,
|
|
29
|
+
baseline: Rails.application.config.instant_record.compiled_migration_baseline,
|
|
30
|
+
migration_paths: Rails.application.config.paths["db/migrate"].existent,
|
|
31
|
+
island: ENV["INSTANT_RECORD_ISLAND"].presence || Rails.application.config.instant_record.island,
|
|
32
|
+
overrides: Rails.application.config.instant_record.include,
|
|
33
|
+
shell_snapshot: Rails.application.config.instant_record.shell_snapshot
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
desc "Print the canonical instant_record.manifest.json for this app's local-first island"
|
|
38
|
+
task :manifest, [:island] => :environment do |_task, args|
|
|
39
|
+
require "instant_record/compiler"
|
|
40
|
+
manifest = InstantRecord::Compiler.manifest(
|
|
41
|
+
root: Rails.root,
|
|
42
|
+
island: args[:island].presence || ENV["INSTANT_RECORD_ISLAND"].presence || Rails.application.config.instant_record.island,
|
|
43
|
+
overrides: Rails.application.config.instant_record.include,
|
|
44
|
+
migration_paths: Rails.application.config.paths["db/migrate"].existent
|
|
45
|
+
)
|
|
46
|
+
puts manifest.to_json
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc "Compile this Rails app to a static browser site using Roundhouse, Spinel and SQLite"
|
|
50
|
+
task compile: :environment do
|
|
51
|
+
# The options first: asking for them is what loads the compiler.
|
|
52
|
+
options = compiler_options.call
|
|
53
|
+
require_toolchain.call(options[:toolchain])
|
|
54
|
+
output = InstantRecord::Compiler.build(**options)
|
|
55
|
+
puts "Compiled browser site: #{output}"
|
|
56
|
+
rescue InstantRecord::Compiler::BuildError, ArgumentError => e
|
|
57
|
+
abort e.message
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "Build the compiled browser site"
|
|
61
|
+
task build: :compile
|
|
62
|
+
|
|
63
|
+
desc "Build this Rails app, with its app/screens, as libraries a native app links: instant_record:native[iphonesimulator] or [iphoneos]"
|
|
64
|
+
task :native, [:target] => :environment do |_task, args|
|
|
65
|
+
options = compiler_options.call
|
|
66
|
+
require_toolchain.call(options[:toolchain])
|
|
67
|
+
output = InstantRecord::Compiler.build_native(
|
|
68
|
+
**options.except(:shell_snapshot),
|
|
69
|
+
target: args[:target],
|
|
70
|
+
swift_out: ENV["SWIFT_OUT"],
|
|
71
|
+
kotlin: ENV["KOTLIN"] == "1" || ENV["KOTLIN_OUT"].present?,
|
|
72
|
+
kotlin_out: ENV["KOTLIN_OUT"],
|
|
73
|
+
kotlin_package: ENV.fetch("KOTLIN_PACKAGE", "dev.instantrecord.contracts")
|
|
74
|
+
)
|
|
75
|
+
puts "Native libraries: #{output}"
|
|
76
|
+
rescue InstantRecord::Compiler::BuildError, ArgumentError => e
|
|
77
|
+
abort e.message
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
namespace :native do
|
|
81
|
+
desc "Generate typed Swift (and optional Kotlin) contract bindings from app/screens without running a C build"
|
|
82
|
+
task contracts: :environment do
|
|
83
|
+
require "instant_record/compiler"
|
|
84
|
+
swift_out = ENV.fetch("SWIFT_OUT") { Rails.root.join("tmp/instant_record/compiled/.build-native/generated/InstantRecordContracts.swift").to_s }
|
|
85
|
+
kotlin_out = ENV["KOTLIN_OUT"] || (ENV["KOTLIN"] == "1" ? Rails.root.join("tmp/instant_record/compiled/.build-native/generated/InstantRecordContracts.kt").to_s : nil)
|
|
86
|
+
result = InstantRecord::Compiler.generate_native_contracts(
|
|
87
|
+
screens_dir: Rails.root.join("app/screens").to_s,
|
|
88
|
+
swift_out: swift_out,
|
|
89
|
+
kotlin_out: kotlin_out,
|
|
90
|
+
kotlin_package: ENV.fetch("KOTLIN_PACKAGE", "dev.instantrecord.contracts")
|
|
91
|
+
)
|
|
92
|
+
if result[:contracts].empty?
|
|
93
|
+
puts "No native contracts declared in app/screens."
|
|
94
|
+
else
|
|
95
|
+
result[:written].each { |lang, path| puts "Generated #{lang} contracts (#{result[:contracts].size}): #{path}" }
|
|
96
|
+
end
|
|
97
|
+
rescue InstantRecord::Compiler::BuildError => e
|
|
98
|
+
abort e.message
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
desc "Run the local MCP stdio server or offline CLI around the compiled native host (pass CLI args after `--`)"
|
|
103
|
+
task mcp: :environment do
|
|
104
|
+
require "instant_record/compiler"
|
|
105
|
+
require "instant_record/mcp"
|
|
106
|
+
|
|
107
|
+
Rails.application.eager_load!
|
|
108
|
+
mount_path = Rails.application.config.instant_record.mount_path || InstantRecord::DEFAULT_MOUNT_PATH
|
|
109
|
+
default_endpoint =
|
|
110
|
+
if mount_path.to_s.start_with?("http://", "https://")
|
|
111
|
+
mount_path.to_s
|
|
112
|
+
else
|
|
113
|
+
"http://127.0.0.1:#{ENV.fetch('PORT', '3000')}#{mount_path}"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
screens = InstantRecord::Compiler::EntryBuilder.discover_screens(Rails.root.to_s).map(&:first)
|
|
117
|
+
models = InstantRecord.syncable_models.map(&:name)
|
|
118
|
+
builder = lambda do
|
|
119
|
+
options = compiler_options.call
|
|
120
|
+
require_toolchain.call(options[:toolchain])
|
|
121
|
+
InstantRecord::Compiler.build_native(**options, out: $stderr)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
cli_args =
|
|
125
|
+
if (sep = ARGV.index("--"))
|
|
126
|
+
ARGV[(sep + 1)..]
|
|
127
|
+
else
|
|
128
|
+
[]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
status = InstantRecord::Mcp::Cli.run(
|
|
132
|
+
cli_args,
|
|
133
|
+
defaults: {
|
|
134
|
+
root: Rails.root.to_s,
|
|
135
|
+
endpoint: default_endpoint,
|
|
136
|
+
models: models,
|
|
137
|
+
screens: screens,
|
|
138
|
+
builder: builder
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
exit(status)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
desc "Verify the compiler toolchain, static AOT/32-bit compatibility, and schema lockfile upgrade ladder (optional target: wasm, native, iphonesimulator, iphoneos)"
|
|
145
|
+
task :doctor, [:target] => :environment do |_task, args|
|
|
146
|
+
require "instant_record/compiler"
|
|
147
|
+
Rails.application.eager_load!
|
|
148
|
+
toolchain = toolchain_path.call
|
|
149
|
+
require_toolchain.call(toolchain)
|
|
150
|
+
report = InstantRecord::Compiler.doctor(
|
|
151
|
+
toolchain: toolchain,
|
|
152
|
+
target: args[:target] || :wasm,
|
|
153
|
+
web_dir: Rails.root.join("tmp/instant_record/compiled/web"),
|
|
154
|
+
root: Rails.root,
|
|
155
|
+
app_root: Rails.root,
|
|
156
|
+
baseline: Rails.application.config.instant_record.compiled_migration_baseline,
|
|
157
|
+
migration_paths: Rails.application.config.paths["db/migrate"].existent,
|
|
158
|
+
models: InstantRecord.syncable_models
|
|
159
|
+
)
|
|
160
|
+
puts report
|
|
161
|
+
abort "Doctor check failed." unless report.ok?
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
namespace :schema do
|
|
165
|
+
desc "Generate or update db/instant_record_lock.json from db/schema.rb and db/migrate"
|
|
166
|
+
task lock: :environment do
|
|
167
|
+
require "instant_record/compiler"
|
|
168
|
+
lock = InstantRecord::Compiler.lock_schema(
|
|
169
|
+
root: Rails.root,
|
|
170
|
+
baseline: Rails.application.config.instant_record.compiled_migration_baseline,
|
|
171
|
+
migration_paths: Rails.application.config.paths["db/migrate"].existent
|
|
172
|
+
)
|
|
173
|
+
puts "Wrote #{InstantRecord::Compiler::SchemaLock.path(Rails.root)} (schema version #{lock['schema_version']}, #{lock['versions'].size} versions)"
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
desc "Verify db/instant_record_lock.json and replay every historical schema version + pending outbox up to HEAD"
|
|
177
|
+
task verify: :environment do
|
|
178
|
+
require "instant_record/compiler"
|
|
179
|
+
Rails.application.eager_load!
|
|
180
|
+
report = InstantRecord::Compiler.verify_schema(
|
|
181
|
+
root: Rails.root,
|
|
182
|
+
baseline: Rails.application.config.instant_record.compiled_migration_baseline,
|
|
183
|
+
migration_paths: Rails.application.config.paths["db/migrate"].existent,
|
|
184
|
+
models: InstantRecord.syncable_models
|
|
185
|
+
)
|
|
186
|
+
puts report
|
|
187
|
+
abort "Schema lockfile verification failed." unless report.ok?
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
desc "Replay a recorded .irtrace flight recorder file deterministically in Node AppHost"
|
|
192
|
+
task :replay, [:file, :wasm] => :environment do |_task, args|
|
|
193
|
+
require "instant_record/trace"
|
|
194
|
+
|
|
195
|
+
# Support `rails instant_record:replay path/to/file.irtrace`,
|
|
196
|
+
# `rails "instant_record:replay[path/to/file.irtrace]"`, and `TRACE=...`.
|
|
197
|
+
extra = ARGV.drop_while { |arg| !arg.start_with?("instant_record:replay") }.drop(1)
|
|
198
|
+
positional = []
|
|
199
|
+
wasm_opt = args[:wasm].to_s.empty? ? ENV["WASM"] : args[:wasm]
|
|
200
|
+
db_opt = ENV["DB"]
|
|
201
|
+
json_opt = ENV["JSON"] == "1"
|
|
202
|
+
allow_mismatch = ENV["ALLOW_DIGEST_MISMATCH"] == "1"
|
|
203
|
+
stop_on_fault = ENV["STOP_ON_FAULT"] == "1"
|
|
204
|
+
max_steps = ENV["MAX_STEPS"]
|
|
205
|
+
|
|
206
|
+
i = 0
|
|
207
|
+
while i < extra.length
|
|
208
|
+
arg = extra[i]
|
|
209
|
+
if arg == "--wasm" && extra[i + 1]
|
|
210
|
+
wasm_opt = extra[i + 1]
|
|
211
|
+
i += 2
|
|
212
|
+
elsif arg == "--db" && extra[i + 1]
|
|
213
|
+
db_opt = extra[i + 1]
|
|
214
|
+
i += 2
|
|
215
|
+
elsif arg == "--max-steps" && extra[i + 1]
|
|
216
|
+
max_steps = extra[i + 1]
|
|
217
|
+
i += 2
|
|
218
|
+
elsif arg == "--json"
|
|
219
|
+
json_opt = true
|
|
220
|
+
i += 1
|
|
221
|
+
elsif arg == "--allow-digest-mismatch"
|
|
222
|
+
allow_mismatch = true
|
|
223
|
+
i += 1
|
|
224
|
+
elsif arg == "--stop-on-fault"
|
|
225
|
+
stop_on_fault = true
|
|
226
|
+
i += 1
|
|
227
|
+
elsif !arg.start_with?("-")
|
|
228
|
+
positional << arg
|
|
229
|
+
i += 1
|
|
230
|
+
else
|
|
231
|
+
i += 1
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
extra.each { |arg| Rake::Task.define_task(arg.to_sym) {} unless Rake::Task.task_defined?(arg) }
|
|
236
|
+
|
|
237
|
+
trace_file = args[:file].to_s.empty? ? (positional[0] || ENV["TRACE"]) : args[:file]
|
|
238
|
+
if trace_file.nil? || trace_file.empty?
|
|
239
|
+
abort "Usage: bin/rails instant_record:replay <file.irtrace> [--wasm <app.wasm>] [--db <file.sqlite3>] [--json]"
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
wasm_opt ||= positional[1]
|
|
243
|
+
result = InstantRecord::Trace.replay(
|
|
244
|
+
trace_path: trace_file,
|
|
245
|
+
wasm_path: wasm_opt,
|
|
246
|
+
db_path: db_opt,
|
|
247
|
+
root: defined?(Rails) && Rails.respond_to?(:root) ? Rails.root : nil,
|
|
248
|
+
toolchain: defined?(Rails) && Rails.respond_to?(:root) ? toolchain_path.call : nil,
|
|
249
|
+
json: json_opt,
|
|
250
|
+
allow_digest_mismatch: allow_mismatch,
|
|
251
|
+
stop_on_fault: stop_on_fault,
|
|
252
|
+
max_steps: max_steps
|
|
253
|
+
)
|
|
254
|
+
puts result.stdout unless result.stdout.empty?
|
|
255
|
+
warn result.stderr unless result.stderr.empty?
|
|
256
|
+
abort "Replay failed (exit #{result.status})" unless result.ok?
|
|
257
|
+
rescue InstantRecord::Trace::Error => e
|
|
258
|
+
abort e.message
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
namespace :files do
|
|
262
|
+
desc "Remove uploads of sync_file records that were given up: partials no piece has reached for DAYS days (default 2)"
|
|
263
|
+
task sweep: :environment do
|
|
264
|
+
days = ENV.fetch("DAYS", 2).to_f
|
|
265
|
+
removed = InstantRecord::Files.store.sweep(before: days.days.ago)
|
|
266
|
+
puts "Removed #{removed} given-up #{"upload".pluralize(removed)}"
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
desc "Run headless dual-runtime parity checks across CRuby+DB, compiled app.wasm (Node AppHost), and Native C ABI (Fiddle)"
|
|
271
|
+
task verify_parity: :environment do
|
|
272
|
+
require "instant_record/testing"
|
|
273
|
+
Rails.application.eager_load!
|
|
274
|
+
InstantRecord::Testing.verify_parity(
|
|
275
|
+
rails_app: Rails.application,
|
|
276
|
+
root: Rails.root
|
|
277
|
+
)
|
|
278
|
+
rescue InstantRecord::Testing::Error => e
|
|
279
|
+
abort e.message
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
desc "Run deterministic seeded multi-client chaos simulation across CRuby+DB, compiled app.wasm, and Native C ABI (SEED=, SEEDS=, STEPS=, CLIENTS=, RUNTIMES=, REQUIRE_COMPILED=1)"
|
|
283
|
+
task chaos: :environment do
|
|
284
|
+
require "instant_record/testing"
|
|
285
|
+
Rails.application.eager_load!
|
|
286
|
+
InstantRecord::Testing.run_chaos(
|
|
287
|
+
rails_app: Rails.application,
|
|
288
|
+
root: Rails.root
|
|
289
|
+
)
|
|
290
|
+
rescue InstantRecord::Testing::Error => e
|
|
291
|
+
abort e.message
|
|
36
292
|
end
|
|
37
293
|
end
|
|
38
294
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
next if ENV["INSTANT_RECORD_SKIP_BUILD"]
|
|
49
|
-
next unless Rails.application.config.instant_record.build_on_precompile
|
|
50
|
-
|
|
51
|
-
Rake::Task["instant_record:build"].invoke
|
|
295
|
+
Rake::Task.define_task("assets:precompile").enhance do
|
|
296
|
+
case Rails.application.config.instant_record.build_on_precompile
|
|
297
|
+
when true, :compiled
|
|
298
|
+
Rake::Task["instant_record:compile"].invoke
|
|
299
|
+
InstantRecord::Compiler.publish(Rails.root)
|
|
300
|
+
when false, nil
|
|
301
|
+
# The host app manages its own build.
|
|
302
|
+
else
|
|
303
|
+
raise ArgumentError, "build_on_precompile must be false, true, or :compiled"
|
|
52
304
|
end
|
|
53
305
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// swift-tools-version:5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "InstantRecordNative",
|
|
6
|
+
platforms: [.iOS(.v17), .macOS(.v14)],
|
|
7
|
+
products: [.library(name: "InstantRecordNative", targets: ["InstantRecordNative"])],
|
|
8
|
+
targets: [
|
|
9
|
+
.target(name: "InstantRecordNative"),
|
|
10
|
+
.testTarget(name: "InstantRecordNativeTests", dependencies: ["InstantRecordNative"]),
|
|
11
|
+
]
|
|
12
|
+
)
|