mammoth-search-watch 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6ddb2d67a170a1a2b61d96bdc4b4a3cad2515f851fa2b261e858b551ccb02c40
4
+ data.tar.gz: 778673f6a9e4ae5988987a9880ba8fc47614e2fc6c1e8cf2a8caebb59c987e51
5
+ SHA512:
6
+ metadata.gz: fd3561aed67dd5e0a368cd3de5d01ca9bdd287a18337d53d94173edfe1c5efd3073725ec07c9f07f97f8b2625fd79aadc53b9d1fb4cd2ea4f4f81a8c4cf75a5a
7
+ data.tar.gz: 77ef0d24b8588620e0fe7ef1e6bfe74c06d1aca04d9867db7f755314f1548c982802ad5b2dc9359cf520b6a39fbf6243c456068b449f92169c5de6f3dccf4182
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [Unreleased]
2
+
3
+ - Initial boilerplate files generated from bundle gem ...
@@ -0,0 +1,14 @@
1
+ # Code of Conduct
2
+
3
+ "mammoth-search-watch" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ - Participants will be tolerant of opposing views.
6
+ - Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ - When interpreting the words and actions of others, participants should always assume good intentions.
8
+ - Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have concerns about behaviour within this project, please open an issue at:
11
+
12
+ https://github.com/kanutocd/mammoth-search-watch/issues/new
13
+
14
+ Please note that GitHub issues are public. Do not include sensitive personal information in your report.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Kennneth C. Demanawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # Mammoth Search Watch
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/mammoth-search-watch.svg)](https://badge.fury.io/rb/mammoth-search-watch)
4
+ [![CI](https://github.com/kanutocd/mammoth-search-watch/workflows/CI/badge.svg)](https://github.com/kanutocd/mammoth-search-watch/actions)
5
+ [![Ruby Version](https://img.shields.io/badge/ruby-%3E%3D%204.0-ruby.svg)](https://www.ruby-lang.org/en/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ Mammoth Search Watch observes SERP/search API request-response activity, persists normalized observation facts into PostgreSQL, and lets Mammoth deliver resulting changes through WAL-backed delivery.
9
+
10
+ **Mammoth Search Watch** is a SERP observation and drift-capture service built on the Mammoth data plane.
11
+
12
+ It captures SERP request/response observations, persists them as PostgreSQL facts, and lets Mammoth carry the resulting changes through PostgreSQL WAL, replication slots, and reliable downstream delivery.
13
+
14
+ SearchAPI is the first supported provider adapter.
15
+
16
+ ```text
17
+ Tiny observer / adapter
18
+
19
+ Mammoth Search Watch
20
+
21
+ PostgreSQL facts
22
+
23
+ PostgreSQL WAL + replication slot
24
+
25
+ Mammoth
26
+
27
+ Webhook / downstream delivery
28
+ ```
29
+
30
+ Mammoth Search Watch is intentionally **PostgreSQL-first**, **WAL-centric**, and **operationally boring**. It is not a generic HTTP event bus, not a scraper, and not an SEO dashboard.
31
+
32
+ ## Status
33
+
34
+ Early development. The public contract and storage model may change before `1.0`.
35
+
36
+ ## Core idea
37
+
38
+ A SERP API endpoint returns observable search state. Mammoth Search Watch records that state as durable PostgreSQL facts and emits only meaningful changes through Mammoth.
39
+
40
+ ```text
41
+ SERP API endpoint interaction
42
+
43
+ request observed
44
+ response observed
45
+
46
+ watch key + result hash
47
+
48
+ PostgreSQL insert
49
+
50
+ Mammoth delivery
51
+ ```
52
+
53
+ ## Intended audiences
54
+
55
+ Mammoth Search Watch is useful for two related audiences:
56
+
57
+ 1. **SERP API company itself** — product telemetry, support evidence, parser regression detection, compliance trails, and drift analytics.
58
+ 2. **SERP API company customers** — durable search-change events without rewriting business logic around polling and diffing.
59
+
60
+ ## Architecture boundary
61
+
62
+ Mammoth Search Watch creates PostgreSQL facts. Mammoth operates and delivers them.
63
+
64
+ ```text
65
+ Mammoth Search Watch
66
+ owns: observation ingestion, normalization, retention, drift fact persistence
67
+
68
+ Mammoth
69
+ owns: WAL consumption, replication slot handling, delivery, retries, dead letters, health, metrics
70
+ ```
71
+
72
+ This keeps Mammoth Search Watch true to the Mammoth model:
73
+
74
+ ```text
75
+ PostgreSQL table
76
+
77
+ WAL
78
+
79
+ replication slot
80
+
81
+ Mammoth data plane
82
+ ```
83
+
84
+ ## Fragile ingress table
85
+
86
+ The first integration boundary is intentionally simple: a fragile, retention-managed PostgreSQL table for observed HTTP activity.
87
+
88
+ Example shape:
89
+
90
+ ```sql
91
+ CREATE TYPE activity_type AS ENUM ('request', 'response');
92
+
93
+ CREATE TABLE activities (
94
+ id BIGSERIAL PRIMARY KEY,
95
+ tenant_id TEXT NOT NULL,
96
+ observation_id TEXT NOT NULL,
97
+ activity_type activity_type NOT NULL,
98
+ payload JSONB NOT NULL,
99
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
100
+ );
101
+ ```
102
+
103
+ The `activities` table is an ingress ledger, not canonical long-term history. Rows may be deleted after the configured retention period.
104
+
105
+ Consumers that want to retain full history may configure a longer retention period or replicate the table elsewhere.
106
+
107
+ ## Multi-tenancy
108
+
109
+ Mammoth Search Watch is designed to be multi-tenant aware.
110
+
111
+ A PostgreSQL Row-Level Security policy can isolate tenant data:
112
+
113
+ ```sql
114
+ ALTER TABLE activities ENABLE ROW LEVEL SECURITY;
115
+
116
+ CREATE POLICY tenant_isolation_policy
117
+ ON activities
118
+ USING (tenant_id = current_setting('app.current_tenant_id', true))
119
+ WITH CHECK (tenant_id = current_setting('app.current_tenant_id', true));
120
+ ```
121
+
122
+ Example usage:
123
+
124
+ ```sql
125
+ BEGIN;
126
+ SET LOCAL app.current_tenant_id = 'tenant_abc_123';
127
+
128
+ INSERT INTO activities (
129
+ tenant_id,
130
+ observation_id,
131
+ activity_type,
132
+ payload
133
+ )
134
+ VALUES (
135
+ 'tenant_abc_123',
136
+ 'obs_123',
137
+ 'request',
138
+ '{"engine":"google_rank_tracking","q":"ruby jobs"}'::jsonb
139
+ );
140
+
141
+ COMMIT;
142
+ ```
143
+
144
+ ## Watch key and result hash
145
+
146
+ Mammoth Search Watch separates request identity from response identity.
147
+
148
+ ```text
149
+ watch_key / observation_id
150
+ deterministic identity derived from the normalized request shape
151
+
152
+ sample_id
153
+ unique identity for a specific request/response instance
154
+
155
+ result_hash
156
+ deterministic hash of the normalized SERP API result
157
+ ```
158
+
159
+ The practical deduplication rule is:
160
+
161
+ ```text
162
+ same watched query + same result hash
163
+ = no new durable search state
164
+
165
+ same watched query + new result hash
166
+ = new PostgreSQL fact
167
+ = new WAL event
168
+ = Mammoth delivery
169
+ ```
170
+
171
+ A derived table may use a uniqueness rule like:
172
+
173
+ ```sql
174
+ UNIQUE (observation_id, result_hash)
175
+ ```
176
+
177
+ ## Tiny observer principle
178
+
179
+ Observers should have a very small footprint.
180
+
181
+ They should:
182
+
183
+ 1. copy selected request data,
184
+ 2. derive or receive an observation id,
185
+ 3. pass the request through,
186
+ 4. copy selected response data,
187
+ 5. pass the response through unchanged,
188
+ 6. enqueue or insert the observation payload.
189
+
190
+ Observers should not own drift analytics, Mammoth delivery, retention policy, or long-term product behavior.
191
+
192
+ ## Installation
193
+
194
+ Add the gem to your application:
195
+
196
+ ```bash
197
+ bundle add mammoth-search-watch
198
+ ```
199
+
200
+ Or install directly:
201
+
202
+ ```bash
203
+ gem install mammoth-search-watch
204
+ ```
205
+
206
+ ## Docker
207
+
208
+ Planned image:
209
+
210
+ ```text
211
+ ghcr.io/kanutocd/mammoth-search-watch:latest
212
+ ghcr.io/kanutocd/mammoth-search-watch:v0.1.0
213
+ ```
214
+
215
+ A typical local deployment uses separate containers for PostgreSQL, Mammoth, Mammoth Search Watch, and a webhook receiver.
216
+
217
+ ```yaml
218
+ services:
219
+ postgres:
220
+ image: postgres:17
221
+
222
+ mammoth:
223
+ image: ghcr.io/kanutocd/mammoth:latest
224
+ environment:
225
+ MAMMOTH_CONFIG: /config/mammoth.yml
226
+ volumes:
227
+ - ./config/mammoth.yml:/config/mammoth.yml:ro
228
+ - mammoth_data:/app/.sqlite3
229
+ depends_on:
230
+ - postgres
231
+
232
+ search-watch:
233
+ image: ghcr.io/kanutocd/mammoth-search-watch:latest
234
+ environment:
235
+ DATABASE_URL: postgres://mammoth_search_watch:secret@postgres:5432/search_watch
236
+ SEARCH_WATCH_RETENTION: 24h
237
+ ports:
238
+ - "9292:9292"
239
+ depends_on:
240
+ - postgres
241
+
242
+ volumes:
243
+ mammoth_data:
244
+ postgres_data:
245
+ ```
246
+
247
+ ## Kubernetes and Helm
248
+
249
+ Mammoth Search Watch should reuse the Mammoth deployment model where possible.
250
+
251
+ A dedicated Helm chart should only be introduced when Search Watch needs distinct deployment variants, such as:
252
+
253
+ - observer ingress service,
254
+ - tenant-specific configuration,
255
+ - retention jobs,
256
+ - RLS/bootstrap migrations,
257
+ - separate service accounts,
258
+ - separate secrets,
259
+ - hosted-vs-customer-pod profiles.
260
+
261
+ ## Non-goals
262
+
263
+ Mammoth Search Watch is not:
264
+
265
+ - a browser scraper,
266
+ - a proxy-rotation system,
267
+ - an SEO dashboard,
268
+ - a generic HTTP event bus,
269
+ - a replacement for a SERP API,
270
+ - a replacement for Mammoth.
271
+
272
+ ## Development
273
+
274
+ After checking out the repository:
275
+
276
+ ```bash
277
+ bin/setup
278
+ bundle exec rake test
279
+ ```
280
+
281
+ Use the console for local exploration:
282
+
283
+ ```bash
284
+ bin/console
285
+ ```
286
+
287
+ ## License
288
+
289
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
290
+
291
+ ## Code of Conduct
292
+
293
+ Everyone interacting with this project is expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "mammoth/search/watch"
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mammoth
4
+ module Search
5
+ module Watch
6
+ VERSION = "0.0.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "watch/version"
4
+
5
+ module Mammoth
6
+ module Search
7
+ module Watch
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module Mammoth
2
+ module Search
3
+ module Watch
4
+ VERSION: String
5
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
6
+ end
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mammoth-search-watch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kenneth C. Demanawa
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: agoo
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.15'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.15'
26
+ - !ruby/object:Gem::Dependency
27
+ name: mammoth
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.7'
40
+ description: |-
41
+ Mammoth Search Watch captures SERP request and response observations,
42
+ persists them as PostgreSQL facts, and lets Mammoth deliver resulting WAL-backed
43
+ change events. It is intentionally PostgreSQL-first, WAL-centric, and built as
44
+ a Mammoth descendant rather than a generic HTTP event bus.
45
+ email:
46
+ - kenneth.c.demanawa@gmail.com
47
+ executables:
48
+ - mammoth-search-watch
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - CHANGELOG.md
53
+ - CODE_OF_CONDUCT.md
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - exe/mammoth-search-watch
58
+ - lib/mammoth/search/watch.rb
59
+ - lib/mammoth/search/watch/version.rb
60
+ - sig/mammoth/search/watch.rbs
61
+ homepage: https://github.com/kanutocd/mammoth-search-watch
62
+ licenses:
63
+ - MIT
64
+ metadata:
65
+ bug_tracker_uri: https://github.com/kanutocd/mammoth-search-watch/issues
66
+ changelog_uri: https://github.com/kanutocd/mammoth-search-watch/blob/main/CHANGELOG.md
67
+ documentation_uri: https://github.com/kanutocd/mammoth-search-watch#readme
68
+ homepage_uri: https://github.com/kanutocd/mammoth-search-watch
69
+ rubygems_mfa_required: 'true'
70
+ source_code_uri: https://github.com/kanutocd/mammoth-search-watch
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '4.0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 4.0.15
86
+ specification_version: 4
87
+ summary: SERP observation and drift capture built on the Mammoth data plane.
88
+ test_files: []