refresh-engine 0.1.0__py3-none-any.whl

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.
Files changed (35) hide show
  1. refresh_engine/__init__.py +169 -0
  2. refresh_engine/api/__init__.py +43 -0
  3. refresh_engine/api/abc.py +176 -0
  4. refresh_engine/api/engine.py +468 -0
  5. refresh_engine/api/protocols.py +89 -0
  6. refresh_engine/core/models.py +362 -0
  7. refresh_engine/detection/__init__.py +21 -0
  8. refresh_engine/detection/detector.py +54 -0
  9. refresh_engine/detection/fingerprints.py +115 -0
  10. refresh_engine/errors.py +57 -0
  11. refresh_engine/events/__init__.py +6 -0
  12. refresh_engine/events/models.py +42 -0
  13. refresh_engine/events/publisher.py +77 -0
  14. refresh_engine/execution/__init__.py +5 -0
  15. refresh_engine/execution/coordinator.py +128 -0
  16. refresh_engine/execution/executor.py +180 -0
  17. refresh_engine/observability/__init__.py +9 -0
  18. refresh_engine/observability/logging.py +49 -0
  19. refresh_engine/observability/metrics.py +44 -0
  20. refresh_engine/planning/__init__.py +6 -0
  21. refresh_engine/planning/dependency.py +79 -0
  22. refresh_engine/planning/planner.py +86 -0
  23. refresh_engine/py.typed +0 -0
  24. refresh_engine/scheduling/__init__.py +13 -0
  25. refresh_engine/scheduling/async_scheduler.py +126 -0
  26. refresh_engine/scheduling/external.py +17 -0
  27. refresh_engine/stores/__init__.py +11 -0
  28. refresh_engine/stores/memory.py +77 -0
  29. refresh_engine/triggers/__init__.py +16 -0
  30. refresh_engine/triggers/adapters.py +38 -0
  31. refresh_engine/triggers/selectors.py +46 -0
  32. refresh_engine-0.1.0.dist-info/METADATA +95 -0
  33. refresh_engine-0.1.0.dist-info/RECORD +35 -0
  34. refresh_engine-0.1.0.dist-info/WHEEL +4 -0
  35. refresh_engine-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,126 @@
