Skip to content

Extending

Pt edited this page Jun 17, 2026 · 2 revisions

Lc is modular by design.
You can extend parser strategy, event orchestration, command semantics, and operational instrumentation independently.

Extension points

  1. parser implementation,
  2. command handlers,
  3. event hooks,
  4. scope schema,
  5. logging format and export.

1) Custom parsers

Implement:

  • Parse(code string) ([]stringParsing.ParsedNode, error)
  • Parse(code []byte) ([]byteParsing.ParsedBytes, error)

Inject with builder:

  • WithStringParser(...)
  • WithByteParser(...)

Production recommendation:

  • pin parser contracts with dedicated conformance tests.

2) Custom event hooks

Register handlers with:

  • UEP.Event.NewEvent(name, handler)

Common industrial use cases:

  • policy gates,
  • audit logging,
  • metrics and tracing wrappers,
  • output post-processing.

3) Scope schema governance

UEP.Scope is dynamic; discipline is essential.

Recommended:

  • central key constants,
  • stable value types per key,
  • validation at handler boundaries,
  • avoid collisions with runtime-reserved keys.

4) Command extension

When adding handlers:

  • validate inputs early,
  • separate validation/execution/output logic,
  • return explicit errors instead of hidden failures,
  • keep output deterministic.

5) Context integration

Use context-aware APIs:

  • ProcessStringWithCtx
  • ProcessBytesWithCtx

This enables deadline/cancellation propagation from your outer system.

6) Logger customization

core.Logger supports:

  • custom default format via NewLogger(format),
  • status-level format overrides via Logger.Statuses,
  • in-memory aggregation via Logger.Log and GetLog().

Suggested industrial rollout

  1. stabilize parser + command contracts,
  2. define runtime pipeline points,
  3. add audit/metrics hooks,
  4. enforce scope schema,
  5. run integration tests with cancellation and fault scenarios.

Clone this wiki locally