@mamund/tram 0.0.0-stage → 0.1.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.
@@ -0,0 +1,92 @@
1
+ # TRAM quick start
2
+
3
+ Run your first TRAM behavioral API test against a public endpoint. This walkthrough requires Node.js 18+, an internet connection, and no local API server.
4
+
5
+ TRAM executes a JSON manifest containing HTTP requests and assertions. It records the observed responses and evaluates them against the expected behavior.
6
+
7
+ ## 1. Install TRAM
8
+
9
+ Once the beta is published to npm, install it with:
10
+
11
+ ```bash
12
+ npm install -g @mamund/tram@beta
13
+ ```
14
+
15
+ Check the command:
16
+
17
+ ```bash
18
+ tram --help
19
+ ```
20
+
21
+ Before npm publication, use the source checkout instead: `npm link` from the repository root.
22
+
23
+ ## 2. Create a manifest
24
+
25
+ Create a file named `quick-start.json` containing:
26
+
27
+ ```json
28
+ {
29
+ "manifestVersion": "0.2",
30
+ "name": "JSONPlaceholder quick start",
31
+ "config": {
32
+ "baseUrl": "https://jsonplaceholder.typicode.com"
33
+ },
34
+ "tests": [
35
+ {
36
+ "id": "todo-1",
37
+ "name": "Retrieve a known todo",
38
+ "method": "GET",
39
+ "path": "/todos/1",
40
+ "expect": {
41
+ "status": 200,
42
+ "headers": [
43
+ { "name": "content-type", "contains": "application/json" }
44
+ ],
45
+ "body": [
46
+ { "path": "$.id", "equals": 1 },
47
+ { "path": "$.userId", "type": "number" },
48
+ { "path": "$.completed", "type": "boolean" }
49
+ ]
50
+ }
51
+ }
52
+ ]
53
+ }
54
+ ```
55
+
56
+ This example uses [JSONPlaceholder](https://jsonplaceholder.typicode.com/), a public demonstration REST API. It tests the HTTP response and selected JSON fields without requiring credentials or modifying server state.
57
+
58
+ ## 3. Validate the manifest
59
+
60
+ ```bash
61
+ tram quick-start.json --validate
62
+ ```
63
+
64
+ Validation checks the manifest structure without sending an HTTP request. A successful validation confirms that the manifest can be parsed; it does not establish that the API behaves as expected.
65
+
66
+ ## 4. Run the test and collect evidence
67
+
68
+ ```bash
69
+ tram quick-start.json --report results.json --transcript transcript.http
70
+ ```
71
+
72
+ TRAM requests `/todos/1`, checks the HTTP status, response header, and JSON body, and writes two evidence files. A successful run exits with status `0`; failed tests return a nonzero exit status.
73
+
74
+ The endpoint is an external service. A network outage, service change, or rate limit can cause this example to fail independently of TRAM.
75
+
76
+ ## 5. Inspect the results
77
+
78
+ Open `results.json` to examine assertion results and the test summary. Open `transcript.http` to review the HTTP exchange.
79
+
80
+ The evidence chain is:
81
+
82
+ ```text
83
+ Manifest → HTTP request/response → Assertions → Report and transcript
84
+ ```
85
+
86
+ Try changing `"equals": 1` to `"equals": 999` and rerun the manifest. The test should fail and the report should preserve the observed value alongside the failed assertion. Restore the original value afterward.
87
+
88
+ ## Continue learning
89
+
90
+ The [manifest specification](manifest-spec.md) documents available assertion operators, runtime data, and capture. For a stateful API example involving writes and reuse of captured values, see the [Tasks API tutorial](tasks-api-tutorial.md) (planned for the next documentation round). The Tasks API runs locally from the [TRAM repository](https://github.com/mamund/tram).
91
+
92
+ **Security note:** Reports and transcripts may contain API data. TRAM redacts a defined set of sensitive HTTP headers, but does not automatically remove secrets from URLs, bodies, or all assertion evidence. See [beta status](beta-status.md).
@@ -0,0 +1,557 @@
1
+ # TRAM Roadmap
2
+
3
+ ## Purpose
4
+
5
+ This document outlines the near-term direction for the TRAM project.
6
+
7
+ TRAM is still early-stage software. The current emphasis is not feature completeness, but validating a behavioral testing model that is:
8
+
9
+ * readable
10
+ * executable
11
+ * framework-independent
12
+ * teachable
13
+ * compatible with AI-assisted coaching workflows
14
+
15
+ The roadmap reflects ideas and implementation pressure discovered during real usage of the sample runner and manifest system.
16
+
17
+ Several core TRAM semantics are now operationally validated rather than purely exploratory. The project is increasingly evolving from a lightweight assertion runner into a layered behavioral modeling system for observable HTTP API behavior.
18
+
19
+ ---
20
+
21
+ # Current state
22
+
23
+ TRAM currently includes:
24
+
25
+ * dependency-free HTTP runner
26
+ * dependency-free assertion library
27
+ * manifest-driven behavioral testing
28
+ * layered behavioral modeling (Levels 0–5)
29
+ * happy-path and sad-path support
30
+ * workflow-oriented behavioral modeling
31
+ * governance-oriented behavioral assertions
32
+ * accumulated-state workflow modeling
33
+ * JSON/form/text request body support
34
+ * machine-readable reporting
35
+ * collection assertions (`each`)
36
+ * object assertions (`hasProperties`)
37
+ * object-map assertions (`eachProperty`)
38
+ * native type assertions (`type`)
39
+ * range assertions (`range`)
40
+ * optional property assertions
41
+ * stable run-scoped variables
42
+ * runtime interpolation
43
+ * nested traversal assertions
44
+ * validated nested traversal semantics
45
+ * array vs object-map traversal distinction
46
+ * path vs property traversal distinction
47
+ * npm CLI packaging
48
+ * executable `tram` CLI runner
49
+ * CLI argument hardening
50
+ * pre-run manifest validation
51
+ * accumulated validation error reporting
52
+ * supported method/bodyType validation
53
+ * authoring/runtime/assertion failure separation
54
+ * sample CRUD-style task API
55
+ * standalone manifest validation (--validate)
56
+
57
+ The current implementation has been validated against a real Node.js HTTP API using layered behavioral manifests spanning:
58
+
59
+ | Level | Focus |
60
+ |---|---|
61
+ | 0 | Surface |
62
+ | 1 | Shape |
63
+ | 2 | Safe behavior |
64
+ | 3 | Unsafe behavior |
65
+ | 4 | Workflow |
66
+ | 5 | Governance |
67
+
68
+ The behavioral levels build progressively. Early levels verify observable responses in isolation. Later levels introduce continuity through captured observations, workflow progression through hypermedia affordances, and governance through observable policy behavior.
69
+
70
+ | Level | Primary behavioral capability |
71
+ | ----- | ---------------------- |
72
+ | 0 | Observation |
73
+ | 1 | Structural description |
74
+ | 2 | Navigation |
75
+ | 3 | Captured observations |
76
+ | 4 | Hypermedia progression |
77
+ | 5 | Governance validation |
78
+
79
+
80
+ ---
81
+
82
+ # Guiding principles
83
+
84
+ TRAM development currently follows several constraints.
85
+
86
+ ## Explicit over implicit
87
+
88
+ TRAM prefers visible configuration over hidden runtime behavior.
89
+
90
+ ## Behavioral testing over implementation testing
91
+
92
+ The focus is API behavior, not internal function coverage.
93
+
94
+ ## Low-noise output
95
+
96
+ Reporting should help users quickly understand failures.
97
+
98
+ ## Stable executable core
99
+
100
+ The runner and assertion library should remain lightweight and predictable.
101
+
102
+ TRAM increasingly distinguishes between:
103
+
104
+ * manifest correctness
105
+ * runtime execution
106
+ * behavioral verification
107
+
108
+ ## Declarative sequencing over scripting
109
+
110
+ TRAM models workflows through visible sequential behavioral declarations rather than embedded procedural scripting.
111
+
112
+ ## Coaching-oriented design
113
+
114
+ The eventual AI Coach should help users understand behavioral API testing while collaboratively constructing executable manifests.
115
+
116
+ ## Layered behavioral isolation
117
+
118
+ TRAM separates observable concerns into progressive behavioral layers.
119
+
120
+ The layering model improves:
121
+
122
+ * debugging scope isolation
123
+ * manifest readability
124
+ * collaborative review
125
+ * AI-assisted generation
126
+ * long-term manifest maintenance
127
+
128
+ ---
129
+
130
+ # Near-term roadmap
131
+
132
+ ## Traversal and recursion hardening
133
+
134
+ The current traversal model now supports:
135
+
136
+ * nested `each`
137
+ * nested `eachProperty`
138
+ * path-based structural traversal
139
+ * property-based scalar assertions
140
+ * nested affordance validation
141
+
142
+ Future work will focus on:
143
+
144
+ * deeper recursive composition
145
+ * improved failure localization
146
+ * recursive reporting clarity
147
+ * null/undefined traversal edge cases
148
+ * traversal ergonomics
149
+
150
+ This work will likely evolve incrementally in response to real-world usage.
151
+
152
+ ---
153
+
154
+ ## Workflow-oriented behavioral modeling
155
+
156
+ Recent manifest patterns now support executable operational workflows including:
157
+
158
+ * captured observations
159
+ * accumulated state verification
160
+ * continuity validation
161
+ * multi-step operational narratives
162
+
163
+ Future work will focus on:
164
+
165
+ * declarative capture of observed responses
166
+ * captured observation reuse
167
+ * workflow visualization
168
+ * workflow diffing
169
+ * continuity diagnostics
170
+ * generated workflow review reports
171
+ * workflow-oriented coaching guidance
172
+
173
+ Workflow modeling is increasingly becoming a core architectural capability within TRAM rather than merely a convenience feature.
174
+
175
+ ## Named Endpoint Support
176
+
177
+ ### Motivation
178
+
179
+ Current TRAM manifests assume all requests execute against a single `baseUrl` defined in configuration. This works well for single-service APIs but limits the ability to model workflows that span multiple services.
180
+
181
+ As TRAM expands into workflow and governance testing, manifests should be able to express that a request targets a particular service without embedding deployment-specific URLs in the manifest itself.
182
+
183
+ The goal is to preserve executable intent while keeping infrastructure details in configuration.
184
+
185
+ ### Proposed Configuration
186
+
187
+ Add an optional `endpoints` collection to the configuration file.
188
+
189
+ ```json
190
+ {
191
+ "baseUrl": "http://localhost:3000",
192
+ "endpoints": {
193
+ "auth": "http://localhost:5000",
194
+ "billing": "http://localhost:4000",
195
+ "notifications": "http://localhost:6000"
196
+ }
197
+ }
198
+ ```
199
+
200
+ The existing `baseUrl` remains unchanged and continues to serve as the default target for requests that do not specify an endpoint.
201
+
202
+ ### Proposed Manifest Extension
203
+
204
+ Add an optional `endpoint` property to the `request` object.
205
+
206
+ ```json
207
+ {
208
+ "request": {
209
+ "endpoint": "auth",
210
+ "method": "POST",
211
+ "path": "/login"
212
+ }
213
+ }
214
+ ```
215
+
216
+ When omitted, the request uses the configured `baseUrl`.
217
+
218
+ ```json
219
+ {
220
+ "request": {
221
+ "method": "GET",
222
+ "path": "/tasks"
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Resolution Rules
228
+
229
+ Request execution follows these rules:
230
+
231
+ 1. If `request.endpoint` is present, resolve the corresponding URL root from `config.endpoints`.
232
+ 2. If `request.endpoint` is absent, use `config.baseUrl`.
233
+ 3. If an endpoint name cannot be resolved, execution fails with a descriptive error.
234
+
235
+ Example:
236
+
237
+ ```text
238
+ Unknown endpoint "authz".
239
+ Known endpoints: auth, billing, notifications
240
+ ```
241
+
242
+ ### Validation Changes
243
+
244
+ Manifest validation:
245
+
246
+ * `request.endpoint` is optional.
247
+ * When present, it must be a string.
248
+
249
+ Configuration validation:
250
+
251
+ * `endpoints` is optional.
252
+ * When present, it must be an object.
253
+ * Each endpoint value must be a string URL root.
254
+
255
+ ### Benefits
256
+
257
+ * Supports cross-service workflow testing.
258
+ * Keeps deployment details out of manifests.
259
+ * Preserves backward compatibility.
260
+ * Maintains separation between behavioral intent and runtime configuration.
261
+ * Improves support for workflow and governance scenarios where multiple services participate in a single business process.
262
+
263
+ ### Example Workflow
264
+
265
+ ```json
266
+ {
267
+ "request": {
268
+ "endpoint": "auth",
269
+ "method": "POST",
270
+ "path": "/login"
271
+ }
272
+ }
273
+ ```
274
+
275
+ ```json
276
+ {
277
+ "request": {
278
+ "endpoint": "tasks",
279
+ "method": "POST",
280
+ "path": "/tasks"
281
+ }
282
+ }
283
+ ```
284
+
285
+ ```json
286
+ {
287
+ "request": {
288
+ "endpoint": "notifications",
289
+ "method": "POST",
290
+ "path": "/messages"
291
+ }
292
+ }
293
+ ```
294
+
295
+ This allows manifests to express relationships between services while leaving deployment concerns in configuration.
296
+
297
+ ### Relationship to TRAM Layers
298
+
299
+ This enhancement is primarily intended to support Level 4 (Workflow) and Level 5 (Governance) testing.
300
+
301
+ Levels 0–3 focus on validating the behavior of individual resources and interactions. Named endpoint support enables manifests to describe business processes that span multiple services while preserving the same declarative testing model.
302
+
303
+ The feature does not introduce new assertion types or alter existing manifest semantics. Instead, it expands the execution environment so that workflow-oriented manifests can express service boundaries without exposing infrastructure details.
304
+
305
+ Named endpoint support also provides the foundation for future hypermedia traversal across service boundaries.
306
+
307
+ ---
308
+
309
+ ## Governance-oriented assertions
310
+
311
+ Current governance support includes:
312
+
313
+ * required-field validation
314
+ * allowed-value assertions
315
+ * range assertions
316
+ * optional property constraints
317
+ * policy-oriented sad-path testing
318
+
319
+ Future exploration areas include:
320
+
321
+ * authorization modeling
322
+ * workflow legality constraints
323
+ * permission-sensitive representations
324
+ * policy visualization
325
+ * governance-oriented review reporting
326
+
327
+ The distinction between representation shape and semantic legitimacy is expected to become increasingly important as APIs evolve and generated systems become more common.
328
+
329
+ ---
330
+
331
+ ## Reporting improvements
332
+
333
+ Current reporting intentionally emphasizes:
334
+
335
+ * concise console output
336
+ * readable failures
337
+ * machine-readable JSON reports
338
+
339
+ Possible future additions:
340
+
341
+ * summary-only mode
342
+ * grouped failure reporting
343
+ * colorized output
344
+ * timing summaries
345
+ * assertion statistics
346
+ * test filtering by tag
347
+ * validation-phase diagnostics
348
+ * workflow-phase summaries
349
+ * workflow continuity summaries
350
+ * governance-focused failure grouping
351
+
352
+ ---
353
+
354
+ ## Manifest ergonomics
355
+
356
+ The current JSON manifest is intentionally explicit.
357
+
358
+ Ongoing evaluation areas:
359
+
360
+ * repetition pressure
361
+ * readability
362
+ * local reasoning
363
+ * failure comprehension
364
+ * maintainability
365
+ * coaching usability
366
+ * workflow readability
367
+ * traversal readability
368
+
369
+ The project may eventually support alternate authoring formats while preserving the JSON manifest as the executable runtime representation.
370
+
371
+ Possible future directions include:
372
+
373
+ * markdown-oriented authoring
374
+ * review-oriented manifest projections
375
+ * generated operational summaries
376
+ * coaching-oriented editing workflows
377
+
378
+ ---
379
+
380
+ ## Namespace expansion
381
+
382
+ The current manifest system already supports:
383
+
384
+ ```text
385
+ data.* -- authored input
386
+ ```
387
+
388
+ Future namespaces under consideration:
389
+
390
+ ```text
391
+ capture.* -- captured observations
392
+ env.* -- execution environment
393
+ ```
394
+
395
+ Potential uses include:
396
+
397
+ * response capture reuse
398
+ * environment configuration
399
+ * runtime execution flexibility
400
+ * improved manifest portability
401
+ * workflow coordination
402
+ * multi-environment testing
403
+
404
+ The current design constraint remains:
405
+
406
+ ```text
407
+ maintain visible and inspectable runtime behavior
408
+ ```
409
+
410
+ ---
411
+
412
+ # AI Coach direction
413
+
414
+ The long-term direction for TRAM includes an AI Coaching layer.
415
+
416
+ The AI Coach is intended to:
417
+
418
+ 1. inspect `server.js` and/or API Story documents
419
+ 2. identify API behaviors
420
+ 3. suggest candidate tests
421
+ 4. distinguish happy and sad paths
422
+ 5. review request/response data shapes
423
+ 6. review assertion choices
424
+ 7. help users modify generated tests
425
+ 8. generate executable manifests
426
+
427
+ The coaching layer now also includes:
428
+
429
+ * layered manifest progression
430
+ * traversal-aware guidance
431
+ * capture guidance
432
+ * hypermedia workflow guidance
433
+ * governance guidance
434
+ * runtime interpolation guidance
435
+ * manifest debugging assistance
436
+ * workflow-oriented review patterns
437
+ * behavioral decomposition guidance
438
+
439
+ The coaching experience should preserve:
440
+
441
+ * user judgment
442
+ * visible reasoning
443
+ * intentional friction
444
+ * behavioral understanding
445
+
446
+ The goal is not one-shot test generation.
447
+
448
+ The goal is collaborative construction of behavioral API tests and executable operational models.
449
+
450
+ ---
451
+
452
+ # Review document generation
453
+
454
+ A future utility may generate human-readable review documents directly from manifests.
455
+
456
+ Possible flow:
457
+
458
+ ```text
459
+ api-tests.json
460
+ ↓
461
+ tram-review.js
462
+ ↓
463
+ TRAM Test Review Document
464
+ ```
465
+
466
+ Purpose:
467
+
468
+ * inspect coverage
469
+ * review behaviors
470
+ * identify weak assertions
471
+ * review happy/sad path balance
472
+ * support coaching/reflection loops
473
+ * inspect workflow continuity
474
+ * inspect governance assumptions
475
+
476
+ Important architectural rule:
477
+
478
+ ```text
479
+ The manifest is authoritative.
480
+ The review document is explanatory.
481
+ ```
482
+
483
+ The review document is intentionally:
484
+
485
+ * generated
486
+ * read-only
487
+ * regenerable
488
+ * non-authoritative
489
+
490
+ Possible future additions include:
491
+
492
+ * workflow summaries
493
+ * governance summaries
494
+ * behavioral coverage maps
495
+ * affordance inventories
496
+ * layer-oriented review views
497
+
498
+ ---
499
+
500
+ # Deferred from current scope
501
+
502
+ The following ideas are intentionally postponed:
503
+
504
+ ```text
505
+ schema validation
506
+ parallel execution
507
+ dedicated setup/teardown lifecycle sections
508
+ custom scripting
509
+ plugin systems
510
+ external assertion libraries
511
+ framework adapters
512
+ browser automation
513
+ ```
514
+
515
+ The current project emphasis remains:
516
+
517
+ ```text
518
+ behavioral clarity
519
+ workflow visibility
520
+ predictable execution
521
+ reviewability
522
+ human understanding
523
+ ```
524
+
525
+ ---
526
+
527
+ # Current development philosophy
528
+
529
+ TRAM is currently evolving through:
530
+
531
+ * real API testing
532
+ * iterative manifest authoring
533
+ * runner pressure-testing
534
+ * assertion refinement
535
+ * workflow-oriented experimentation
536
+ * governance-oriented modeling
537
+ * coaching-oriented design review
538
+ * CLI usability refinement
539
+
540
+ The project remains intentionally conservative at this stage.
541
+
542
+ The emphasis is:
543
+
544
+ ```text
545
+ clarity
546
+ behavior visibility
547
+ workflow visibility
548
+ predictability
549
+ reviewability
550
+ human understanding
551
+ ```
552
+
553
+ Execution is one outcome of a behavioral model. TRAM is increasingly focused on helping authors create, validate, execute, and review those models while preserving observable API behavior as the primary source of evidence. Validation establishes that the behavioral model is internally consistent. Execution gathers evidence about that model by observing a running API.
554
+
555
+ The long-term direction is not merely a larger assertion engine.
556
+
557
+ The larger goal is a system for creating readable, executable behavioral models of observable API behavior.