1
+ """Asyncio-native interval scheduler."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ from collections.abc import Awaitable, Callable
7
+ from enum import StrEnum, auto
8
+
9
+ from apscheduler.schedulers.asyncio import AsyncIOScheduler
10
+
11
+ from refresh_engine.api.abc import AsyncSchedulerABC
12
+ from refresh_engine.errors import SchedulerError
13
+ from refresh_engine.events import EventKind, EventPublisher, RefreshEvent
14
+
15
+ ScheduledCallback = Callable[[], Awaitable[object]]
16
+
17
+
18
+ class SchedulerState(StrEnum):
19
+ STOPPED = auto()
20
+ RUNNING = auto()
21
+ PAUSED = auto()
22
+ STOPPING = auto()
23
+
24
+
25
+ class AsyncScheduler(AsyncSchedulerABC):
26
+ def __init__(
27
+ self,
28
+ callback: ScheduledCallback,
29
+ interval: float,
30
+ *,
31
+ events: EventPublisher | None = None,
32
+ run_immediately: bool = False,
33
+ cancel_active_on_stop: bool = False,
34
+ ) -> None:
35
+ if interval <= 0:
36
+ raise ValueError("interval must be positive")
37
+ self._callback = callback
38
+ self._interval = interval
39
+ self._events = events or EventPublisher()
40
+ self._run_immediately = run_immediately
41
+ self._cancel_active_on_stop = cancel_active_on_stop
42
+ self._state = SchedulerState.STOPPED
43
+ self._task: asyncio.Task[None] | None = None
44
+ self._active: asyncio.Task[object] | None = None
45
+ self._wake = asyncio.Event()
46
+ self._timer: AsyncIOScheduler | None = None
47
+
48
+ @property
49
+ def state(self) -> SchedulerState:
50
+ return self._state
51
+
52
+ async def start(self) -> None:
53
+ if self._state is not SchedulerState.STOPPED:
54
+ raise SchedulerError("scheduler is already started")
55
+ self._state = SchedulerState.RUNNING
56
+ self._timer = AsyncIOScheduler(event_loop=asyncio.get_running_loop())
57
+ self._timer.add_job(
58
+ self._wake.set,
59
+ "interval",
60
+ seconds=self._interval,
61
+ id="refresh-engine-interval",
62
+ coalesce=True,
63
+ max_instances=1,
64
+ )
65
+ self._timer.start()
66
+ self._task = asyncio.create_task(
67
+ self._run(), name="refresh-engine-async-scheduler"
68
+ )
69
+ if self._run_immediately:
70
+ self._wake.set()
71
+ await self._events.publish(RefreshEvent(EventKind.SCHEDULER_STARTED))
72
+
73
+ async def pause(self) -> None:
74
+ if self._state is not SchedulerState.RUNNING:
75
+ raise SchedulerError("only a running scheduler can be paused")
76
+ self._state = SchedulerState.PAUSED
77
+ assert self._timer is not None
78
+ self._timer.pause()
79
+
80
+ async def resume(self) -> None:
81
+ if self._state is not SchedulerState.PAUSED:
82
+ raise SchedulerError("only a paused scheduler can be resumed")
83
+ self._state = SchedulerState.RUNNING
84
+ assert self._timer is not None
85
+ self._timer.resume()
86
+
87
+ async def stop(self) -> None:
88
+ if self._state is SchedulerState.STOPPED:
89
+ return
90
+ self._state = SchedulerState.STOPPING
91
+ if self._timer is not None:
92
+ self._timer.shutdown(wait=False)
93
+ self._wake.set()
94
+ if self._active is not None and self._cancel_active_on_stop:
95
+ self._active.cancel()
96
+ if self._task is not None:
97
+ await self._task
98
+ self._state = SchedulerState.STOPPED
99
+ self._timer = None
100
+ await self._events.publish(RefreshEvent(EventKind.SCHEDULER_STOPPED))
101
+
102
+ async def _run(self) -> None:
103
+ try:
104
+ while self._state is not SchedulerState.STOPPING:
105
+ await self._wake.wait()
106
+ self._wake.clear()
107
+ if self._state is not SchedulerState.RUNNING:
108
+ continue
109
+ self._active = asyncio.create_task(
110
+ self._invoke_callback(), name="refresh-engine-scheduled-refresh"
111
+ )
112
+ try:
113
+ await self._active
114
+ except asyncio.CancelledError:
115
+ if self._state is not SchedulerState.STOPPING:
116
+ raise
117
+ finally:
118
+ self._active = None
119
+ finally:
120
+ if self._active is not None and not self._active.done():
121
+ if self._cancel_active_on_stop:
122
+ self._active.cancel()
123
+ await asyncio.gather(self._active, return_exceptions=True)
124
+
125
+ async def _invoke_callback(self) -> object:
126
+ return await self._callback()
@@ -0,0 +1,17 @@
1
+ """Adapter for externally owned schedulers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Awaitable, Callable
6
+
7
+ from refresh_engine.core.models import RefreshRequest, RefreshResult
8
+
9
+
10
+ class ExternalSchedulerAdapter:
11
+ def __init__(
12
+ self, submit: Callable[[RefreshRequest], Awaitable[RefreshResult]]
13
+ ) -> None:
14
+ self._submit = submit
15
+
16
+ async def run(self, request: RefreshRequest) -> RefreshResult:
17
+ return await self._submit(request)
@@ -0,0 +1,11 @@
1
+ """State store implementations."""
2
+
3
+ from refresh_engine.stores.memory import (
4
+ InMemoryStateStore,
5
+ InMemoryStateTransaction,
6
+ )
7
+
8
+ __all__ = [
9
+ "InMemoryStateStore",
10
+ "InMemoryStateTransaction",
11
+ ]
@@ -0,0 +1,77 @@
1
+ """Transactional in-memory state store."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ from collections.abc import Mapping
7
+ from types import MappingProxyType
8
+
9
+ from refresh_engine.api.abc import StateStoreABC, StateTransactionABC
10
+ from refresh_engine.core.models import ResourceState
11
+ from refresh_engine.errors import StateStoreError
12
+
13
+
14
+ class InMemoryStateTransaction(StateTransactionABC):
15
+ def __init__(self, store: InMemoryStateStore) -> None:
16
+ self._store = store
17
+ self._puts: dict[str, ResourceState] = {}
18
+ self._deletes: set[str] = set()
19
+ self._closed = False
20
+
21
+ async def put(self, state: ResourceState) -> None:
22
+ self._ensure_open()
23
+ self._puts[state.resource_id] = state
24
+ self._deletes.discard(state.resource_id)
25
+
26
+ async def delete(self, resource_id: str) -> None:
27
+ self._ensure_open()
28
+ self._deletes.add(resource_id)
29
+ self._puts.pop(resource_id, None)
30
+
31
+ async def commit(self) -> None:
32
+ self._ensure_open()
33
+ async with self._store._lock:
34
+ updated = dict(self._store._states)
35
+ for resource_id in self._deletes:
36
+ updated.pop(resource_id, None)
37
+ updated.update(self._puts)
38
+ self._store._states = updated
39
+ self._closed = True
40
+
41
+ async def rollback(self) -> None:
42
+ self._puts.clear()
43
+ self._deletes.clear()
44
+ self._closed = True
45
+
46
+ async def __aenter__(self) -> InMemoryStateTransaction:
47
+ return self
48
+
49
+ async def __aexit__(
50
+ self,
51
+ exc_type: type[BaseException] | None,
52
+ exc: BaseException | None,
53
+ traceback: object | None,
54
+ ) -> None:
55
+ if exc_type is not None and not self._closed:
56
+ await self.rollback()
57
+ elif not self._closed:
58
+ await self.commit()
59
+
60
+ def _ensure_open(self) -> None:
61
+ if self._closed:
62
+ raise StateStoreError("state transaction is already closed")
63
+
64
+
65
+ class InMemoryStateStore(StateStoreABC):
66
+ """Copy-on-write state with serialized atomic commits."""
67
+
68
+ def __init__(self, initial: Mapping[str, ResourceState] | None = None) -> None:
69
+ self._states = dict(initial or {})
70
+ self._lock = asyncio.Lock()
71
+
72
+ async def load_all(self) -> Mapping[str, ResourceState]:
73
+ async with self._lock:
74
+ return MappingProxyType(dict(self._states))
75
+
76
+ def transaction(self) -> InMemoryStateTransaction:
77
+ return InMemoryStateTransaction(self)
@@ -0,0 +1,16 @@
1
+ """Manual, event, and query trigger helpers."""
2
+
3
+ from refresh_engine.triggers.adapters import EventTrigger, QueryTrigger
4
+ from refresh_engine.triggers.selectors import (
5
+ IDSelector,
6
+ PredicateSelector,
7
+ TagSelector,
8
+ )
9
+
10
+ __all__ = [
11
+ "EventTrigger",
12
+ "IDSelector",
13
+ "PredicateSelector",
14
+ "QueryTrigger",
15
+ "TagSelector",
16
+ ]
@@ -0,0 +1,38 @@
1
+ """Event and query adapters that normalize refresh requests."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable, Iterable, Mapping
6
+ from typing import Any
7
+
8
+ from refresh_engine.core.models import (
9
+ RefreshMode,
10
+ RefreshRequest,
11
+ TriggerSource,
12
+ )
13
+
14
+
15
+ class EventTrigger:
16
+ def __init__(
17
+ self,
18
+ mapper: Callable[[object], RefreshRequest | None],
19
+ ) -> None:
20
+ self._mapper = mapper
21
+
22
+ def request_for(self, event: object) -> RefreshRequest | None:
23
+ return self._mapper(event)
24
+
25
+
26
+ class QueryTrigger:
27
+ def request(
28
+ self,
29
+ resource_ids: Iterable[str],
30
+ *,
31
+ metadata: Mapping[str, Any] | None = None,
32
+ ) -> RefreshRequest:
33
+ return RefreshRequest(
34
+ mode=RefreshMode.TARGETED,
35
+ resource_ids=frozenset(resource_ids),
36
+ trigger=TriggerSource.QUERY,
37
+ metadata=metadata or {},
38
+ )
@@ -0,0 +1,46 @@
1
+ """Generic resource selectors."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable, Iterable
6
+ from dataclasses import dataclass
7
+
8
+ from refresh_engine.api.abc import ResourceSelectorABC
9
+ from refresh_engine.core.models import Resource
10
+
11
+
12
+ @dataclass(frozen=True, slots=True)
13
+ class IDSelector(ResourceSelectorABC):
14
+ resource_ids: frozenset[str]
15
+
16
+ def __init__(self, resource_ids: Iterable[str]) -> None:
17
+ object.__setattr__(self, "resource_ids", frozenset(resource_ids))
18
+
19
+ def matches(self, resource: Resource) -> bool:
20
+ return resource.resource_id in self.resource_ids
21
+
22
+
23
+ @dataclass(frozen=True, slots=True)
24
+ class TagSelector(ResourceSelectorABC):
25
+ tags: frozenset[str]
26
+ match_all: bool = True
27
+
28
+ def __init__(self, tags: Iterable[str], match_all: bool = True) -> None:
29
+ object.__setattr__(self, "tags", frozenset(tags))
30
+ object.__setattr__(self, "match_all", match_all)
31
+
32
+ def matches(self, resource: Resource) -> bool:
33
+ resource_tags = frozenset(resource.metadata.get("tags", ()))
34
+ return (
35
+ self.tags <= resource_tags
36
+ if self.match_all
37
+ else bool(self.tags & resource_tags)
38
+ )
39
+
40
+
41
+ @dataclass(frozen=True, slots=True)
42
+ class PredicateSelector(ResourceSelectorABC):
43
+ predicate: Callable[[Resource], bool]
44
+
45
+ def matches(self, resource: Resource) -> bool:
46
+ return self.predicate(resource)
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.5
2
+ Name: refresh-engine
3
+ Version: 0.1.0
4
+ Summary: Production-grade generic refresh infrastructure
5
+ Author: S. Muni Harish
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: <3.13,>=3.12
14
+ Requires-Dist: apscheduler<4,>=3.11
15
+ Requires-Dist: networkx<4,>=3.6
16
+ Requires-Dist: structlog<26,>=25.4
17
+ Requires-Dist: tenacity<10,>=9.1
18
+ Description-Content-Type: text/markdown
19
+
20
+ # refresh-engine
21
+
22
+ `refresh-engine` is an asyncio-first, domain-neutral Python library for discovering
23
+ resources, detecting changes, planning dependency-aware work, and executing
24
+ application-defined refresh operations safely.
25
+
26
+ ## Features
27
+
28
+ - full, incremental, targeted, and dependency-aware refresh modes
29
+ - deterministic fingerprints and reliable cheap pre-checks
30
+ - bounded concurrency, retries, timeouts, and overlap policies
31
+ - transactional state with an in-memory default and application-injected durable stores
32
+ - asyncio and externally managed scheduling
33
+ - typed public protocols and ABC inheritance points
34
+ - native `structlog` lifecycle logging with configurable processors and redaction
35
+
36
+ Requires Python 3.12.
37
+
38
+ `RefreshEngine` uses `InMemoryStateStore` when `store` is omitted. Applications can
39
+ inject a SQLite, PostgreSQL, or other adapter through the public `StateStore`
40
+ protocol or `StateStoreABC`:
41
+
42
+ ```python
43
+ engine = RefreshEngine(source, operation, store=my_store)
44
+ ```
45
+
46
+ SQLite and PostgreSQL reference adapters are provided under
47
+ [`examples/`](examples/README.md); database clients are not part of the production
48
+ package.
49
+
50
+ ## Quick start
51
+
52
+ ```python
53
+ import asyncio
54
+ from refresh_engine import (
55
+ DiscoveryResult, PlanAction, RefreshEngine, Resource, ResourceSnapshot,
56
+ )
57
+
58
+ class Source:
59
+ async def discover(self):
60
+ async def resources():
61
+ yield Resource("alpha")
62
+ return DiscoveryResult(resources())
63
+
64
+ async def snapshot(self, resource):
65
+ return ResourceSnapshot(resource.resource_id, content={"value": 1})
66
+
67
+ async def apply(resource, snapshot, action, request):
68
+ assert resource is not None
69
+ print(action, resource.resource_id)
70
+
71
+ async def main():
72
+ engine = RefreshEngine(Source(), apply)
73
+ result = await engine.refresh()
74
+ print(result.status, result.refreshed_count)
75
+ await engine.close()
76
+
77
+ asyncio.run(main())
78
+ ```
79
+
80
+ For a `PlanAction.DELETE`, the operation receives a lightweight `Resource` carrying
81
+ the deleted ID and `snapshot=None`; deletion handling must not expect source payloads.
82
+
83
+ ## Documentation
84
+
85
+ - [Getting started](docs/getting-started.md)
86
+ - [Guides](docs/guides/index.md)
87
+ - [API reference](docs/api/index.md)
88
+ - [Architecture](docs/architecture/overview.md)
89
+ - [Runnable examples](examples/README.md)
90
+ - [Benchmarks](benchmarks/README.md)
91
+
92
+ ## Development and support
93
+
94
+ See [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md), the
95
+ [changelog](CHANGELOG.md), and the [Apache 2.0 license](LICENSE).
@@ -0,0 +1,35 @@
1
+ refresh_engine/__init__.py,sha256=d7M6-6DoPOrwYWpwWTE2fe5yIsQapq87_xl7EfjF7p4,3832
2
+ refresh_engine/errors.py,sha256=g4P-mcn70OEnL-9g4JMxeXi_U6quWUJeA0oQEl65Pdo,1321
3
+ refresh_engine/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ refresh_engine/api/__init__.py,sha256=2e5aaGAUri4quCq-92Wj4GghqpMbCpiRKzjfEPM-Xp4,957
5
+ refresh_engine/api/abc.py,sha256=NjjJRfuuQ8fF4oR-GwuXZX8cko9GSQf3Qxrg7wAMLn0,4872
6
+ refresh_engine/api/engine.py,sha256=O_mDTXvV01xhkbDomXWE4gnoAYqi-AgEKcNCLSsd2uE,17885
7
+ refresh_engine/api/protocols.py,sha256=xyUlaIJPH1XP_gbDjHTw5e8KzcRtr6KrOzOINjv4VnM,2403
8
+ refresh_engine/core/models.py,sha256=56uHACS7H3kjzasphbphQtu2-MHphX8H-8S-eaErZG8,10999
9
+ refresh_engine/detection/__init__.py,sha256=H30JM0Lpwo8krH82L54KNF41vDBuxwHYw-dQ8oldHkc,479
10
+ refresh_engine/detection/detector.py,sha256=io08qCJrJ50j3E3E0frw0JR0F37Q-o9gZ5_XnfpeN9g,1762
11
+ refresh_engine/detection/fingerprints.py,sha256=EjrTgQQ46I8uujLFPEzbK_b9wIOQCmyRjzRjy4JOWpo,4330
12
+ refresh_engine/events/__init__.py,sha256=YGjTESs1fZpGF5uJulAQXyJ3RWwJMjymrZaFQkI8Cj4,231
13
+ refresh_engine/events/models.py,sha256=HQALg4kkEbniXGztv9UJL92VtHEUJ1_qX7f95ERyPx0,1284
14
+ refresh_engine/events/publisher.py,sha256=E3GNNzQU9ljMfzZVa7tD0f3jK3Jm5UR6BPAAsEs-l80,2614
15
+ refresh_engine/execution/__init__.py,sha256=twmrCJaq7Je7wGKUqqdRDr7360wD5jsgnm0_8TFW7Xw,124
16
+ refresh_engine/execution/coordinator.py,sha256=kWKz23Cc1F7N_Ti_pIHVKbJ7a0NurUZghqi2KPbV0Lk,5035
17
+ refresh_engine/execution/executor.py,sha256=JaYb_KrUWtNNnT20gvpIAyrXdRDv4coIgSYFU2FujjY,6291
18
+ refresh_engine/observability/__init__.py,sha256=Wew8FLBG6AqG0ygLZ_uEiRTPpueQJgi9tAHyOrSVb2I,286
19
+ refresh_engine/observability/logging.py,sha256=rHc43F61DVr2lC3sSqCiJwDQzLVt3bNKdCl57SL02K0,1607
20
+ refresh_engine/observability/metrics.py,sha256=BMz-mYJH4hJf4LvOOr2ptwFoWo0ypTqhCVyPUIMzf-8,1505
21
+ refresh_engine/planning/__init__.py,sha256=_5-VIIb_LF5x-Gcx7auQvKCcrISEDxpmEAocaE0lJfo,260
22
+ refresh_engine/planning/dependency.py,sha256=po-WJsnUqQDGLHO3BlwWDxuN8C2IO4wyazhr8EHR5pY,3058
23
+ refresh_engine/planning/planner.py,sha256=CmCGCvQ8ILuxbMWPGroB8zmyOVRaXJR3SGN7iw_bpkc,2699
24
+ refresh_engine/scheduling/__init__.py,sha256=ttFD1LVZBM30PtEApjtkDAHTy2uEEuX8IKniaFVCUpM,319
25
+ refresh_engine/scheduling/async_scheduler.py,sha256=xpEISEga2XRmVbnYw0RvkttICZiJ6uxOLi6U2bW3uAo,4586
26
+ refresh_engine/scheduling/external.py,sha256=97oucbbGsIHmVjBCNF7nSX5yQt2ehcm510sukktM6f8,502
27
+ refresh_engine/stores/__init__.py,sha256=Cv70UG0Mtt1leeoE9-FE5ctP73qzpCbLl0lmvKP9ohw,219
28
+ refresh_engine/stores/memory.py,sha256=zQD0Xpx3SMHJvCRjSba38amAsOXaWuk-LBnXWvYzgXc,2555
29
+ refresh_engine/triggers/__init__.py,sha256=BRf_2UfhKnt37kzVminud6CcQ1-1sAtVOEyIgyWIynI,360
30
+ refresh_engine/triggers/adapters.py,sha256=4PFeLJyc_Ml99pHt8bTf7kK3hdZjRTZdJNcwxE4gYZc,964
31
+ refresh_engine/triggers/selectors.py,sha256=mNqTGqmJ1-6bmd3MtLF9032XVZ8ilRZDQn4LS16cwbU,1464
32
+ refresh_engine-0.1.0.dist-info/METADATA,sha256=Oe_fg-dBolTNG4Z9C04VcFwaFQN3bLnzdT8E7H35fps,3113
33
+ refresh_engine-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
34
+ refresh_engine-0.1.0.dist-info/licenses/LICENSE,sha256=A_CLOXXxhuotTkfLXkr4uusrrXRUmNshOBb21YvVWzU,11544
35
+ refresh_engine-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 S. Muni Harish
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.